From 6765e8c7124a72e741524bb79766d79bd6260e8d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sat, 7 Jul 2001 07:59:37 +0000 Subject: [PATCH] Hopefully fixed the fullscreen mode code for KDE --- src/video/x11/SDL_x11events.c | 6 ---- src/video/x11/SDL_x11modes.c | 54 ++++++++++++++++------------------- src/video/x11/SDL_x11video.c | 12 -------- src/video/x11/SDL_x11wm.c | 25 +++++++++------- 4 files changed, 40 insertions(+), 57 deletions(-) diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 132c5cf26..ca49bd467 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -347,13 +347,7 @@ printf("MapNotify!\n"); if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) { -#ifdef GRAB_FULLSCREEN X11_EnterFullScreen(this); -#else - /* Queue entry into fullscreen mode */ - switch_waiting = 0x01 | SDL_FULLSCREEN; - switch_time = SDL_GetTicks() + 1500; -#endif } else { X11_GrabInputNoLock(this, this->input_grab); } diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 8a1642c44..dc2238544 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -37,6 +37,7 @@ static char rcsid = #include "SDL_x11video.h" #include "SDL_x11wm_c.h" #include "SDL_x11modes_c.h" +#include "SDL_x11image_c.h" #ifdef XFREE86_VM @@ -459,31 +460,6 @@ int X11_EnterFullScreen(_THIS) XRaiseWindow(SDL_Display, FSwindow); #endif - /* Grab the mouse on the fullscreen window - The event handling will know when we become active, and then - enter fullscreen mode if we can't grab the mouse this time. - */ -#ifdef GRAB_FULLSCREEN - if ( (XGrabPointer(SDL_Display, FSwindow, True, 0, - GrabModeAsync, GrabModeAsync, - FSwindow, None, CurrentTime) != GrabSuccess) || - (XGrabKeyboard(SDL_Display, WMwindow, True, - GrabModeAsync, GrabModeAsync, CurrentTime) != 0) ) { -#else - if ( XGrabPointer(SDL_Display, FSwindow, True, 0, - GrabModeAsync, GrabModeAsync, - FSwindow, None, CurrentTime) != GrabSuccess ) { -#endif - /* We lost the grab, so try again later */ - XUnmapWindow(SDL_Display, FSwindow); - X11_WaitUnmapped(this, FSwindow); - X11_QueueEnterFullScreen(this); - return(0); - } -#ifdef GRAB_FULLSCREEN - SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); -#endif - #ifdef XFREE86_VM /* Save the current video mode */ if ( use_vidmode ) { @@ -502,7 +478,19 @@ int X11_EnterFullScreen(_THIS) XInstallColormap(SDL_Display, SDL_XColorMap); } } - X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); + if ( okay ) + X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); + + /* We may need to refresh the screen at this point (no backing store) + We also don't get an event, which is why we explicitly refresh. */ + if ( this->screen ) { + if ( this->screen->flags & SDL_OPENGL ) { + SDL_PrivateExpose(); + } else { + X11_RefreshDisplay(this); + } + } + return(okay); } @@ -518,9 +506,6 @@ int X11_LeaveFullScreen(_THIS) #endif XUnmapWindow(SDL_Display, FSwindow); X11_WaitUnmapped(this, FSwindow); -#ifdef GRAB_FULLSCREEN - XUngrabKeyboard(SDL_Display, CurrentTime); -#endif XSync(SDL_Display, True); /* Flush spurious mode change events */ currently_fullscreen = 0; } @@ -530,5 +515,16 @@ int X11_LeaveFullScreen(_THIS) explicitly grabbed. */ X11_GrabInputNoLock(this, this->input_grab & ~SDL_GRAB_FULLSCREEN); + + /* We may need to refresh the screen at this point (no backing store) + We also don't get an event, which is why we explicitly refresh. */ + if ( this->screen ) { + if ( this->screen->flags & SDL_OPENGL ) { + SDL_PrivateExpose(); + } else { + X11_RefreshDisplay(this); + } + } + return(0); } diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index ac3d1dd51..6ff9e00cf 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -853,11 +853,7 @@ static int X11_CreateWindow(_THIS, SDL_Surface *screen, if ( flags & SDL_FULLSCREEN ) { screen->flags |= SDL_FULLSCREEN; X11_WaitMapped(this, WMwindow); -#ifdef GRAB_FULLSCREEN X11_EnterFullScreen(this); -#else - X11_QueueEnterFullScreen(this); -#endif } else { screen->flags &= ~SDL_FULLSCREEN; } @@ -881,11 +877,7 @@ static int X11_ResizeWindow(_THIS, X11_ResizeFullScreen(this); } else { screen->flags |= SDL_FULLSCREEN; -#ifdef GRAB_FULLSCREEN X11_EnterFullScreen(this); -#else - X11_QueueEnterFullScreen(this); -#endif } } else { if ( screen->flags & SDL_FULLSCREEN ) { @@ -969,12 +961,8 @@ static int X11_ToggleFullScreen(_THIS, int on) SDL_Lock_EventThread(); } if ( on ) { -#ifdef GRAB_FULLSCREEN this->screen->flags |= SDL_FULLSCREEN; X11_EnterFullScreen(this); -#else - X11_QueueEnterFullScreen(this); -#endif } else { this->screen->flags &= ~SDL_FULLSCREEN; X11_LeaveFullScreen(this); diff --git a/src/video/x11/SDL_x11wm.c b/src/video/x11/SDL_x11wm.c index 1d737e635..4fd9a7f3e 100644 --- a/src/video/x11/SDL_x11wm.c +++ b/src/video/x11/SDL_x11wm.c @@ -258,16 +258,17 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) True, 0, GrabModeAsync, GrabModeAsync, FSwindow, None, CurrentTime); - if ( result == AlreadyGrabbed ) { + if ( result == GrabSuccess ) { break; } SDL_Delay(100); } + if ( result != GrabSuccess ) { + /* Uh, oh, what do we do here? */ ; + } } -#ifdef GRAB_FULLSCREEN if ( !(this->screen->flags & SDL_FULLSCREEN) ) -#endif - XUngrabKeyboard(SDL_Display, CurrentTime); + XUngrabKeyboard(SDL_Display, CurrentTime); } else { if ( this->screen->flags & SDL_FULLSCREEN ) { /* Unbind the mouse from the fullscreen window */ @@ -278,16 +279,20 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) result = XGrabPointer(SDL_Display, SDL_Window, True, 0, GrabModeAsync, GrabModeAsync, SDL_Window, None, CurrentTime); - if ( result != AlreadyGrabbed ) { + if ( result == GrabSuccess ) { break; } SDL_Delay(100); } -#ifdef GRAB_FULLSCREEN - if ( !(this->screen->flags & SDL_FULLSCREEN) ) -#endif - XGrabKeyboard(SDL_Display, WMwindow, True, - GrabModeAsync, GrabModeAsync, CurrentTime); + if ( result != GrabSuccess ) { + /* Uh, oh, what do we do here? */ ; + } + /* Grab the keyboard if we're in fullscreen mode */ + if ( !(this->screen->flags & SDL_FULLSCREEN) ) { + XGrabKeyboard(SDL_Display, WMwindow, True, + GrabModeAsync, GrabModeAsync, CurrentTime); + SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); + } /* Raise the window if we grab the mouse */ if ( !(this->screen->flags & SDL_FULLSCREEN) )