From 183461a42830f27ad8e4e2af97917850a348b7f3 Mon Sep 17 00:00:00 2001 From: Lance Date: Wed, 3 Jun 2009 09:09:35 +0000 Subject: [PATCH] Crossbuilt MinGW32 SDL binaries working again, applied a parentwindow git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3210 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/fs.c | 27 ++-- engine/common/fs_stdio.c | 2 +- engine/libs/mingw-libs/SDL_syswm.h | 214 +++++++++++++++++++++++++++++ 3 files changed, 233 insertions(+), 10 deletions(-) create mode 100644 engine/libs/mingw-libs/SDL_syswm.h diff --git a/engine/common/fs.c b/engine/common/fs.c index 414d2599a..f349c04de 100644 --- a/engine/common/fs.c +++ b/engine/common/fs.c @@ -9,12 +9,14 @@ #include "fs.h" +#include "SDL_syswm.h" // mingw sdl cross binary complains off sys_parentwindow + hashtable_t filesystemhash; qboolean com_fschanged = true; extern cvar_t com_fs_cache; int active_fs_cachetype; -struct +struct { const char *extension; searchpathfuncs_t *funcs; @@ -607,7 +609,7 @@ char *FS_GetPackNames(char *buffer, int buffersize, qboolean referencedonly) searchpath_t *search; buffersize--; *buffer = 0; - + if (com_purepaths) { for (search = com_purepaths ; search ; search = search->nextpure) @@ -975,7 +977,7 @@ vfsfile_t *FS_OpenVFS(const char *filename, const char *mode, enum fs_relative r //blanket-bans - + filename = FS_GetCleanPath(filename, cleanname, sizeof(cleanname)); if (!filename) return NULL; @@ -1092,7 +1094,7 @@ void FS_CreatePath(const char *pname, enum fs_relative relativeto) char fullname[MAX_OSPATH]; if (!FS_NativePath(pname, relativeto, fullname, sizeof(fullname))) return; - + COM_CreatePath(fullname); } @@ -1663,7 +1665,7 @@ void COM_Gamedir (const char *dir) return; } } - + } } @@ -2137,7 +2139,7 @@ qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *base } #if !defined(NPQTV) && !defined(SERVERONLY) //this is *really* unfortunate, but doing this crashes the browser - //I assume its because the client + //I assume its because the client if (poshname) { @@ -2145,6 +2147,13 @@ qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *base BROWSEINFO bi; LPITEMIDLIST il; memset(&bi, 0, sizeof(bi)); + + #if defined(_SDL) && defined (WIN32) && defined (MINGW) // mingw32 sdl cross compiled binary, code completely untested, doesn't crash so good sign ~moodles + SDL_SysWMinfo wmInfo; + SDL_GetWMInfo(&wmInfo); + HWND sys_parentwindow = wmInfo.window; + #endif + if (sys_parentwindow) bi.hwndOwner = sys_parentwindow; //note that this is usually still null else @@ -2369,13 +2378,13 @@ void COM_InitFilesystem (void) advapi32 = LoadLibrary("advapi32.dll"); if (advapi32) - { + { BOOL (WINAPI *dCheckTokenMembership) (HANDLE TokenHandle, PSID SidToCheck, PBOOL IsMember); dCheckTokenMembership = (void *)GetProcAddress(advapi32, "CheckTokenMembership"); if (dCheckTokenMembership) { - // on XP systems, only use a home directory by default if we're a limited user or if we're on a network + // on XP systems, only use a home directory by default if we're a limited user or if we're on a network BOOL isadmin, isonnetwork; SID_IDENTIFIER_AUTHORITY ntauth = SECURITY_NT_AUTHORITY; PSID adminSID, networkSID; @@ -2385,7 +2394,7 @@ void COM_InitFilesystem (void) SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, - &adminSID); + &adminSID); // just checking the network rid should be close enough to matching domain logins isonnetwork = AllocateAndInitializeSid(&ntauth, diff --git a/engine/common/fs_stdio.c b/engine/common/fs_stdio.c index d663e7db3..a2efa781f 100644 --- a/engine/common/fs_stdio.c +++ b/engine/common/fs_stdio.c @@ -1,7 +1,7 @@ #include "quakedef.h" #include "fs.h" -#ifndef _WIN32 +#if !defined(_WIN32) || defined(_SDL) #define VFSSTDIO_Open VFSOS_Open #define stdiofilefuncs osfilefuncs #endif diff --git a/engine/libs/mingw-libs/SDL_syswm.h b/engine/libs/mingw-libs/SDL_syswm.h new file mode 100644 index 000000000..010dd1bcc --- /dev/null +++ b/engine/libs/mingw-libs/SDL_syswm.h @@ -0,0 +1,214 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include file for SDL custom system window manager hooks */ + +#ifndef _SDL_syswm_h +#define _SDL_syswm_h + +#include "SDL_stdinc.h" +#include "SDL_error.h" +#include "SDL_version.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/* Your application has access to a special type of event 'SDL_SYSWMEVENT', + which contains window-manager specific information and arrives whenever + an unhandled window event occurs. This event is ignored by default, but + you can enable it with SDL_EventState() +*/ +#ifdef SDL_PROTOTYPES_ONLY +struct SDL_SysWMinfo; +typedef struct SDL_SysWMinfo SDL_SysWMinfo; +#else + +/* This is the structure for custom window manager events */ +#if defined(SDL_VIDEO_DRIVER_X11) +#if defined(__APPLE__) && defined(__MACH__) +/* conflicts with Quickdraw.h */ +#define Cursor X11Cursor +#endif + +#include +#include + +#if defined(__APPLE__) && defined(__MACH__) +/* matches the re-define above */ +#undef Cursor +#endif + +/* These are the various supported subsystems under UNIX */ +typedef enum { + SDL_SYSWM_X11 +} SDL_SYSWM_TYPE; + +/* The UNIX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + XEvent xevent; + } event; +}; + +/* The UNIX custom window manager information structure. + When this structure is returned, it holds information about which + low level system it is using, and will be one of SDL_SYSWM_TYPE. + */ +typedef struct SDL_SysWMinfo { + SDL_version version; + SDL_SYSWM_TYPE subsystem; + union { + struct { + Display *display; /* The X11 display */ + Window window; /* The X11 display window */ + /* These locking functions should be called around + any X11 functions using the display variable, + but not the gfxdisplay variable. + They lock the event thread, so should not be + called around event functions or from event filters. + */ + void (*lock_func)(void); + void (*unlock_func)(void); + + /* Introduced in SDL 1.0.2 */ + Window fswindow; /* The X11 fullscreen window */ + Window wmwindow; /* The X11 managed input window */ + + /* Introduced in SDL 1.2.12 */ + Display *gfxdisplay; /* The X11 display to which rendering is done */ + } x11; + } info; +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_NANOX) +#include + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version ; + GR_WINDOW_ID window ; /* The display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_WINDIB) || defined(SDL_VIDEO_DRIVER_DDRAW) || defined(SDL_VIDEO_DRIVER_GAPI) +#define WIN32_LEAN_AND_MEAN +#include + +/* The windows custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + HWND hwnd; /* The window for the message */ + UINT msg; /* The type of message */ + WPARAM wParam; /* WORD message parameter */ + LPARAM lParam; /* LONG message parameter */ +}; + +/* The windows custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + HWND window; /* The Win32 display window */ + HGLRC hglrc; /* The OpenGL context, if any */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_RISCOS) + +/* RISC OS custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int eventCode; /* The window for the message */ + int pollBlock[64]; +}; + +/* The RISC OS custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int wimpVersion; /* Wimp version running under */ + int taskHandle; /* The RISC OS task handle */ + int window; /* The RISC OS display window */ +} SDL_SysWMinfo; + +#elif defined(SDL_VIDEO_DRIVER_PHOTON) +#include +#include + +/* The QNX custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The QNX custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#else + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The generic custom window manager information structure */ +typedef struct SDL_SysWMinfo { + SDL_version version; + int data; +} SDL_SysWMinfo; + +#endif /* video driver type */ + +#endif /* SDL_PROTOTYPES_ONLY */ + +/* Function prototypes */ +/* + * This function gives you custom hooks into the window manager information. + * It fills the structure pointed to by 'info' with custom information and + * returns 1 if the function is implemented. If it's not implemented, or + * the version member of the 'info' structure is invalid, it returns 0. + * + * You typically use this function like this: + * SDL_SysWMInfo info; + * SDL_VERSION(&info.version); + * if ( SDL_GetWMInfo(&info) ) { ... } + */ +extern DECLSPEC int SDLCALL SDL_GetWMInfo(SDL_SysWMinfo *info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_syswm_h */