Fixed some problems with the fullscreen code. Wooo. :)
authorSam Lantinga <slouken@lokigames.com>
Mon, 09 Jul 2001 22:36:16 +0000
changeset 988a5aff5c1294
parent 97 c7bcdece4845
child 99 1b387dc653d0
Fixed some problems with the fullscreen code. Wooo. :)
src/video/x11/SDL_x11modes.c
src/video/x11/SDL_x11wm.c
     1.1 --- a/src/video/x11/SDL_x11modes.c	Mon Jul 09 15:47:40 2001 +0000
     1.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Jul 09 22:36:16 2001 +0000
     1.3 @@ -396,7 +396,7 @@
     1.4          set_best_resolution(this, current_w, current_h);
     1.5          move_cursor_to(this, 0, 0);
     1.6          get_real_resolution(this, &real_w, &real_h);
     1.7 -        XResizeWindow(SDL_Display, FSwindow, real_w, real_h);
     1.8 +        XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
     1.9          move_cursor_to(this, real_w/2, real_h/2);
    1.10  
    1.11          /* Center and reparent the drawing window */
    1.12 @@ -425,58 +425,62 @@
    1.13      Window tmpwin, *windows;
    1.14      int i, nwindows;
    1.15  #endif
    1.16 +    int real_w, real_h;
    1.17  
    1.18      okay = 1;
    1.19 -    if ( ! currently_fullscreen ) {
    1.20 -        int real_w, real_h;
    1.21 +    if ( currently_fullscreen ) {
    1.22 +        return(okay);
    1.23 +    }
    1.24  
    1.25 -        /* Map the fullscreen window to blank the screen */
    1.26 -        get_real_resolution(this, &real_w, &real_h);
    1.27 -        XResizeWindow(SDL_Display, FSwindow, real_w, real_h);
    1.28 -        XMapRaised(SDL_Display, FSwindow);
    1.29 -        X11_WaitMapped(this, FSwindow);
    1.30 +    /* Ungrab the input so that we can move the mouse around */
    1.31 +    X11_GrabInputNoLock(this, SDL_GRAB_OFF);
    1.32 +
    1.33 +    /* Map the fullscreen window to blank the screen */
    1.34 +    get_real_resolution(this, &real_w, &real_h);
    1.35 +    XMoveResizeWindow(SDL_Display, FSwindow, 0, 0, real_w, real_h);
    1.36 +    XMapRaised(SDL_Display, FSwindow);
    1.37 +    X11_WaitMapped(this, FSwindow);
    1.38  
    1.39  #if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
    1.40 -        /* Make sure we got to the top of the window stack */
    1.41 -        if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
    1.42 -                                &windows, &nwindows) && windows ) {
    1.43 -            /* If not, try to put us there - if fail... oh well */
    1.44 -            if ( windows[nwindows-1] != FSwindow ) {
    1.45 -                tmpwin = windows[nwindows-1];
    1.46 -                for ( i=0; i<nwindows; ++i ) {
    1.47 -                    if ( windows[i] == FSwindow ) {
    1.48 -                        memcpy(&windows[i], &windows[i+1],
    1.49 -                               (nwindows-i-1)*sizeof(windows[i]));
    1.50 -                        break;
    1.51 -                    }
    1.52 +    /* Make sure we got to the top of the window stack */
    1.53 +    if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
    1.54 +                            &windows, &nwindows) && windows ) {
    1.55 +        /* If not, try to put us there - if fail... oh well */
    1.56 +        if ( windows[nwindows-1] != FSwindow ) {
    1.57 +            tmpwin = windows[nwindows-1];
    1.58 +            for ( i=0; i<nwindows; ++i ) {
    1.59 +                if ( windows[i] == FSwindow ) {
    1.60 +                    memcpy(&windows[i], &windows[i+1],
    1.61 +                           (nwindows-i-1)*sizeof(windows[i]));
    1.62 +                    break;
    1.63                  }
    1.64 -                windows[nwindows-1] = FSwindow;
    1.65 -                XRestackWindows(SDL_Display, windows, nwindows);
    1.66 -                XSync(SDL_Display, False);
    1.67              }
    1.68 -            XFree(windows);
    1.69 +            windows[nwindows-1] = FSwindow;
    1.70 +            XRestackWindows(SDL_Display, windows, nwindows);
    1.71 +            XSync(SDL_Display, False);
    1.72          }
    1.73 +        XFree(windows);
    1.74 +    }
    1.75  #else
    1.76 -	XRaiseWindow(SDL_Display, FSwindow);
    1.77 +    XRaiseWindow(SDL_Display, FSwindow);
    1.78  #endif
    1.79  
    1.80  #ifdef XFREE86_VM
    1.81 -        /* Save the current video mode */
    1.82 -        if ( use_vidmode ) {
    1.83 -            XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True));
    1.84 -        }
    1.85 +    /* Save the current video mode */
    1.86 +    if ( use_vidmode ) {
    1.87 +        XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True));
    1.88 +    }
    1.89  #endif
    1.90 -        currently_fullscreen = 1;
    1.91 +    currently_fullscreen = 1;
    1.92  
    1.93 -        /* Set the new resolution */
    1.94 -        okay = X11_ResizeFullScreen(this);
    1.95 -        if ( ! okay ) {
    1.96 -            X11_LeaveFullScreen(this);
    1.97 -        }
    1.98 -	/* Set the colormap */
    1.99 -	if ( SDL_XColorMap ) {
   1.100 -		XInstallColormap(SDL_Display, SDL_XColorMap);
   1.101 -	}
   1.102 +    /* Set the new resolution */
   1.103 +    okay = X11_ResizeFullScreen(this);
   1.104 +    if ( ! okay ) {
   1.105 +        X11_LeaveFullScreen(this);
   1.106 +    }
   1.107 +    /* Set the colormap */
   1.108 +    if ( SDL_XColorMap ) {
   1.109 +        XInstallColormap(SDL_Display, SDL_XColorMap);
   1.110      }
   1.111      if ( okay )
   1.112          X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
     2.1 --- a/src/video/x11/SDL_x11wm.c	Mon Jul 09 15:47:40 2001 +0000
     2.2 +++ b/src/video/x11/SDL_x11wm.c	Mon Jul 09 22:36:16 2001 +0000
     2.3 @@ -250,32 +250,21 @@
     2.4  		return(mode);	/* Will be set later on mode switch */
     2.5  	}
     2.6  	if ( mode == SDL_GRAB_OFF ) {
     2.7 +printf("SDL grab OFF\n");
     2.8  		XUngrabPointer(SDL_Display, CurrentTime);
     2.9 -		if ( this->screen->flags & SDL_FULLSCREEN ) {
    2.10 -			/* Rebind the mouse to the fullscreen window */
    2.11 -			for ( numtries = 0; numtries < 10; ++numtries ) {
    2.12 -				result = XGrabPointer(SDL_Display, FSwindow,
    2.13 -						True, 0,
    2.14 -						GrabModeAsync, GrabModeAsync,
    2.15 -						FSwindow, None, CurrentTime);
    2.16 -				if ( result == GrabSuccess ) {
    2.17 -					break;
    2.18 -				}
    2.19 -				SDL_Delay(100);
    2.20 -			}
    2.21 -			if ( result != GrabSuccess ) {
    2.22 -				/* Uh, oh, what do we do here? */ ;
    2.23 -			}
    2.24 -		}
    2.25 -		if ( !(this->screen->flags & SDL_FULLSCREEN) )
    2.26 -			XUngrabKeyboard(SDL_Display, CurrentTime);
    2.27 +		XUngrabKeyboard(SDL_Display, CurrentTime);
    2.28  	} else {
    2.29 +printf("SDL grab ON\n");
    2.30  		if ( this->screen->flags & SDL_FULLSCREEN ) {
    2.31  			/* Unbind the mouse from the fullscreen window */
    2.32  			XUngrabPointer(SDL_Display, CurrentTime);
    2.33  		}
    2.34  		/* Try to grab the mouse */
    2.35 +#if 0 /* We'll wait here until we actually grab, otherwise behavior undefined */
    2.36  		for ( numtries = 0; numtries < 10; ++numtries ) {
    2.37 +#else
    2.38 +		while ( 1 ) {
    2.39 +#endif
    2.40  			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
    2.41  						GrabModeAsync, GrabModeAsync,
    2.42  						SDL_Window, None, CurrentTime);
    2.43 @@ -287,16 +276,16 @@
    2.44  		if ( result != GrabSuccess ) {
    2.45  			/* Uh, oh, what do we do here? */ ;
    2.46  		}
    2.47 -		/* Grab the keyboard if we're in fullscreen mode */
    2.48 -		if ( !(this->screen->flags & SDL_FULLSCREEN) ) {
    2.49 -			XGrabKeyboard(SDL_Display, WMwindow, True,
    2.50 +		/* Now grab the keyboard */
    2.51 +		XGrabKeyboard(SDL_Display, WMwindow, True,
    2.52  				GrabModeAsync, GrabModeAsync, CurrentTime);
    2.53 -			SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
    2.54 -		}
    2.55  
    2.56  		/* Raise the window if we grab the mouse */
    2.57  		if ( !(this->screen->flags & SDL_FULLSCREEN) )
    2.58  			XRaiseWindow(SDL_Display, WMwindow);
    2.59 +
    2.60 +		/* Make sure we register input focus */
    2.61 +		SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
    2.62  	}
    2.63  	XSync(SDL_Display, False);
    2.64