# HG changeset patch # User Sam Lantinga # Date 1138515098 0 # Node ID f61f045343d3c9fff2a439525921282989eb4b33 # Parent e867f327aa540f4da5cb1b2c9e12873844a4ccb0 Re-query the SDL_WINDOWID each time we initialize the video diff -r e867f327aa54 -r f61f045343d3 src/video/wincommon/SDL_lowvideo.h --- a/src/video/wincommon/SDL_lowvideo.h Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/wincommon/SDL_lowvideo.h Sun Jan 29 06:11:38 2006 +0000 @@ -61,7 +61,7 @@ #endif extern HINSTANCE SDL_Instance; extern HWND SDL_Window; -extern const char *SDL_windowid; +extern BOOL SDL_windowid; /* Variables and functions exported to other parts of the native video subsystem (SDL_sysevents.c) diff -r e867f327aa54 -r f61f045343d3 src/video/wincommon/SDL_sysevents.c --- a/src/video/wincommon/SDL_sysevents.c Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/wincommon/SDL_sysevents.c Sun Jan 29 06:11:38 2006 +0000 @@ -672,7 +672,7 @@ } /* This allows the SDL_WINDOWID hack */ -const char *SDL_windowid = NULL; +BOOL SDL_windowid = FALSE; static int app_registered = 0; @@ -743,9 +743,6 @@ } #endif /* WM_MOUSELEAVE */ - /* Check for SDL_WINDOWID hack */ - SDL_windowid = getenv("SDL_WINDOWID"); - #ifndef NO_GETKEYBOARDSTATE /* Initialise variables for SDL_ToUnicode() */ codepage = GetCodePage(); diff -r e867f327aa54 -r f61f045343d3 src/video/wincommon/SDL_wingl.c --- a/src/video/wincommon/SDL_wingl.c Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/wincommon/SDL_wingl.c Sun Jan 29 06:11:38 2006 +0000 @@ -44,15 +44,11 @@ static int WIN_GL_ResetWindow(_THIS) { int status = 0; - int can_reset = 1; - /* If we were passed a window, then we can't create a new one */ - if ( SDL_windowid ) { - can_reset = 0; - } #if 0 /* This doesn't work with DirectX code (see CVS comments) */ #ifndef _WIN32_WCE /* FIXME WinCE needs the UNICODE version of CreateWindow() */ - if ( can_reset ) { + /* If we were passed a window, then we can't create a new one */ + if ( !SDL_windowid ) { /* Save the existing window attributes */ LONG style; RECT rect = { 0, 0, 0, 0 }; diff -r e867f327aa54 -r f61f045343d3 src/video/windib/SDL_dibevents.c --- a/src/video/windib/SDL_dibevents.c Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/windib/SDL_dibevents.c Sun Jan 29 06:11:38 2006 +0000 @@ -404,24 +404,23 @@ int DIB_CreateWindow(_THIS) { -#if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - wchar_t *SDL_windowid_t; -#endif + char *windowid = getenv("SDL_WINDOWID"); #ifndef CS_BYTEALIGNCLIENT #define CS_BYTEALIGNCLIENT 0 #endif SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); + + SDL_windowid = (windowid != NULL); if ( SDL_windowid ) { - -// wince 2.1 does not have strtol #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) - SDL_windowid_t = malloc((strlen(SDL_windowid) + 1) * sizeof(wchar_t)); - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, SDL_windowid, -1, SDL_windowid_t, strlen(SDL_windowid) + 1); - SDL_Window = (HWND)wcstol(SDL_windowid_t, NULL, 0); - free(SDL_windowid_t); + /* wince 2.1 does not have strtol */ + wchar_t *windowid_t = malloc((strlen(windowid) + 1) * sizeof(wchar_t)); + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, strlen(windowid) + 1); + SDL_Window = (HWND)wcstol(windowid_t, NULL, 0); + free(windowid_t); #else - SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); + SDL_Window = (HWND)strtol(windowid, NULL, 0); #endif if ( SDL_Window == NULL ) { SDL_SetError("Couldn't get user specified window"); diff -r e867f327aa54 -r f61f045343d3 src/video/windib/SDL_dibvideo.c --- a/src/video/windib/SDL_dibvideo.c Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/windib/SDL_dibvideo.c Sun Jan 29 06:11:38 2006 +0000 @@ -589,7 +589,7 @@ } /* DJM: Don't piss of anyone who has setup his own window */ - if ( SDL_windowid == NULL ) + if ( !SDL_windowid ) SetWindowLong(SDL_Window, GWL_STYLE, style); /* Delete the old bitmap if necessary */ @@ -665,7 +665,7 @@ } /* Resize the window */ - if ( SDL_windowid == NULL ) { + if ( !SDL_windowid ) { HWND top; UINT swp_flags; const char *window = getenv("SDL_VIDEO_WINDOW_POS"); diff -r e867f327aa54 -r f61f045343d3 src/video/windx5/SDL_dx5events.c --- a/src/video/windx5/SDL_dx5events.c Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/windx5/SDL_dx5events.c Sun Jan 29 06:11:38 2006 +0000 @@ -848,6 +848,7 @@ int DX5_CreateWindow(_THIS) { + char *windowid = getenv("SDL_WINDOWID"); int i; /* Clear out DirectInput variables in case we fail */ @@ -861,8 +862,10 @@ #define CS_BYTEALIGNCLIENT 0 #endif SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); + + SDL_windowid = (windowid != NULL); if ( SDL_windowid ) { - SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); + SDL_Window = (HWND)strtol(windowid, NULL, 0); if ( SDL_Window == NULL ) { SDL_SetError("Couldn't get user specified window"); return(-1); diff -r e867f327aa54 -r f61f045343d3 src/video/windx5/SDL_dx5video.c --- a/src/video/windx5/SDL_dx5video.c Sat Jan 28 05:47:11 2006 +0000 +++ b/src/video/windx5/SDL_dx5video.c Sun Jan 29 06:11:38 2006 +0000 @@ -1133,11 +1133,11 @@ } /* DJM: Don't piss of anyone who has setup his own window */ - if ( SDL_windowid == NULL ) + if ( !SDL_windowid ) SetWindowLong(SDL_Window, GWL_STYLE, style); /* Resize the window (copied from SDL WinDIB driver) */ - if ( SDL_windowid == NULL ) { + if ( !SDL_windowid ) { HWND top; UINT swp_flags; const char *window = getenv("SDL_VIDEO_WINDOW_POS"); @@ -1223,7 +1223,7 @@ #endif } /* DJM: Don't piss of anyone who has setup his own window */ - if ( SDL_windowid == NULL ) + if ( !SDL_windowid ) SetWindowLong(SDL_Window, GWL_STYLE, style); /* Set DirectDraw sharing mode.. exclusive when fullscreen */