aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-06-20 20:56:49 +0800
committerPo Lu2022-06-20 20:59:38 +0800
commit4cc2f820b500ed2f8fad9baa2cf4a057f271a006 (patch)
treec32aa9a1882205d2ab62367ebadb976e9d06df5a /src
parenta7aeef934be65ed86993181f3ad3b4b074a6afaa (diff)
downloademacs-4cc2f820b500ed2f8fad9baa2cf4a057f271a006.tar.gz
emacs-4cc2f820b500ed2f8fad9baa2cf4a057f271a006.zip
Fix x-selection-timeout if some keyboard input arrives while waiting
* src/process.c (wait_reading_process_output): Don't allow skipping calls to select if detect_input_pending when just waiting for a cell. (bug#46935) * src/xselect.c (x_get_foreign_selection): Add more debugging code.
Diffstat (limited to 'src')
-rw-r--r--src/process.c12
-rw-r--r--src/xselect.c8
2 files changed, 18 insertions, 2 deletions
diff --git a/src/process.c b/src/process.c
index 0cbac172fe4..8f654961482 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5492,7 +5492,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
5492 triggered by processing X events). In the latter case, set 5492 triggered by processing X events). In the latter case, set
5493 nfds to 1 to avoid breaking the loop. */ 5493 nfds to 1 to avoid breaking the loop. */
5494 no_avail = 0; 5494 no_avail = 0;
5495 if ((read_kbd || !NILP (wait_for_cell)) 5495 if ((read_kbd
5496 /* The following code doesn't make any sense for just the
5497 wait_or_cell case, because detect_input_pending returns
5498 whether or not the keyboard buffer isn't empty or there
5499 is mouse movement. Any keyboard input that arrives
5500 while waiting for a cell will cause the select call to
5501 be skipped, and gobble_input to be called even when
5502 there is no input available from the terminal itself.
5503 Skipping the call to select also causes the timeout to
5504 be ignored. (bug#46935) */
5505 /* || !NILP (wait_for_cell) */)
5496 && detect_input_pending ()) 5506 && detect_input_pending ())
5497 { 5507 {
5498 nfds = read_kbd ? 0 : 1; 5508 nfds = read_kbd ? 0 : 1;
diff --git a/src/xselect.c b/src/xselect.c
index dd82a906af1..fcf0ee944e2 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -1261,7 +1261,13 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type,
1261 intmax_t timeout = max (0, x_selection_timeout); 1261 intmax_t timeout = max (0, x_selection_timeout);
1262 intmax_t secs = timeout / 1000; 1262 intmax_t secs = timeout / 1000;
1263 int nsecs = (timeout % 1000) * 1000000; 1263 int nsecs = (timeout % 1000) * 1000000;
1264 TRACE1 (" Start waiting %"PRIdMAX" secs for SelectionNotify", secs); 1264 TRACE1 (" Start waiting %"PRIdMAX" secs for SelectionNotify.", secs);
1265
1266 if (input_blocked_p ())
1267 TRACE0 (" Input is blocked.");
1268 else
1269 TRACE1 (" Waiting for %d nsecs in addition.", nsecs);
1270
1265 /* This function can be called with input blocked inside Xt or GTK 1271 /* This function can be called with input blocked inside Xt or GTK
1266 timeouts run inside popup menus, so use a function that works 1272 timeouts run inside popup menus, so use a function that works
1267 when input is blocked. Prefer wait_reading_process_output 1273 when input is blocked. Prefer wait_reading_process_output