diff --git a/libs/video/targets/context_sdl.c b/libs/video/targets/context_sdl.c index fb4f26e4f..03b922a66 100644 --- a/libs/video/targets/context_sdl.c +++ b/libs/video/targets/context_sdl.c @@ -17,6 +17,7 @@ static __attribute__ ((unused)) const char rcsid[] = #include "QF/console.h" #include "QF/cvar.h" +#include "QF/input.h" #include "QF/va.h" #include "QF/vid.h" @@ -72,6 +73,8 @@ VID_UpdateFullscreen (cvar_t *vid_fullscreen) || (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN)) if (!SDL_WM_ToggleFullScreen (screen)) Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n"); + if (in_grab) + IN_UpdateGrab (in_grab); } void diff --git a/libs/video/targets/context_x11.c b/libs/video/targets/context_x11.c index 398bbf48f..638dec281 100644 --- a/libs/video/targets/context_x11.c +++ b/libs/video/targets/context_x11.c @@ -415,11 +415,10 @@ X11_UpdateFullscreen (cvar_t *fullscreen) } X11_ForceMove (0, 0); - XWarpPointer (x_disp, None, x_win, - 0, 0, 0, 0, - vid.width / 2, vid.height / 2); - X11_ForceViewPort (); + XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, vid.width / 2, + vid.height / 2); // Done in X11_SetVidMode but moved the window since then + X11_ForceViewPort (); } } @@ -515,7 +514,7 @@ X11_RestoreVidMode (void) } static void -X11_GrabKeyboardBool(qboolean yes) +X11_GrabKeyboard (qboolean yes) { static qboolean is_grabbed = false; @@ -534,16 +533,8 @@ X11_GrabKeyboardBool(qboolean yes) } } -#if 0 static void -X11_UngrabKeyboard (void) -{ - XUngrabKeyboard (x_disp, CurrentTime); -} -#endif - -static void -X11_GrabMouseBool (qboolean yes) +X11_GrabMouse (qboolean yes) { static qboolean is_grabbed = false; @@ -564,16 +555,6 @@ X11_GrabMouseBool (qboolean yes) vid.height / 2); } -#if 0 -static void -X11_UngrabMouse(void) -{ - XUngrabPointer (x_disp, CurrentTime); - XWarpPointer (x_disp, x_win, x_win, 0, 0, 0, 0, vid.width / 2, - vid.height / 2); -} -#endif - void X11_Grabber (qboolean grab) { @@ -581,8 +562,8 @@ X11_Grabber (qboolean grab) Con_Printf ("No video context to grab to!\n"); return; } - X11_GrabMouseBool (grab); - X11_GrabKeyboardBool (grab); + X11_GrabMouse (grab); + X11_GrabKeyboard (grab); XSync (x_disp, false); } diff --git a/libs/video/targets/in_common.c b/libs/video/targets/in_common.c index 78d88df94..ef53f9aa3 100644 --- a/libs/video/targets/in_common.c +++ b/libs/video/targets/in_common.c @@ -78,20 +78,18 @@ qboolean in_mouse_avail; float in_mouse_x, in_mouse_y; static float in_old_mouse_x, in_old_mouse_y; -static int input_grabbed; +static int input_grabbed = 0; -void // called from context_x11.c -IN_UpdateGrab (cvar_t *var) +void +IN_UpdateGrab (cvar_t *var) // called from context_*.c { - if (var->int_val || (vid_fullscreen && vid_fullscreen->int_val)) { + if (var->int_val) { if (!input_grabbed) { - IN_LL_Grab_Input (); - input_grabbed = 1; + input_grabbed = IN_LL_Grab_Input (); } } else { if (input_grabbed) { - IN_LL_Ungrab_Input (); - input_grabbed = 0; + input_grabbed = IN_LL_Ungrab_Input (); } } } diff --git a/libs/video/targets/in_fbdev.c b/libs/video/targets/in_fbdev.c index 8f8b618db..c3aae1eef 100644 --- a/libs/video/targets/in_fbdev.c +++ b/libs/video/targets/in_fbdev.c @@ -133,14 +133,16 @@ IN_LL_SendKeyEvents (void) } } -void +int IN_LL_Grab_Input (void) { + return 0; } -void +int IN_LL_Ungrab_Input (void) { + return 0; } void diff --git a/libs/video/targets/in_sdl.c b/libs/video/targets/in_sdl.c index 9a198198d..1b28191fc 100644 --- a/libs/video/targets/in_sdl.c +++ b/libs/video/targets/in_sdl.c @@ -851,16 +851,16 @@ IN_LL_SendKeyEvents (void) } } -void +int IN_LL_Grab_Input (void) { - SDL_WM_GrabInput (SDL_GRAB_ON); + return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_ON)); } -void +int IN_LL_Ungrab_Input (void) { - SDL_WM_GrabInput (SDL_GRAB_OFF); + return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_OFF)); } void diff --git a/libs/video/targets/in_svgalib.c b/libs/video/targets/in_svgalib.c index b3451a49f..afd76087d 100644 --- a/libs/video/targets/in_svgalib.c +++ b/libs/video/targets/in_svgalib.c @@ -457,14 +457,16 @@ IN_LL_SendKeyEvents (void) } } -void +int IN_LL_Grab_Input (void) { + return 0; } -void +int IN_LL_Ungrab_Input (void) { + return 0; } void diff --git a/libs/video/targets/in_win.c b/libs/video/targets/in_win.c index b44324c4c..955cc5708 100644 --- a/libs/video/targets/in_win.c +++ b/libs/video/targets/in_win.c @@ -407,14 +407,16 @@ IN_MouseEvent (int mstate) } } -void +int IN_LL_Grab_Input (void) { + return 0; } -void +int IN_LL_Ungrab_Input (void) { + return 0; } void diff --git a/libs/video/targets/in_x11.c b/libs/video/targets/in_x11.c index 856540f14..355160665 100644 --- a/libs/video/targets/in_x11.c +++ b/libs/video/targets/in_x11.c @@ -544,24 +544,26 @@ event_motion (XEvent *event) } } -void +int IN_LL_Grab_Input (void) { if (!x_disp || !x_win) - return; + return 0; X11_Grabber (true); if (in_dga->int_val) dga_on (); + return 1; } -void +int IN_LL_Ungrab_Input (void) { if (!x_disp || !x_win) - return; + return 0; if (in_dga->int_val) dga_off (); X11_Grabber (false); + return 0; } void @@ -635,7 +637,6 @@ IN_LL_Init_Cvars (void) "DGA Input support"); } - void IN_LL_ClearStates (void) {