From 6fb206329f9c3f14154bd425e08b2e72e7f31855 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 3 Aug 2022 20:17:18 +0800 Subject: [PATCH] ; * src/xterm.c (x_if_event): Minor speed improvements. --- src/xterm.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/xterm.c b/src/xterm.c index eb1a557e883..f82340958e5 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -6605,12 +6605,17 @@ x_if_event (Display *dpy, XEvent *event_return, current_time = current_timespec (); target = timespec_add (current_time, timeout); + /* Check if an event is already in the queue. If it is, avoid + syncing. */ + if (XCheckIfEvent (dpy, event_return, predicate, arg)) + return 0; + while (true) { /* Get events into the queue. */ XSync (dpy, False); - /* Check if an event is now in the queue. */ + /* Look for an event again. */ if (XCheckIfEvent (dpy, event_return, predicate, arg)) return 0; -- 2.39.5