Process X events before timers

This commit is contained in:
Josh Holtrop 2017-10-12 19:59:46 -04:00
parent 07cdc5f8d0
commit 6eeb0d5b9a

View File

@ -298,7 +298,16 @@ void Jtk_WaitEvent(Jtk_Event * event)
{ {
for (;;) for (;;)
{ {
/* First check if any timer has expired. */ /* First check for an X event. */
while (XPending(g_display) > 0)
{
XEvent x_event;
XNextEvent(g_display, &x_event);
if (ProcessXEvent(&x_event, event))
return;
}
/* Next check if any timer has expired. */
size_t timer_id = Jtk_GetExpiredTimer(); size_t timer_id = Jtk_GetExpiredTimer();
if (timer_id != (size_t)-1) if (timer_id != (size_t)-1)
{ {
@ -321,15 +330,6 @@ void Jtk_WaitEvent(Jtk_Event * event)
return; return;
} }
/* Next check for an X event. */
while (XPending(g_display) > 0)
{
XEvent x_event;
XNextEvent(g_display, &x_event);
if (ProcessXEvent(&x_event, event))
return;
}
/* Finally, wait for something to happen. */ /* Finally, wait for something to happen. */
uint64_t time_to_wait = Jtk_TimeToNextTimerExpiration(); uint64_t time_to_wait = Jtk_TimeToNextTimerExpiration();
if (time_to_wait > MAX_WAIT_TIME) if (time_to_wait > MAX_WAIT_TIME)