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;
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