[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4cc2f820b5: Fix x-selection-timeout if some keyboard input arrive
From: |
Po Lu |
Subject: |
master 4cc2f820b5: Fix x-selection-timeout if some keyboard input arrives while waiting |
Date: |
Mon, 20 Jun 2022 08:59:48 -0400 (EDT) |
branch: master
commit 4cc2f820b500ed2f8fad9baa2cf4a057f271a006
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
src/process.c | 12 +++++++++++-
src/xselect.c | 8 +++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/process.c b/src/process.c
index 0cbac172fe..8f65496148 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,
triggered by processing X events). In the latter case, set
nfds to 1 to avoid breaking the loop. */
no_avail = 0;
- if ((read_kbd || !NILP (wait_for_cell))
+ if ((read_kbd
+ /* The following code doesn't make any sense for just the
+ wait_or_cell case, because detect_input_pending returns
+ whether or not the keyboard buffer isn't empty or there
+ is mouse movement. Any keyboard input that arrives
+ while waiting for a cell will cause the select call to
+ be skipped, and gobble_input to be called even when
+ there is no input available from the terminal itself.
+ Skipping the call to select also causes the timeout to
+ be ignored. (bug#46935) */
+ /* || !NILP (wait_for_cell) */)
&& detect_input_pending ())
{
nfds = read_kbd ? 0 : 1;
diff --git a/src/xselect.c b/src/xselect.c
index dd82a906af..fcf0ee944e 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,
intmax_t timeout = max (0, x_selection_timeout);
intmax_t secs = timeout / 1000;
int nsecs = (timeout % 1000) * 1000000;
- TRACE1 (" Start waiting %"PRIdMAX" secs for SelectionNotify", secs);
+ TRACE1 (" Start waiting %"PRIdMAX" secs for SelectionNotify.", secs);
+
+ if (input_blocked_p ())
+ TRACE0 (" Input is blocked.");
+ else
+ TRACE1 (" Waiting for %d nsecs in addition.", nsecs);
+
/* This function can be called with input blocked inside Xt or GTK
timeouts run inside popup menus, so use a function that works
when input is blocked. Prefer wait_reading_process_output
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 4cc2f820b5: Fix x-selection-timeout if some keyboard input arrives while waiting,
Po Lu <=