Want for the mouse to move when going fullscreen before moving the

viewport. This should fix the uncetnered viewport when going fullscreen.
Also discard mouse events caused by fullscreen toggling to avoid chaning
orientation.
This commit is contained in:
Bill Currie 2004-03-21 05:21:27 +00:00
parent db1f68347b
commit 7feaa3d631
3 changed files with 31 additions and 2 deletions

View file

@ -55,6 +55,7 @@ extern vec3_t x_gamma;
extern int x_screen;
extern int x_shmeventtype;
extern Time x_time;
extern Time x_mouse_time;
extern qboolean doShm;
extern qboolean oktodraw;
extern qboolean x_have_focus;

View file

@ -89,6 +89,7 @@ XVisualInfo *x_visinfo;
Visual *x_vis;
Window x_win;
Time x_time;
Time x_mouse_time;
qboolean x_have_focus = false;
@ -308,6 +309,29 @@ X11_ForceMove (int x, int y)
X11_WaitForEvent (ConfigureNotify);
}
static Bool
check_mouse_event (Display *disp, XEvent *ev, XPointer arg)
{
XMotionEvent *me = &ev->xmotion;
if (ev->type != MotionNotify)
return False;
if (me->x != scr_width / 2 || me->y != scr_height / 2)
return False;
return True;
}
static void
X11_SetMouse (void)
{
XEvent ev;
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, 0, 0);
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, scr_width / 2,
scr_height / 2);
XPeekIfEvent (x_disp, &ev, check_mouse_event, 0);
x_mouse_time = ev.xmotion.time;
}
static vec3_t *
X11_GetGamma (void)
{
@ -444,8 +468,7 @@ X11_UpdateFullscreen (cvar_t *fullscreen)
}
X11_ForceMove (0, 0);
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, scr_width / 2,
scr_height / 2);
X11_SetMouse ();
IN_UpdateGrab (in_grab);
// Done in X11_SetVidMode but moved the window since then
X11_ForceViewPort ();

View file

@ -538,6 +538,11 @@ static void
event_motion (XEvent *event)
{
x_time = event->xmotion.time;
if (x_time <= x_mouse_time) {
p_mouse_x = event->xmotion.x;
p_mouse_y = event->xmotion.y;
return;
}
if (dga_active) {
in_mouse_x += event->xmotion.x_root;