From 1201f615eebe70ed719bcd9a8bdcf8508438298e Mon Sep 17 00:00:00 2001 From: Ragnvald Maartmann-Moe IV Date: Tue, 25 Feb 2003 06:04:42 +0000 Subject: [PATCH] Move a test inside function, rather than repeated all over the place. --- libs/video/targets/context_sdl.c | 3 +-- libs/video/targets/context_x11.c | 12 +++--------- libs/video/targets/in_common.c | 16 +++++++++------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/libs/video/targets/context_sdl.c b/libs/video/targets/context_sdl.c index 03b922a66..07b26165b 100644 --- a/libs/video/targets/context_sdl.c +++ b/libs/video/targets/context_sdl.c @@ -73,8 +73,7 @@ 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); + IN_UpdateGrab (in_grab); } void diff --git a/libs/video/targets/context_x11.c b/libs/video/targets/context_x11.c index 638dec281..3ab1e29dd 100644 --- a/libs/video/targets/context_x11.c +++ b/libs/video/targets/context_x11.c @@ -391,23 +391,17 @@ X11_UpdateFullscreen (cvar_t *fullscreen) X11_ForceMove (window_x, window_y); window_saved = 0; } - if (in_grab) { - IN_UpdateGrab (in_grab); - } + IN_UpdateGrab (in_grab); return; } else { - if (in_grab) { - IN_UpdateGrab (in_grab); - } + IN_UpdateGrab (in_grab); if (X11_GetWindowCoords (&window_x, &window_y)) window_saved = 1; X11_SetVidMode (scr_width, scr_height); - if (in_grab) { // FIXME: why are there two of these? - IN_UpdateGrab (in_grab); - } + IN_UpdateGrab (in_grab); // FIXME: why are there two of these? if (!vidmode_active) { window_saved = 0; diff --git a/libs/video/targets/in_common.c b/libs/video/targets/in_common.c index ef53f9aa3..049eb958b 100644 --- a/libs/video/targets/in_common.c +++ b/libs/video/targets/in_common.c @@ -83,13 +83,15 @@ static int input_grabbed = 0; void IN_UpdateGrab (cvar_t *var) // called from context_*.c { - if (var->int_val) { - if (!input_grabbed) { - input_grabbed = IN_LL_Grab_Input (); - } - } else { - if (input_grabbed) { - input_grabbed = IN_LL_Ungrab_Input (); + 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 (); + } } } }