Add return value checking for in_grab. Also some dead code removal, dangling comment and white space cleanup.

This commit is contained in:
Ragnvald Maartmann-Moe IV 2003-02-13 19:03:48 +00:00
parent 53d3252792
commit 646f875a34
8 changed files with 38 additions and 49 deletions

View File

@ -17,6 +17,7 @@ static __attribute__ ((unused)) const char rcsid[] =
#include "QF/console.h" #include "QF/console.h"
#include "QF/cvar.h" #include "QF/cvar.h"
#include "QF/input.h"
#include "QF/va.h" #include "QF/va.h"
#include "QF/vid.h" #include "QF/vid.h"
@ -72,6 +73,8 @@ VID_UpdateFullscreen (cvar_t *vid_fullscreen)
|| (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN)) || (!vid_fullscreen->int_val && screen->flags & SDL_FULLSCREEN))
if (!SDL_WM_ToggleFullScreen (screen)) if (!SDL_WM_ToggleFullScreen (screen))
Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n"); Con_Printf ("VID_UpdateFullscreen: error setting fullscreen\n");
if (in_grab)
IN_UpdateGrab (in_grab);
} }
void void

View File

@ -415,11 +415,10 @@ X11_UpdateFullscreen (cvar_t *fullscreen)
} }
X11_ForceMove (0, 0); X11_ForceMove (0, 0);
XWarpPointer (x_disp, None, x_win, XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, vid.width / 2,
0, 0, 0, 0, vid.height / 2);
vid.width / 2, vid.height / 2);
X11_ForceViewPort ();
// Done in X11_SetVidMode but moved the window since then // Done in X11_SetVidMode but moved the window since then
X11_ForceViewPort ();
} }
} }
@ -515,7 +514,7 @@ X11_RestoreVidMode (void)
} }
static void static void
X11_GrabKeyboardBool(qboolean yes) X11_GrabKeyboard (qboolean yes)
{ {
static qboolean is_grabbed = false; static qboolean is_grabbed = false;
@ -534,16 +533,8 @@ X11_GrabKeyboardBool(qboolean yes)
} }
} }
#if 0
static void static void
X11_UngrabKeyboard (void) X11_GrabMouse (qboolean yes)
{
XUngrabKeyboard (x_disp, CurrentTime);
}
#endif
static void
X11_GrabMouseBool (qboolean yes)
{ {
static qboolean is_grabbed = false; static qboolean is_grabbed = false;
@ -564,16 +555,6 @@ X11_GrabMouseBool (qboolean yes)
vid.height / 2); 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 void
X11_Grabber (qboolean grab) X11_Grabber (qboolean grab)
{ {
@ -581,8 +562,8 @@ X11_Grabber (qboolean grab)
Con_Printf ("No video context to grab to!\n"); Con_Printf ("No video context to grab to!\n");
return; return;
} }
X11_GrabMouseBool (grab); X11_GrabMouse (grab);
X11_GrabKeyboardBool (grab); X11_GrabKeyboard (grab);
XSync (x_disp, false); XSync (x_disp, false);
} }

View File

@ -78,20 +78,18 @@ qboolean in_mouse_avail;
float in_mouse_x, in_mouse_y; float in_mouse_x, in_mouse_y;
static float in_old_mouse_x, in_old_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 void
IN_UpdateGrab (cvar_t *var) 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) { if (!input_grabbed) {
IN_LL_Grab_Input (); input_grabbed = IN_LL_Grab_Input ();
input_grabbed = 1;
} }
} else { } else {
if (input_grabbed) { if (input_grabbed) {
IN_LL_Ungrab_Input (); input_grabbed = IN_LL_Ungrab_Input ();
input_grabbed = 0;
} }
} }
} }

View File

@ -133,14 +133,16 @@ IN_LL_SendKeyEvents (void)
} }
} }
void int
IN_LL_Grab_Input (void) IN_LL_Grab_Input (void)
{ {
return 0;
} }
void int
IN_LL_Ungrab_Input (void) IN_LL_Ungrab_Input (void)
{ {
return 0;
} }
void void

View File

@ -851,16 +851,16 @@ IN_LL_SendKeyEvents (void)
} }
} }
void int
IN_LL_Grab_Input (void) 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) IN_LL_Ungrab_Input (void)
{ {
SDL_WM_GrabInput (SDL_GRAB_OFF); return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_OFF));
} }
void void

View File

@ -457,14 +457,16 @@ IN_LL_SendKeyEvents (void)
} }
} }
void int
IN_LL_Grab_Input (void) IN_LL_Grab_Input (void)
{ {
return 0;
} }
void int
IN_LL_Ungrab_Input (void) IN_LL_Ungrab_Input (void)
{ {
return 0;
} }
void void

View File

@ -407,14 +407,16 @@ IN_MouseEvent (int mstate)
} }
} }
void int
IN_LL_Grab_Input (void) IN_LL_Grab_Input (void)
{ {
return 0;
} }
void int
IN_LL_Ungrab_Input (void) IN_LL_Ungrab_Input (void)
{ {
return 0;
} }
void void

View File

@ -544,24 +544,26 @@ event_motion (XEvent *event)
} }
} }
void int
IN_LL_Grab_Input (void) IN_LL_Grab_Input (void)
{ {
if (!x_disp || !x_win) if (!x_disp || !x_win)
return; return 0;
X11_Grabber (true); X11_Grabber (true);
if (in_dga->int_val) if (in_dga->int_val)
dga_on (); dga_on ();
return 1;
} }
void int
IN_LL_Ungrab_Input (void) IN_LL_Ungrab_Input (void)
{ {
if (!x_disp || !x_win) if (!x_disp || !x_win)
return; return 0;
if (in_dga->int_val) if (in_dga->int_val)
dga_off (); dga_off ();
X11_Grabber (false); X11_Grabber (false);
return 0;
} }
void void
@ -635,7 +637,6 @@ IN_LL_Init_Cvars (void)
"DGA Input support"); "DGA Input support");
} }
void void
IN_LL_ClearStates (void) IN_LL_ClearStates (void)
{ {