From e1c6b40e9d3b9bb44a310dcac4f7f05b4e5bde4f Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 13 Apr 2022 15:03:50 +0800 Subject: [PATCH] Fix input availability detection during visible-bell * src/xterm.c (XTflash): Exit pselect loop also if input becomes available on f's display connection. --- src/xterm.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/xterm.c b/src/xterm.c index c1c9ebde5cb..0c1c70340de 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -8652,6 +8652,8 @@ XTflash (struct frame *f) { GC gc; XGCValues values; + fd_set fds; + int fd; block_input (); @@ -8702,6 +8704,7 @@ XTflash (struct frame *f) struct timespec delay = make_timespec (0, 150 * 1000 * 1000); struct timespec wakeup = timespec_add (current_timespec (), delay); + fd = ConnectionNumber (FRAME_X_DISPLAY (f)); /* Keep waiting until past the time wakeup or any input gets available. */ @@ -8717,8 +8720,17 @@ XTflash (struct frame *f) /* How long `select' should wait. */ timeout = make_timespec (0, 10 * 1000 * 1000); + /* Wait for some input to become available on the X + connection. */ + FD_ZERO (&fds); + FD_SET (fd, &fds); + /* Try to wait that long--but we might wake up sooner. */ - pselect (0, NULL, NULL, NULL, &timeout, NULL); + pselect (fd + 1, &fds, NULL, NULL, &timeout, NULL); + + /* Some input is available, exit the visible bell. */ + if (FD_ISSET (fd, &fds)) + break; } /* If window is tall, flash top and bottom line. */ -- 2.39.5