From 38126709168df23b4dc3456ebfea49183b476121 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 10 Mar 2002 03:25:47 +0000 Subject: [PATCH] *** empty log message *** --- src/video/wincommon/SDL_lowvideo.h | 11 +++++++++++ src/video/wincommon/SDL_sysevents.c | 24 ++++++++++++++++++++++++ src/video/windib/SDL_dibvideo.c | 1 + src/video/windx5/SDL_dx5video.c | 4 +--- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/video/wincommon/SDL_lowvideo.h b/src/video/wincommon/SDL_lowvideo.h index 808cc7b5f..27057b043 100644 --- a/src/video/wincommon/SDL_lowvideo.h +++ b/src/video/wincommon/SDL_lowvideo.h @@ -35,6 +35,12 @@ static char rcsid = /* 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 @@ extern int SDL_resizing; /* 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); diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index 9b4bc0ece..c4601e233 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -57,6 +57,9 @@ RECT SDL_bounds = {0, 0, 0, 0}; 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_PaletteChanged)(_THIS, HWND window); 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 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) { WIN_SwapGamma(this); + if ( WINDIB_FULLSCREEN() ) { + SDL_RestoreGameMode(); + } } posted = SDL_PrivateAppActive(1, appstate); WIN_GetKeyboardState(); @@ -192,6 +213,9 @@ LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) { WIN_SwapGamma(this); + if ( WINDIB_FULLSCREEN() ) { + SDL_RestoreDesktopMode(); + } } posted = SDL_PrivateAppActive(0, appstate); } diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index e840129b5..0ec2ce643 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -527,6 +527,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, 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 */ diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index 6d59f6a8a..b5a7d5f86 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -51,9 +51,6 @@ static char rcsid = #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 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL; if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) { video->flags |= SDL_FULLSCREEN; + SDL_fullscreen_mode = settings; } }