From 7865bd6782dacf506de8f69064f018de444da27f Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Tue, 12 Oct 2021 09:53:57 +0200 Subject: [PATCH] Have 'while-no-input-ignore-events' handle idle timers too (Bug#49997) * src/keyboard.c (read_char): Use Vwhile_no_input_ignore_events to check which idle timers should be resumed (Bug#49997). (init_while_no_input_ignore_events): New function to initialize Vwhile_no_input_ignore_events. (Vwhile_no_input_ignore_events): Say in doc-string that events in this list do not stop idle timers. * lisp/subr.el (while-no-input): Remove initialization of 'while-no-input-ignore-events'; do that in keyboard.c now. --- lisp/subr.el | 5 ----- src/keyboard.c | 43 ++++++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lisp/subr.el b/lisp/subr.el index fa097b3f19e..90f24a237fb 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -4387,11 +4387,6 @@ is allowed once again. (Immediately, if `inhibit-quit' is nil.)" ;; that intends to handle the quit signal next time. (eval '(ignore nil))))) -;; Don't throw `throw-on-input' on those events by default. -(setq while-no-input-ignore-events - '(focus-in focus-out help-echo iconify-frame - make-frame-visible selection-request)) - (defmacro while-no-input (&rest body) "Execute BODY only as long as there's no pending input. If input arrives, that ends the execution of BODY, diff --git a/src/keyboard.c b/src/keyboard.c index 7184b1509b1..ce3b900b485 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -2943,20 +2943,8 @@ read_char (int commandflag, Lisp_Object map, last_input_event = c; call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt); - if (CONSP (c) - && (EQ (XCAR (c), Qselect_window) - || EQ (XCAR (c), Qfocus_out) -#ifdef HAVE_DBUS - || EQ (XCAR (c), Qdbus_event) -#endif -#ifdef USE_FILE_NOTIFY - || EQ (XCAR (c), Qfile_notify) -#endif -#ifdef THREADS_ENABLED - || EQ (XCAR (c), Qthread_event) -#endif - || EQ (XCAR (c), Qconfig_changed_event)) - && !end_time) + if (CONSP (c) && !NILP (Fmemq (XCAR (c), Vwhile_no_input_ignore_events)) + && !end_time) /* We stopped being idle for this event; undo that. This prevents automatic window selection (under mouse-autoselect-window) from acting as a real input event, for @@ -11605,6 +11593,27 @@ static const struct event_head head_table[] = { {SYMBOL_INDEX (Qselect_window), SYMBOL_INDEX (Qswitch_frame)} }; +static Lisp_Object +init_while_no_input_ignore_events (void) +{ + Lisp_Object events = listn (9, Qselect_window, Qhelp_echo, Qmove_frame, + Qiconify_frame, Qmake_frame_visible, + Qfocus_in, Qfocus_out, Qconfig_changed_event, + Qselection_request); + +#ifdef HAVE_DBUS + events = Fcons (Qdbus_event, events); +#endif +#ifdef USE_FILE_NOTIFY + events = Fcons (Qfile_notify, events); +#endif +#ifdef THREADS_ENABLED + events = Fcons (Qthread_event, events); +#endif + + return events; +} + static void syms_of_keyboard_for_pdumper (void); void @@ -12499,7 +12508,11 @@ If nil, Emacs crashes immediately in response to fatal signals. */); DEFVAR_LISP ("while-no-input-ignore-events", Vwhile_no_input_ignore_events, - doc: /* Ignored events from while-no-input. */); + doc: /* Ignored events from `while-no-input'. +Events in this list do not count as pending input while running +`while-no-input' and do not cause any idle timers to get reset when they +occur. */); + Vwhile_no_input_ignore_events = init_while_no_input_ignore_events (); DEFVAR_BOOL ("translate-upper-case-key-bindings", translate_upper_case_key_bindings, -- 2.39.2