From c731afa957cb8408d20561d6cfcaec7e69934dc4 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 7 Mar 2003 03:55:51 +0000 Subject: [PATCH] hopefully fix the input grabbing (and evem more hopefully, without driving Despair to ... um... ;) --- include/QF/input.h | 3 +-- libs/video/targets/in_common.c | 12 +---------- libs/video/targets/in_fbdev.c | 11 ++-------- libs/video/targets/in_sdl.c | 15 +++++++------- libs/video/targets/in_svgalib.c | 11 ++-------- libs/video/targets/in_win.c | 11 ++-------- libs/video/targets/in_x11.c | 36 +++++++++++++++++---------------- 7 files changed, 34 insertions(+), 65 deletions(-) diff --git a/include/QF/input.h b/include/QF/input.h index 3d97b3ac8..6a2cc0759 100644 --- a/include/QF/input.h +++ b/include/QF/input.h @@ -79,8 +79,7 @@ void IN_LL_Init (void); void IN_LL_Shutdown (void); void IN_LL_SendKeyEvents (void); void IN_LL_ClearStates (void); -int IN_LL_Grab_Input (void); -int IN_LL_Ungrab_Input (void); +void IN_LL_Grab_Input (int grab); extern kbutton_t in_strafe, in_klook, in_speed, in_mlook; diff --git a/libs/video/targets/in_common.c b/libs/video/targets/in_common.c index 049eb958b..1f1bebcef 100644 --- a/libs/video/targets/in_common.c +++ b/libs/video/targets/in_common.c @@ -78,21 +78,11 @@ 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 = 0; - void IN_UpdateGrab (cvar_t *var) // called from context_*.c { if (var) { - if (var->int_val) { - if (!input_grabbed) { - input_grabbed = IN_LL_Grab_Input (); - } - } else { - if (input_grabbed) { - input_grabbed = IN_LL_Ungrab_Input (); - } - } + IN_LL_Grab_Input (var->int_val); } } diff --git a/libs/video/targets/in_fbdev.c b/libs/video/targets/in_fbdev.c index c3aae1eef..7e745e722 100644 --- a/libs/video/targets/in_fbdev.c +++ b/libs/video/targets/in_fbdev.c @@ -133,16 +133,9 @@ IN_LL_SendKeyEvents (void) } } -int -IN_LL_Grab_Input (void) +void +IN_LL_Grab_Input (int grab) { - return 0; -} - -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 1b28191fc..e297f8936 100644 --- a/libs/video/targets/in_sdl.c +++ b/libs/video/targets/in_sdl.c @@ -851,16 +851,15 @@ IN_LL_SendKeyEvents (void) } } -int -IN_LL_Grab_Input (void) +void +IN_LL_Grab_Input (int grab) { - return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_ON)); -} + static int input_grabbed = 0; -int -IN_LL_Ungrab_Input (void) -{ - return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_OFF)); + if ((input_grabbed && grab) || (!input_grabbed && !grab)) + return; + input_grabbed = (SDL_GRAB_ON == SDL_WM_GrabInput (grab ? SDL_GRAB_ON + : SDL_GRAB_OFF)); } void diff --git a/libs/video/targets/in_svgalib.c b/libs/video/targets/in_svgalib.c index afd76087d..d378f57d2 100644 --- a/libs/video/targets/in_svgalib.c +++ b/libs/video/targets/in_svgalib.c @@ -457,16 +457,9 @@ IN_LL_SendKeyEvents (void) } } -int -IN_LL_Grab_Input (void) +void +IN_LL_Grab_Input (int grab) { - return 0; -} - -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 955cc5708..04d9da689 100644 --- a/libs/video/targets/in_win.c +++ b/libs/video/targets/in_win.c @@ -407,16 +407,9 @@ IN_MouseEvent (int mstate) } } -int -IN_LL_Grab_Input (void) +void +IN_LL_Grab_Input (int grab) { - return 0; -} - -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 e69d19cc7..b27641805 100644 --- a/libs/video/targets/in_x11.c +++ b/libs/video/targets/in_x11.c @@ -553,26 +553,28 @@ event_motion (XEvent *event) } } -int -IN_LL_Grab_Input (void) +void +IN_LL_Grab_Input (int grab) { - if (!x_disp || !x_win) - return 0; - X11_Grabber (true); - if (in_dga->int_val) - dga_on (); - return 1; -} + static int input_grabbed = 0; -int -IN_LL_Ungrab_Input (void) -{ if (!x_disp || !x_win) - return 0; - if (in_dga->int_val) - dga_off (); - X11_Grabber (false); - return 0; + return; + + if (vid_fullscreen) + grab = grab || vid_fullscreen->int_val; + + if ((input_grabbed && grab) || (!input_grabbed && !grab)) + return; + + input_grabbed = grab; + X11_Grabber (grab); + if (in_dga->int_val) { + if (grab) + dga_on (); + else + dga_off (); + } } void