2010-02-15 23:26:55 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-2001 Id Software, Inc.
|
|
|
|
Copyright (C) 2002-2005 John Fitzgibbons and others
|
|
|
|
Copyright (C) 2007-2008 Kristian Duske
|
2014-09-22 08:55:46 +00:00
|
|
|
Copyright (C) 2010-2014 QuakeSpasm developers
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
|
|
|
#include <windows.h>
|
2012-08-16 04:51:41 +00:00
|
|
|
#if defined(SDL_FRAMEWORK) || defined(NO_SDL_CONFIG)
|
2014-09-10 17:41:34 +00:00
|
|
|
#if defined(USE_SDL2)
|
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
#include <SDL2/SDL_syswm.h>
|
|
|
|
#else
|
2012-08-16 04:51:41 +00:00
|
|
|
#include <SDL/SDL.h>
|
|
|
|
#include <SDL/SDL_syswm.h>
|
2014-09-10 17:41:34 +00:00
|
|
|
#endif
|
2012-08-16 04:51:41 +00:00
|
|
|
#else
|
2010-06-19 22:50:48 +00:00
|
|
|
#include "SDL.h"
|
2010-02-15 23:33:12 +00:00
|
|
|
#include "SDL_syswm.h"
|
2012-08-16 04:51:41 +00:00
|
|
|
#endif
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
static HICON icon;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
|
|
|
void PL_SetWindowIcon (void)
|
|
|
|
{
|
2010-06-22 11:01:24 +00:00
|
|
|
HINSTANCE handle;
|
|
|
|
SDL_SysWMinfo wminfo;
|
|
|
|
HWND hwnd;
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
handle = GetModuleHandle(NULL);
|
|
|
|
icon = LoadIcon(handle, "icon");
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
if (!icon)
|
|
|
|
return; /* no icon in the exe */
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
SDL_VERSION(&wminfo.version);
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2014-09-05 19:34:43 +00:00
|
|
|
#if defined(USE_SDL2)
|
2014-09-14 06:03:56 +00:00
|
|
|
if (SDL_GetWindowWMInfo((SDL_Window*) VID_GetWindow(), &wminfo) != SDL_TRUE)
|
2014-09-05 19:34:43 +00:00
|
|
|
return; /* wrong SDL version */
|
|
|
|
|
|
|
|
hwnd = wminfo.info.win.window;
|
|
|
|
#else
|
2010-06-22 11:01:24 +00:00
|
|
|
if (SDL_GetWMInfo(&wminfo) != 1)
|
|
|
|
return; /* wrong SDL version */
|
2010-02-15 23:26:55 +00:00
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
hwnd = wminfo.window;
|
2014-09-05 19:34:43 +00:00
|
|
|
#endif
|
2010-02-17 16:39:20 +00:00
|
|
|
#ifdef _WIN64
|
2010-06-22 11:01:24 +00:00
|
|
|
SetClassLongPtr(hwnd, GCLP_HICON, (LONG_PTR) icon);
|
2010-02-17 16:39:20 +00:00
|
|
|
#else
|
2010-06-22 11:01:24 +00:00
|
|
|
SetClassLong(hwnd, GCL_HICON, (LONG) icon);
|
2010-02-17 16:39:20 +00:00
|
|
|
#endif
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void PL_VID_Shutdown (void)
|
|
|
|
{
|
2010-06-22 11:01:24 +00:00
|
|
|
DestroyIcon(icon);
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
|
|
|
|
2012-09-27 12:58:37 +00:00
|
|
|
#define MAX_CLIPBOARDTXT MAXCMDLINE /* 256 */
|
|
|
|
char *PL_GetClipboardData (void)
|
|
|
|
{
|
|
|
|
char *data = NULL;
|
|
|
|
char *cliptext;
|
|
|
|
|
|
|
|
if (OpenClipboard(NULL) != 0)
|
|
|
|
{
|
|
|
|
HANDLE hClipboardData;
|
|
|
|
|
|
|
|
if ((hClipboardData = GetClipboardData(CF_TEXT)) != NULL)
|
|
|
|
{
|
|
|
|
cliptext = (char *) GlobalLock(hClipboardData);
|
|
|
|
if (cliptext != NULL)
|
|
|
|
{
|
|
|
|
size_t size = GlobalSize(hClipboardData) + 1;
|
|
|
|
/* this is intended for simple small text copies
|
|
|
|
* such as an ip address, etc: do chop the size
|
|
|
|
* here, otherwise we may experience Z_Malloc()
|
|
|
|
* failures and all other not-oh-so-fun stuff. */
|
|
|
|
size = q_min(MAX_CLIPBOARDTXT, size);
|
|
|
|
data = (char *) Z_Malloc(size);
|
|
|
|
q_strlcpy (data, cliptext, size);
|
|
|
|
GlobalUnlock (hClipboardData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CloseClipboard ();
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2010-06-22 11:01:24 +00:00
|
|
|
void PL_ErrorDialog(const char *errorMsg)
|
2010-02-15 23:26:55 +00:00
|
|
|
{
|
2010-06-22 11:01:24 +00:00
|
|
|
MessageBox (NULL, errorMsg, "Quake Error",
|
|
|
|
MB_OK | MB_SETFOREGROUND | MB_ICONSTOP);
|
2010-02-15 23:26:55 +00:00
|
|
|
}
|
2010-06-19 22:50:48 +00:00
|
|
|
|