Initialize p_mouse_x and p_mouse_y from the EnterNotify event so that the

first mouse move of the game doesn't screw up your view. Also does resonable
behaviour when entering and leaving the window.
This commit is contained in:
Bill Currie 2003-02-25 17:19:47 +00:00
parent 5fc069753a
commit be728c7b7c
2 changed files with 12 additions and 2 deletions

View file

@ -93,7 +93,7 @@ Time x_time;
qboolean x_have_focus = false;
#define X_MASK (VisibilityChangeMask | StructureNotifyMask | ExposureMask | FocusChangeMask)
#define X_MASK (VisibilityChangeMask | StructureNotifyMask | ExposureMask | FocusChangeMask | EnterWindowMask)
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
#ifdef HAVE_VIDMODE

View file

@ -86,7 +86,7 @@ static int p_mouse_x, p_mouse_y;
#define KEY_MASK (KeyPressMask | KeyReleaseMask)
#define MOUSE_MASK (ButtonPressMask | ButtonReleaseMask | PointerMotionMask)
#define FOCUS_MASK (FocusChangeMask)
#define FOCUS_MASK (FocusChangeMask | EnterWindowMask)
#define INPUT_MASK (KEY_MASK | MOUSE_MASK | FOCUS_MASK)
@ -170,6 +170,15 @@ selection_notify (XEvent *event)
XFree (data);
}
static void
enter_notify (XEvent *event)
{
x_time = event->xcrossing.time;
p_mouse_x = event->xmotion.x;
p_mouse_y = event->xmotion.y;
}
static void
XLateKey (XKeyEvent * ev, int *k, int *u)
{
@ -613,6 +622,7 @@ IN_LL_Init (void)
X11_AddEvent (FocusIn, &event_focusin);
X11_AddEvent (FocusOut, &event_focusout);
X11_AddEvent (SelectionNotify, &selection_notify);
X11_AddEvent (EnterNotify, &enter_notify);
if (!COM_CheckParm ("-nomouse")) {
dga_avail = VID_CheckDGA (x_disp, NULL, NULL, NULL);