Re-query the SDL_WINDOWID each time we initialize the video
authorSam Lantinga <slouken@libsdl.org>
Sun, 29 Jan 2006 06:11:38 +0000
changeset 1280f61f045343d3
parent 1279 e867f327aa54
child 1281 644b39bf7253
Re-query the SDL_WINDOWID each time we initialize the video
src/video/wincommon/SDL_lowvideo.h
src/video/wincommon/SDL_sysevents.c
src/video/wincommon/SDL_wingl.c
src/video/windib/SDL_dibevents.c
src/video/windib/SDL_dibvideo.c
src/video/windx5/SDL_dx5events.c
src/video/windx5/SDL_dx5video.c
     1.1 --- a/src/video/wincommon/SDL_lowvideo.h	Sat Jan 28 05:47:11 2006 +0000
     1.2 +++ b/src/video/wincommon/SDL_lowvideo.h	Sun Jan 29 06:11:38 2006 +0000
     1.3 @@ -61,7 +61,7 @@
     1.4  #endif
     1.5  extern HINSTANCE SDL_Instance;
     1.6  extern HWND SDL_Window;
     1.7 -extern const char *SDL_windowid;
     1.8 +extern BOOL SDL_windowid;
     1.9  
    1.10  /* Variables and functions exported to other parts of the native video
    1.11     subsystem (SDL_sysevents.c)
     2.1 --- a/src/video/wincommon/SDL_sysevents.c	Sat Jan 28 05:47:11 2006 +0000
     2.2 +++ b/src/video/wincommon/SDL_sysevents.c	Sun Jan 29 06:11:38 2006 +0000
     2.3 @@ -672,7 +672,7 @@
     2.4  }
     2.5  
     2.6  /* This allows the SDL_WINDOWID hack */
     2.7 -const char *SDL_windowid = NULL;
     2.8 +BOOL SDL_windowid = FALSE;
     2.9  
    2.10  static int app_registered = 0;
    2.11  
    2.12 @@ -743,9 +743,6 @@
    2.13  	}
    2.14  #endif /* WM_MOUSELEAVE */
    2.15  
    2.16 -	/* Check for SDL_WINDOWID hack */
    2.17 -	SDL_windowid = getenv("SDL_WINDOWID");
    2.18 -
    2.19  #ifndef NO_GETKEYBOARDSTATE
    2.20  	/* Initialise variables for SDL_ToUnicode() */
    2.21  	codepage = GetCodePage();
     3.1 --- a/src/video/wincommon/SDL_wingl.c	Sat Jan 28 05:47:11 2006 +0000
     3.2 +++ b/src/video/wincommon/SDL_wingl.c	Sun Jan 29 06:11:38 2006 +0000
     3.3 @@ -44,15 +44,11 @@
     3.4  static int WIN_GL_ResetWindow(_THIS)
     3.5  {
     3.6  	int status = 0;
     3.7 -	int can_reset = 1;
     3.8  
     3.9 -	/* If we were passed a window, then we can't create a new one */
    3.10 -	if ( SDL_windowid ) {
    3.11 -		can_reset = 0;
    3.12 -	}
    3.13  #if 0 /* This doesn't work with DirectX code (see CVS comments) */
    3.14  #ifndef _WIN32_WCE /* FIXME WinCE needs the UNICODE version of CreateWindow() */
    3.15 -	if ( can_reset ) {
    3.16 +	/* If we were passed a window, then we can't create a new one */
    3.17 +	if ( !SDL_windowid ) {
    3.18  		/* Save the existing window attributes */
    3.19  		LONG style;
    3.20  		RECT rect = { 0, 0, 0, 0 };
     4.1 --- a/src/video/windib/SDL_dibevents.c	Sat Jan 28 05:47:11 2006 +0000
     4.2 +++ b/src/video/windib/SDL_dibevents.c	Sun Jan 29 06:11:38 2006 +0000
     4.3 @@ -404,24 +404,23 @@
     4.4  
     4.5  int DIB_CreateWindow(_THIS)
     4.6  {
     4.7 -#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
     4.8 -	wchar_t *SDL_windowid_t;
     4.9 -#endif
    4.10 +	char *windowid = getenv("SDL_WINDOWID");
    4.11  
    4.12  #ifndef CS_BYTEALIGNCLIENT
    4.13  #define CS_BYTEALIGNCLIENT	0
    4.14  #endif
    4.15  	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
    4.16 +
    4.17 +	SDL_windowid = (windowid != NULL);
    4.18  	if ( SDL_windowid ) {
    4.19 -
    4.20 -// wince 2.1 does not have strtol
    4.21  #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
    4.22 -		SDL_windowid_t = malloc((strlen(SDL_windowid) + 1) * sizeof(wchar_t));
    4.23 -		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, SDL_windowid, -1, SDL_windowid_t, strlen(SDL_windowid) + 1);
    4.24 -		SDL_Window = (HWND)wcstol(SDL_windowid_t, NULL, 0);
    4.25 -		free(SDL_windowid_t);
    4.26 +		/* wince 2.1 does not have strtol */
    4.27 +		wchar_t *windowid_t = malloc((strlen(windowid) + 1) * sizeof(wchar_t));
    4.28 +		MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, windowid, -1, windowid_t, strlen(windowid) + 1);
    4.29 +		SDL_Window = (HWND)wcstol(windowid_t, NULL, 0);
    4.30 +		free(windowid_t);
    4.31  #else
    4.32 -		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
    4.33 +		SDL_Window = (HWND)strtol(windowid, NULL, 0);
    4.34  #endif
    4.35  		if ( SDL_Window == NULL ) {
    4.36  			SDL_SetError("Couldn't get user specified window");
     5.1 --- a/src/video/windib/SDL_dibvideo.c	Sat Jan 28 05:47:11 2006 +0000
     5.2 +++ b/src/video/windib/SDL_dibvideo.c	Sun Jan 29 06:11:38 2006 +0000
     5.3 @@ -589,7 +589,7 @@
     5.4  	}
     5.5  
     5.6  	/* DJM: Don't piss of anyone who has setup his own window */
     5.7 -	if ( SDL_windowid == NULL )
     5.8 +	if ( !SDL_windowid )
     5.9  		SetWindowLong(SDL_Window, GWL_STYLE, style);
    5.10  
    5.11  	/* Delete the old bitmap if necessary */
    5.12 @@ -665,7 +665,7 @@
    5.13  	}
    5.14  
    5.15  	/* Resize the window */
    5.16 -	if ( SDL_windowid == NULL ) {
    5.17 +	if ( !SDL_windowid ) {
    5.18  		HWND top;
    5.19  		UINT swp_flags;
    5.20  		const char *window = getenv("SDL_VIDEO_WINDOW_POS");
     6.1 --- a/src/video/windx5/SDL_dx5events.c	Sat Jan 28 05:47:11 2006 +0000
     6.2 +++ b/src/video/windx5/SDL_dx5events.c	Sun Jan 29 06:11:38 2006 +0000
     6.3 @@ -848,6 +848,7 @@
     6.4  
     6.5  int DX5_CreateWindow(_THIS)
     6.6  {
     6.7 +	char *windowid = getenv("SDL_WINDOWID");
     6.8  	int i;
     6.9  
    6.10  	/* Clear out DirectInput variables in case we fail */
    6.11 @@ -861,8 +862,10 @@
    6.12  #define CS_BYTEALIGNCLIENT	0
    6.13  #endif
    6.14  	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
    6.15 +
    6.16 +	SDL_windowid = (windowid != NULL);
    6.17  	if ( SDL_windowid ) {
    6.18 -		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
    6.19 +		SDL_Window = (HWND)strtol(windowid, NULL, 0);
    6.20  		if ( SDL_Window == NULL ) {
    6.21  			SDL_SetError("Couldn't get user specified window");
    6.22  			return(-1);
     7.1 --- a/src/video/windx5/SDL_dx5video.c	Sat Jan 28 05:47:11 2006 +0000
     7.2 +++ b/src/video/windx5/SDL_dx5video.c	Sun Jan 29 06:11:38 2006 +0000
     7.3 @@ -1133,11 +1133,11 @@
     7.4  		}
     7.5  
     7.6  		/* DJM: Don't piss of anyone who has setup his own window */
     7.7 -		if ( SDL_windowid == NULL )
     7.8 +		if ( !SDL_windowid )
     7.9  			SetWindowLong(SDL_Window, GWL_STYLE, style);
    7.10  
    7.11  		/* Resize the window (copied from SDL WinDIB driver) */
    7.12 -		if ( SDL_windowid == NULL ) {
    7.13 +		if ( !SDL_windowid ) {
    7.14  			HWND top;
    7.15  			UINT swp_flags;
    7.16  			const char *window = getenv("SDL_VIDEO_WINDOW_POS");
    7.17 @@ -1223,7 +1223,7 @@
    7.18  #endif
    7.19  	}
    7.20  	/* DJM: Don't piss of anyone who has setup his own window */
    7.21 -	if ( SDL_windowid == NULL )
    7.22 +	if ( !SDL_windowid )
    7.23  		SetWindowLong(SDL_Window, GWL_STYLE, style);
    7.24  
    7.25  	/* Set DirectDraw sharing mode.. exclusive when fullscreen */