Commit d8a033f8 authored by Sam Lantinga's avatar Sam Lantinga

Fixed some problems with the fullscreen code. Wooo. :)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%4099
parent 0d895fa8
...@@ -396,7 +396,7 @@ int X11_ResizeFullScreen(_THIS) ...@@ -396,7 +396,7 @@ int X11_ResizeFullScreen(_THIS)
set_best_resolution(this, current_w, current_h); set_best_resolution(this, current_w, current_h);
move_cursor_to(this, 0, 0); move_cursor_to(this, 0, 0);
get_real_resolution(this, &real_w, &real_h); get_real_resolution(this, &real_w, &real_h);
XResizeWindow(SDL_Display, FSwindow, real_w, real_h); XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
move_cursor_to(this, real_w/2, real_h/2); move_cursor_to(this, real_w/2, real_h/2);
/* Center and reparent the drawing window */ /* Center and reparent the drawing window */
...@@ -425,58 +425,62 @@ int X11_EnterFullScreen(_THIS) ...@@ -425,58 +425,62 @@ int X11_EnterFullScreen(_THIS)
Window tmpwin, *windows; Window tmpwin, *windows;
int i, nwindows; int i, nwindows;
#endif #endif
int real_w, real_h;
okay = 1; okay = 1;
if ( ! currently_fullscreen ) { if ( currently_fullscreen ) {
int real_w, real_h; return(okay);
}
/* Map the fullscreen window to blank the screen */ /* Ungrab the input so that we can move the mouse around */
get_real_resolution(this, &real_w, &real_h); X11_GrabInputNoLock(this, SDL_GRAB_OFF);
XResizeWindow(SDL_Display, FSwindow, real_w, real_h);
XMapRaised(SDL_Display, FSwindow); /* Map the fullscreen window to blank the screen */
X11_WaitMapped(this, FSwindow); get_real_resolution(this, &real_w, &real_h);
XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
XMapRaised(SDL_Display, FSwindow);
X11_WaitMapped(this, FSwindow);
#if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */ #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
/* Make sure we got to the top of the window stack */ /* Make sure we got to the top of the window stack */
if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin, if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
&windows, &nwindows) && windows ) { &windows, &nwindows) && windows ) {
/* If not, try to put us there - if fail... oh well */ /* If not, try to put us there - if fail... oh well */
if ( windows[nwindows-1] != FSwindow ) { if ( windows[nwindows-1] != FSwindow ) {
tmpwin = windows[nwindows-1]; tmpwin = windows[nwindows-1];
for ( i=0; i<nwindows; ++i ) { for ( i=0; i<nwindows; ++i ) {
if ( windows[i] == FSwindow ) { if ( windows[i] == FSwindow ) {
memcpy(&windows[i], &windows[i+1], memcpy(&windows[i], &windows[i+1],
(nwindows-i-1)*sizeof(windows[i])); (nwindows-i-1)*sizeof(windows[i]));
break; break;
}
} }
windows[nwindows-1] = FSwindow;
XRestackWindows(SDL_Display, windows, nwindows);
XSync(SDL_Display, False);
} }
XFree(windows); windows[nwindows-1] = FSwindow;
XRestackWindows(SDL_Display, windows, nwindows);
XSync(SDL_Display, False);
} }
XFree(windows);
}
#else #else
XRaiseWindow(SDL_Display, FSwindow); XRaiseWindow(SDL_Display, FSwindow);
#endif #endif
#ifdef XFREE86_VM #ifdef XFREE86_VM
/* Save the current video mode */ /* Save the current video mode */
if ( use_vidmode ) { if ( use_vidmode ) {
XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True)); XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True));
} }
#endif #endif
currently_fullscreen = 1; currently_fullscreen = 1;
/* Set the new resolution */ /* Set the new resolution */
okay = X11_ResizeFullScreen(this); okay = X11_ResizeFullScreen(this);
if ( ! okay ) { if ( ! okay ) {
X11_LeaveFullScreen(this); X11_LeaveFullScreen(this);
} }
/* Set the colormap */ /* Set the colormap */
if ( SDL_XColorMap ) { if ( SDL_XColorMap ) {
XInstallColormap(SDL_Display, SDL_XColorMap); XInstallColormap(SDL_Display, SDL_XColorMap);
}
} }
if ( okay ) if ( okay )
X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN); X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
......
...@@ -250,32 +250,21 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -250,32 +250,21 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
return(mode); /* Will be set later on mode switch */ return(mode); /* Will be set later on mode switch */
} }
if ( mode == SDL_GRAB_OFF ) { if ( mode == SDL_GRAB_OFF ) {
printf("SDL grab OFF\n");
XUngrabPointer(SDL_Display, CurrentTime); XUngrabPointer(SDL_Display, CurrentTime);
if ( this->screen->flags & SDL_FULLSCREEN ) { XUngrabKeyboard(SDL_Display, CurrentTime);
/* Rebind the mouse to the fullscreen window */
for ( numtries = 0; numtries < 10; ++numtries ) {
result = XGrabPointer(SDL_Display, FSwindow,
True, 0,
GrabModeAsync, GrabModeAsync,
FSwindow, None, CurrentTime);
if ( result == GrabSuccess ) {
break;
}
SDL_Delay(100);
}
if ( result != GrabSuccess ) {
/* Uh, oh, what do we do here? */ ;
}
}
if ( !(this->screen->flags & SDL_FULLSCREEN) )
XUngrabKeyboard(SDL_Display, CurrentTime);
} else { } else {
printf("SDL grab ON\n");
if ( this->screen->flags & SDL_FULLSCREEN ) { if ( this->screen->flags & SDL_FULLSCREEN ) {
/* Unbind the mouse from the fullscreen window */ /* Unbind the mouse from the fullscreen window */
XUngrabPointer(SDL_Display, CurrentTime); XUngrabPointer(SDL_Display, CurrentTime);
} }
/* Try to grab the mouse */ /* Try to grab the mouse */
#if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
for ( numtries = 0; numtries < 10; ++numtries ) { for ( numtries = 0; numtries < 10; ++numtries ) {
#else
while ( 1 ) {
#endif
result = XGrabPointer(SDL_Display, SDL_Window, True, 0, result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
GrabModeAsync, GrabModeAsync, GrabModeAsync, GrabModeAsync,
SDL_Window, None, CurrentTime); SDL_Window, None, CurrentTime);
...@@ -287,16 +276,16 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode) ...@@ -287,16 +276,16 @@ SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
if ( result != GrabSuccess ) { if ( result != GrabSuccess ) {
/* Uh, oh, what do we do here? */ ; /* Uh, oh, what do we do here? */ ;
} }
/* Grab the keyboard if we're in fullscreen mode */ /* Now grab the keyboard */
if ( !(this->screen->flags & SDL_FULLSCREEN) ) { XGrabKeyboard(SDL_Display, WMwindow, True,
XGrabKeyboard(SDL_Display, WMwindow, True,
GrabModeAsync, GrabModeAsync, CurrentTime); GrabModeAsync, GrabModeAsync, CurrentTime);
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
}
/* Raise the window if we grab the mouse */ /* Raise the window if we grab the mouse */
if ( !(this->screen->flags & SDL_FULLSCREEN) ) if ( !(this->screen->flags & SDL_FULLSCREEN) )
XRaiseWindow(SDL_Display, WMwindow); XRaiseWindow(SDL_Display, WMwindow);
/* Make sure we register input focus */
SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
} }
XSync(SDL_Display, False); XSync(SDL_Display, False);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment