Make SetMouse timeout after 2 seconds

This makes sure that some unchecked event doesn't cause a lockup.
However, blocking input is really not the way to go: need to implement a
state machine and use non-blocking event reads.
This commit is contained in:
Bill Currie 2019-07-10 22:24:11 +09:00
parent 203d981675
commit 4eb6cf6f9e

View file

@ -354,7 +354,14 @@ X11_SetMouse (void)
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, 0, 0); XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, 0, 0);
XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0, XWarpPointer (x_disp, None, x_win, 0, 0, 0, 0,
viddef.width / 2, viddef.height / 2); viddef.width / 2, viddef.height / 2);
XPeekIfEvent (x_disp, &ev, check_mouse_event, 0); //FIXME this should be done in a state machine that handles events without
//blocking
double start = Sys_DoubleTime ();
while (!XCheckIfEvent (x_disp, &ev, check_mouse_event, 0)) {
if (Sys_DoubleTime () - start > 2) {
break;
}
}
x_mouse_time = ev.xmotion.time; x_mouse_time = ev.xmotion.time;
} }