*** empty log message ***
authorSam Lantinga <slouken@libsdl.org>
Sun, 10 Mar 2002 03:25:47 +0000
changeset 304 ec53caed9fb2
parent 303 767c10b9ec9f
child 305 9c6613983e85
*** empty log message ***
src/video/wincommon/SDL_lowvideo.h
src/video/wincommon/SDL_sysevents.c
src/video/windib/SDL_dibvideo.c
src/video/windx5/SDL_dx5video.c
--- a/src/video/wincommon/SDL_lowvideo.h	Thu Mar 07 20:29:04 2002 +0000
+++ b/src/video/wincommon/SDL_lowvideo.h	Sun Mar 10 03:25:47 2002 +0000
@@ -35,6 +35,12 @@
 /* Hidden "this" pointer for the video functions */
 #define _THIS	SDL_VideoDevice *this
 
+#define WINDIB_FULLSCREEN()						\
+(									\
+	((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \
+	(((SDL_VideoSurface->flags & SDL_OPENGL   ) == SDL_OPENGL    ) || \
+	 (strcmp(this->name, "windib") == 0))				\
+)
 #define DDRAW_FULLSCREEN() 						\
 (									\
 	((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \
@@ -84,6 +90,11 @@
 /* Flag -- the mouse is in relative motion mode */
 extern int mouse_relative;
 
+/* The GDI fullscreen mode currently active */
+#ifndef NO_CHANGEDISPLAYSETTINGS
+extern DEVMODE SDL_fullscreen_mode;
+#endif
+
 /* This is really from SDL_dx5audio.c */
 extern void DX5_SoundFocus(HWND window);
 
--- a/src/video/wincommon/SDL_sysevents.c	Thu Mar 07 20:29:04 2002 +0000
+++ b/src/video/wincommon/SDL_sysevents.c	Sun Mar 10 03:25:47 2002 +0000
@@ -57,6 +57,9 @@
 int SDL_resizing = 0;
 int mouse_relative = 0;
 int posted = 0;
+#ifndef NO_CHANGEDISPLAYSETTINGS
+DEVMODE SDL_fullscreen_mode;
+#endif
 
 
 /* Functions called by the message processing function */
@@ -67,6 +70,21 @@
 void (*WIN_SwapGamma)(_THIS);
 void (*WIN_WinPAINT)(_THIS, HDC hdc);
 
+static void SDL_RestoreGameMode(void)
+{
+#ifndef NO_CHANGEDISPLAYSETTINGS
+	ShowWindow(SDL_Window, SW_RESTORE);
+	ChangeDisplaySettings(&SDL_fullscreen_mode, CDS_FULLSCREEN);
+#endif
+}
+static void SDL_RestoreDesktopMode(void)
+{
+#ifndef NO_CHANGEDISPLAYSETTINGS
+	ShowWindow(SDL_Window, SW_MINIMIZE);
+	ChangeDisplaySettings(NULL, 0);
+#endif
+}
+
 #ifdef WM_MOUSELEAVE
 /* 
    Special code to handle mouse leave events - this sucks...
@@ -178,6 +196,9 @@
 				}
 				if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) {
 					WIN_SwapGamma(this);
+					if ( WINDIB_FULLSCREEN() ) {
+						SDL_RestoreGameMode();
+					}
 				}
 				posted = SDL_PrivateAppActive(1, appstate);
 				WIN_GetKeyboardState();
@@ -192,6 +213,9 @@
 				}
 				if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
 					WIN_SwapGamma(this);
+					if ( WINDIB_FULLSCREEN() ) {
+						SDL_RestoreDesktopMode();
+					}
 				}
 				posted = SDL_PrivateAppActive(0, appstate);
 			}
--- a/src/video/windib/SDL_dibvideo.c	Thu Mar 07 20:29:04 2002 +0000
+++ b/src/video/windib/SDL_dibvideo.c	Sun Mar 10 03:25:47 2002 +0000
@@ -527,6 +527,7 @@
 		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
 		if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
 			video->flags |= SDL_FULLSCREEN;
+			SDL_fullscreen_mode = settings;
 		}
 	}
 #endif /* !NO_CHANGEDISPLAYSETTINGS */
--- a/src/video/windx5/SDL_dx5video.c	Thu Mar 07 20:29:04 2002 +0000
+++ b/src/video/windx5/SDL_dx5video.c	Sun Mar 10 03:25:47 2002 +0000
@@ -51,9 +51,6 @@
 #include "SDL_dx5yuv_c.h"
 #include "SDL_wingl_c.h"
 
-/* Function called to create a GL video mode - use the GDI driver, not DirectX */
-extern SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
-				int width, int height, int bpp, Uint32 flags);
 
 /* DirectX function pointers for video and events */
 HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
@@ -1078,6 +1075,7 @@
 			settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
 			if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
 				video->flags |= SDL_FULLSCREEN;
+				SDL_fullscreen_mode = settings;
 			}
 		}