hopefully fix the input grabbing (and evem more hopefully, without driving

Despair to ... um... ;)
This commit is contained in:
Bill Currie 2003-03-07 03:55:51 +00:00
parent 7bdf1bdb90
commit c731afa957
7 changed files with 34 additions and 65 deletions

View file

@ -79,8 +79,7 @@ void IN_LL_Init (void);
void IN_LL_Shutdown (void); void IN_LL_Shutdown (void);
void IN_LL_SendKeyEvents (void); void IN_LL_SendKeyEvents (void);
void IN_LL_ClearStates (void); void IN_LL_ClearStates (void);
int IN_LL_Grab_Input (void); void IN_LL_Grab_Input (int grab);
int IN_LL_Ungrab_Input (void);
extern kbutton_t in_strafe, in_klook, in_speed, in_mlook; extern kbutton_t in_strafe, in_klook, in_speed, in_mlook;

View file

@ -78,21 +78,11 @@ 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 = 0;
void void
IN_UpdateGrab (cvar_t *var) // called from context_*.c IN_UpdateGrab (cvar_t *var) // called from context_*.c
{ {
if (var) { if (var) {
if (var->int_val) { IN_LL_Grab_Input (var->int_val);
if (!input_grabbed) {
input_grabbed = IN_LL_Grab_Input ();
}
} else {
if (input_grabbed) {
input_grabbed = IN_LL_Ungrab_Input ();
}
}
} }
} }

View file

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

View file

@ -851,16 +851,15 @@ IN_LL_SendKeyEvents (void)
} }
} }
int void
IN_LL_Grab_Input (void) IN_LL_Grab_Input (int grab)
{ {
return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_ON)); static int input_grabbed = 0;
}
int if ((input_grabbed && grab) || (!input_grabbed && !grab))
IN_LL_Ungrab_Input (void) return;
{ input_grabbed = (SDL_GRAB_ON == SDL_WM_GrabInput (grab ? SDL_GRAB_ON
return (SDL_GRAB_ON == SDL_WM_GrabInput (SDL_GRAB_OFF)); : SDL_GRAB_OFF));
} }
void void

View file

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

View file

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

View file

@ -553,26 +553,28 @@ event_motion (XEvent *event)
} }
} }
int void
IN_LL_Grab_Input (void) IN_LL_Grab_Input (int grab)
{ {
if (!x_disp || !x_win) static int input_grabbed = 0;
return 0;
X11_Grabber (true);
if (in_dga->int_val)
dga_on ();
return 1;
}
int
IN_LL_Ungrab_Input (void)
{
if (!x_disp || !x_win) if (!x_disp || !x_win)
return 0; return;
if (in_dga->int_val)
dga_off (); if (vid_fullscreen)
X11_Grabber (false); grab = grab || vid_fullscreen->int_val;
return 0;
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 void