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/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

View file

@ -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);
}

View file

@ -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 ();
}
}
}

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)
{