From: Aaron Jensen <aaronjensen@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: martin rudalics <rudalics@gmx.at>, Alan Third <alan@idiocy.org>,
Gregory Heytings <gregory@heytings.org>,
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>,
emacs-devel@gnu.org
Subject: Re: input-pending-p after make-frame-visible
Date: Fri, 22 Oct 2021 09:58:28 -0400 [thread overview]
Message-ID: <CAHyO48zhme7qpCWvKy128Gfq-6Jmdz7qtuoWrBcX=kbceGOSkA@mail.gmail.com> (raw)
In-Reply-To: <83y26l7fon.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1100 bytes --]
On Fri, Oct 22, 2021 at 2:10 AM Eli Zaretskii <eliz@gnu.org> wrote:
>
> > From: Aaron Jensen <aaronjensen@gmail.com>
> > Date: Thu, 21 Oct 2021 16:27:54 -0400
> > Cc: martin rudalics <rudalics@gmx.at>, Alan Third <alan@idiocy.org>,
> > Gregory Heytings <gregory@heytings.org>, YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>,
> > emacs-devel@gnu.org
> >
> > > Well, one solution could be renaming the flag, or documenting that it
> > > must not be used by any caller except input-pending-p.
> >
> > Documentation seems like it could be useful, would you want it to say
> > it can't be used by anything but input-pending-p or that it is
> > currently only used by it?
>
> The former. Something like "this is meant to be used only by
> input-pending-p and similar callers, which aren't interested in all
> input events".
Thanks, updated the original patch "Ignore-non-input-events..." (and
corrected some parens).
I'm also attaching a second option, "Ignore-more-events..." that is a
more minimal change. It only introduces a new variable and doesn't do
any renaming.
Thanks,
Aaron
[-- Attachment #2: 0001-Ignore-non-input-events-in-input-pending-p.patch --]
[-- Type: application/octet-stream, Size: 7947 bytes --]
From cae2e33ffc8ed7bbc61ad4a6897019bd26d5fb4d Mon Sep 17 00:00:00 2001
From: Aaron Jensen <aaronjensen@gmail.com>
Date: Sat, 16 Oct 2021 11:03:50 -0400
Subject: [PATCH] Ignore non-input events in input-pending-p
* keyboard.c (is_non_input_event): New predicate function.
(non-input-events): New variable.
(while-no-input-ignore-events): Updated documentation.
(kbd_buffer_store_buffered_event): Use `is_non_input_event'.
(READABLE_EVENTS_FILTER_NON_INPUT_EVENTS): Renamed from
`READABLE_EVENTS_FILTER_EVENTS'
(read_char): Use `non-input-events' if non-nil.
(readable_events): Use `is_non_input_event' if `non-input-events' is
non-nil.
---
src/keyboard.c | 99 +++++++++++++++++++++++++++++++++-----------------
1 file changed, 65 insertions(+), 34 deletions(-)
diff --git a/src/keyboard.c b/src/keyboard.c
index be9fad3ac3..1de045b78f 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -340,7 +340,7 @@ #define GROW_RAW_KEYBUF \
/* Flags for readable_events. */
#define READABLE_EVENTS_DO_TIMERS_NOW (1 << 0)
-#define READABLE_EVENTS_FILTER_EVENTS (1 << 1)
+#define READABLE_EVENTS_FILTER_NON_INPUT_EVENTS (1 << 1)
#define READABLE_EVENTS_IGNORE_SQUEEZABLES (1 << 2)
/* Function for init_keyboard to call with no args (if nonzero). */
@@ -375,6 +375,7 @@ #define READABLE_EVENTS_IGNORE_SQUEEZABLES (1 << 2)
static void deliver_user_signal (int);
static char *find_user_signal_name (int);
static void store_user_signal_events (void);
+static bool is_non_input_event (union buffered_input_event *event);
/* Advance or retreat a buffered input event pointer. */
@@ -2940,10 +2941,14 @@ read_char (int commandflag, Lisp_Object map,
if (!NILP (tem))
{
struct buffer *prev_buffer = current_buffer;
+ Lisp_Object non_input_events = Vnon_input_events;
last_input_event = c;
call4 (Qcommand_execute, tem, Qnil, Fvector (1, &last_input_event), Qt);
- if (CONSP (c) && !NILP (Fmemq (XCAR (c), Vwhile_no_input_ignore_events))
+ if (NILP (non_input_events))
+ non_input_events = Vwhile_no_input_ignore_events;
+
+ if (CONSP (c) && !NILP (Fmemq (XCAR (c), non_input_events))
&& !end_time)
/* We stopped being idle for this event; undo that. This
prevents automatic window selection (under
@@ -3446,11 +3451,14 @@ readable_events (int flags)
if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
timer_check ();
- /* If the buffer contains only FOCUS_IN/OUT_EVENT events, and
- READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */
+ /* If the buffer contains only events in Vnon_input_events, or
+ FOCUS_IN/OUT_EVENT events when Vnon_input_events is nil, and
+ READABLE_EVENTS_FILTER_NON_INPUT_EVENTS is set, report it as empty. This
+ is meant to be used by input-pending-p and similar callers, which aren't
+ interested in all input events. */
if (kbd_fetch_ptr != kbd_store_ptr)
{
- if (flags & (READABLE_EVENTS_FILTER_EVENTS
+ if (flags & (READABLE_EVENTS_FILTER_NON_INPUT_EVENTS
#ifdef USE_TOOLKIT_SCROLL_BARS
| READABLE_EVENTS_IGNORE_SQUEEZABLES
#endif
@@ -3462,10 +3470,13 @@ readable_events (int flags)
{
if (!(
#ifdef USE_TOOLKIT_SCROLL_BARS
- (flags & READABLE_EVENTS_FILTER_EVENTS) &&
+ (flags & READABLE_EVENTS_FILTER_NON_INPUT_EVENTS) &&
#endif
- (event->kind == FOCUS_IN_EVENT
- || event->kind == FOCUS_OUT_EVENT))
+ ((NILP (Vnon_input_events)
+ && (event->kind == FOCUS_IN_EVENT
+ || event->kind == FOCUS_OUT_EVENT))
+ || (!NILP (Vnon_input_events)
+ && is_non_input_event (event))))
#ifdef USE_TOOLKIT_SCROLL_BARS
&& !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
&& (event->kind == SCROLL_BAR_CLICK_EVENT
@@ -3647,29 +3658,10 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
#endif /* subprocesses */
}
- Lisp_Object ignore_event;
-
- switch (event->kind)
- {
- case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break;
- case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break;
- case HELP_EVENT: ignore_event = Qhelp_echo; break;
- case ICONIFY_EVENT: ignore_event = Qiconify_frame; break;
- case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break;
- case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break;
-#ifdef USE_FILE_NOTIFY
- case FILE_NOTIFY_EVENT: ignore_event = Qfile_notify; break;
-#endif
-#ifdef HAVE_DBUS
- case DBUS_EVENT: ignore_event = Qdbus_event; break;
-#endif
- default: ignore_event = Qnil; break;
- }
-
/* If we're inside while-no-input, and this event qualifies
as input, set quit-flag to cause an interrupt. */
if (!NILP (Vthrow_on_input)
- && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events)))
+ && !is_non_input_event (event))
Vquit_flag = Vthrow_on_input;
}
@@ -10490,7 +10482,7 @@ DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 1, 0,
return (get_input_pending ((NILP (check_timers)
? 0 : READABLE_EVENTS_DO_TIMERS_NOW)
- | READABLE_EVENTS_FILTER_EVENTS)
+ | READABLE_EVENTS_FILTER_NON_INPUT_EVENTS)
? Qt : Qnil);
}
@@ -11607,7 +11599,7 @@ init_keyboard (void)
};
static Lisp_Object
-init_while_no_input_ignore_events (void)
+init_non_input_events (void)
{
Lisp_Object events = listn (9, Qselect_window, Qhelp_echo, Qmove_frame,
Qiconify_frame, Qmake_frame_visible,
@@ -11627,6 +11619,35 @@ init_while_no_input_ignore_events (void)
return events;
}
+static bool
+is_non_input_event (union buffered_input_event *event)
+{
+ Lisp_Object lisp_event;
+ Lisp_Object non_input_events = Vnon_input_events;
+
+ if (NILP (non_input_events))
+ non_input_events = Vwhile_no_input_ignore_events;
+
+ switch (event->kind)
+ {
+ case FOCUS_IN_EVENT: lisp_event = Qfocus_in; break;
+ case FOCUS_OUT_EVENT: lisp_event = Qfocus_out; break;
+ case HELP_EVENT: lisp_event = Qhelp_echo; break;
+ case ICONIFY_EVENT: lisp_event = Qiconify_frame; break;
+ case DEICONIFY_EVENT: lisp_event = Qmake_frame_visible; break;
+ case SELECTION_REQUEST_EVENT: lisp_event = Qselection_request; break;
+#ifdef USE_FILE_NOTIFY
+ case FILE_NOTIFY_EVENT: lisp_event = Qfile_notify; break;
+#endif
+#ifdef HAVE_DBUS
+ case DBUS_EVENT: lisp_event = Qdbus_event; break;
+#endif
+ default: lisp_event = Qnil; break;
+ }
+
+ return !NILP (Fmemq (lisp_event, non_input_events));
+}
+
static void syms_of_keyboard_for_pdumper (void);
void
@@ -12519,13 +12540,23 @@ syms_of_keyboard (void)
If nil, Emacs crashes immediately in response to fatal signals. */);
attempt_orderly_shutdown_on_fatal_signal = true;
+ DEFVAR_LISP ("non-input-events",
+ Vnon_input_events,
+ doc: /* Events ignored by input checking.
+Events in this list do not count as pending input while running
+`while-no-input' or `input-pending-p' and do not cause any idle timers to get
+reset when they occur. Setting this to nil will cause `while-no-input' to
+respect `while-no-input-ignore-events' instead. */
+);
+ Vnon_input_events = init_non_input_events ();
+
DEFVAR_LISP ("while-no-input-ignore-events",
Vwhile_no_input_ignore_events,
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 ();
+If `non-input-events' is non-nil, it will be used instead. 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_non_input_events ();
DEFVAR_BOOL ("translate-upper-case-key-bindings",
translate_upper_case_key_bindings,
--
2.33.0
[-- Attachment #3: 0001-Ignore-more-events-in-input-pending-p.patch --]
[-- Type: application/octet-stream, Size: 5805 bytes --]
From 1f6ee151079dd374e71ac98a4fef1ccb05fc9a80 Mon Sep 17 00:00:00 2001
From: Aaron Jensen <aaronjensen@gmail.com>
Date: Fri, 22 Oct 2021 09:53:24 -0400
Subject: [PATCH] Ignore more events in input-pending-p
* keyboard.c (is_while_no_input_ignored_event): New predicate function.
(input-pending-p-ignores-while-no-input-ignore-events): New variable.
(kbd_buffer_store_buffered_event): Use `is_while_no_input_ignored_event'.
(readable_events): Use `is_while_no_input_ignored_event' if
`input-pending-p-ignores-while-no-input-ignore-events' is non-nil.
Improved documentation.
---
src/keyboard.c | 74 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 50 insertions(+), 24 deletions(-)
diff --git a/src/keyboard.c b/src/keyboard.c
index be9fad3ac3..4e0d9469ee 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -375,6 +375,7 @@ #define READABLE_EVENTS_IGNORE_SQUEEZABLES (1 << 2)
static void deliver_user_signal (int);
static char *find_user_signal_name (int);
static void store_user_signal_events (void);
+static bool is_while_no_input_ignored_event (union buffered_input_event *event);
/* Advance or retreat a buffered input event pointer. */
@@ -3446,8 +3447,13 @@ readable_events (int flags)
if (flags & READABLE_EVENTS_DO_TIMERS_NOW)
timer_check ();
- /* If the buffer contains only FOCUS_IN/OUT_EVENT events, and
- READABLE_EVENTS_FILTER_EVENTS is set, report it as empty. */
+ /* READABLE_EVENTS_FILTER_EVENTS is meant to bu used by input-pending-p and
+ similar callers, which aren't interested in all input events. If it is
+ set, and input-pending-p-ignores-while-no-input-ignore-events is non-nil,
+ and the buffer contains only events in while-no-input-ignore-events,
+ report it as empty. If it is set and
+ input-pending-p-ignores-while-no-input-ignore-events is nil, and the
+ buffer contains only FOCUS_IN/OUT_EVENT events, report it as empty. */
if (kbd_fetch_ptr != kbd_store_ptr)
{
if (flags & (READABLE_EVENTS_FILTER_EVENTS
@@ -3457,6 +3463,8 @@ readable_events (int flags)
))
{
union buffered_input_event *event = kbd_fetch_ptr;
+ bool focus_event_only =
+ NILP (Vinput_pending_p_ignores_while_no_input_ignore_events);
do
{
@@ -3464,8 +3472,11 @@ readable_events (int flags)
#ifdef USE_TOOLKIT_SCROLL_BARS
(flags & READABLE_EVENTS_FILTER_EVENTS) &&
#endif
- (event->kind == FOCUS_IN_EVENT
- || event->kind == FOCUS_OUT_EVENT))
+ ((focus_event_only
+ && event->kind == FOCUS_IN_EVENT
+ || event->kind == FOCUS_OUT_EVENT)
+ || (!focus_event_only
+ && is_while_no_input_ignored_event (event))))
#ifdef USE_TOOLKIT_SCROLL_BARS
&& !((flags & READABLE_EVENTS_IGNORE_SQUEEZABLES)
&& (event->kind == SCROLL_BAR_CLICK_EVENT
@@ -3647,29 +3658,10 @@ kbd_buffer_store_buffered_event (union buffered_input_event *event,
#endif /* subprocesses */
}
- Lisp_Object ignore_event;
-
- switch (event->kind)
- {
- case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break;
- case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break;
- case HELP_EVENT: ignore_event = Qhelp_echo; break;
- case ICONIFY_EVENT: ignore_event = Qiconify_frame; break;
- case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break;
- case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break;
-#ifdef USE_FILE_NOTIFY
- case FILE_NOTIFY_EVENT: ignore_event = Qfile_notify; break;
-#endif
-#ifdef HAVE_DBUS
- case DBUS_EVENT: ignore_event = Qdbus_event; break;
-#endif
- default: ignore_event = Qnil; break;
- }
-
/* If we're inside while-no-input, and this event qualifies
as input, set quit-flag to cause an interrupt. */
if (!NILP (Vthrow_on_input)
- && NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events)))
+ && !is_while_no_input_ignored_event (event))
Vquit_flag = Vthrow_on_input;
}
@@ -11627,6 +11619,31 @@ init_while_no_input_ignore_events (void)
return events;
}
+static bool
+is_while_no_input_ignored_event (union buffered_input_event *event)
+{
+ Lisp_Object ignore_event;
+
+ switch (event->kind)
+ {
+ case FOCUS_IN_EVENT: ignore_event = Qfocus_in; break;
+ case FOCUS_OUT_EVENT: ignore_event = Qfocus_out; break;
+ case HELP_EVENT: ignore_event = Qhelp_echo; break;
+ case ICONIFY_EVENT: ignore_event = Qiconify_frame; break;
+ case DEICONIFY_EVENT: ignore_event = Qmake_frame_visible; break;
+ case SELECTION_REQUEST_EVENT: ignore_event = Qselection_request; break;
+#ifdef USE_FILE_NOTIFY
+ case FILE_NOTIFY_EVENT: ignore_event = Qfile_notify; break;
+#endif
+#ifdef HAVE_DBUS
+ case DBUS_EVENT: ignore_event = Qdbus_event; break;
+#endif
+ default: ignore_event = Qnil; break;
+ }
+
+ return !NILP (Fmemq (ignore_event, Vwhile_no_input_ignore_events));
+}
+
static void syms_of_keyboard_for_pdumper (void);
void
@@ -12519,6 +12536,15 @@ syms_of_keyboard (void)
If nil, Emacs crashes immediately in response to fatal signals. */);
attempt_orderly_shutdown_on_fatal_signal = true;
+ DEFVAR_BOOL ("input-pending-p-ignores-while-no-input-ignore-events",
+ Vinput_pending_p_ignores_while_no_input_ignore_events,
+ doc: /* If non-nil, `input-pending-p' and anything else that
+uses `readable_events' with the flag meant to filter events will use
+`while-no-input-ignore-events' as the list of events to filter. This flag
+may eventually be removed once this behavior is deemed safe. */
+);
+ Vinput_pending_p_ignores_while_no_input_ignore_events = true;
+
DEFVAR_LISP ("while-no-input-ignore-events",
Vwhile_no_input_ignore_events,
doc: /* Ignored events from `while-no-input'.
--
2.33.0
next prev parent reply other threads:[~2021-10-22 13:58 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-24 17:12 input-pending-p after make-frame-visible Aaron Jensen
2021-09-26 9:11 ` martin rudalics
2021-09-26 14:02 ` Aaron Jensen
2021-09-26 17:50 ` martin rudalics
2021-09-26 23:55 ` Aaron Jensen
2021-09-27 8:51 ` martin rudalics
2021-09-27 9:46 ` Aaron Jensen
2021-09-27 17:14 ` martin rudalics
2021-09-27 18:57 ` Eli Zaretskii
2021-09-28 7:41 ` martin rudalics
2021-09-28 8:06 ` Eli Zaretskii
2021-09-29 9:28 ` martin rudalics
2021-09-29 12:06 ` Eli Zaretskii
2021-09-29 12:16 ` Aaron Jensen
2021-09-29 13:13 ` Eli Zaretskii
2021-09-29 14:16 ` Aaron Jensen
2021-09-29 15:42 ` Eli Zaretskii
2021-10-01 17:31 ` Aaron Jensen
2021-10-01 17:55 ` Eli Zaretskii
2021-10-01 17:57 ` Eli Zaretskii
2021-10-01 18:25 ` Aaron Jensen
2021-10-03 19:33 ` Aaron Jensen
2021-10-03 20:55 ` Aaron Jensen
2021-10-03 21:22 ` Gregory Heytings
2021-10-04 1:38 ` Aaron Jensen
2021-10-04 8:29 ` martin rudalics
2021-10-04 11:04 ` Gregory Heytings
2021-10-04 15:00 ` Aaron Jensen
2021-10-04 20:37 ` Alan Third
2021-10-04 22:12 ` Aaron Jensen
2021-10-05 15:47 ` Alan Third
2021-10-14 11:15 ` Aaron Jensen
2021-10-14 11:32 ` Aaron Jensen
2021-10-14 12:42 ` martin rudalics
2021-10-14 23:04 ` Aaron Jensen
2021-10-15 7:05 ` martin rudalics
2021-10-15 11:30 ` Aaron Jensen
2021-10-16 7:54 ` martin rudalics
2021-10-16 14:16 ` Aaron Jensen
2021-10-16 14:45 ` Aaron Jensen
2021-10-16 15:09 ` Aaron Jensen
2021-10-16 16:49 ` martin rudalics
2021-10-16 17:14 ` Aaron Jensen
2021-10-20 15:27 ` Aaron Jensen
2021-10-20 16:41 ` Eli Zaretskii
2021-10-20 17:15 ` Aaron Jensen
2021-10-20 17:40 ` Eli Zaretskii
2021-10-20 17:47 ` Aaron Jensen
2021-10-20 18:24 ` Eli Zaretskii
2021-10-20 18:55 ` Aaron Jensen
2021-10-20 19:04 ` Eli Zaretskii
2021-10-20 20:00 ` Aaron Jensen
2021-10-21 6:02 ` Eli Zaretskii
2021-10-21 6:58 ` YAMAMOTO Mitsuharu
2021-10-21 7:47 ` Eli Zaretskii
2021-10-21 11:25 ` Aaron Jensen
2021-10-21 11:33 ` Aaron Jensen
2021-10-21 12:40 ` Stefan Monnier
2021-10-21 13:44 ` Eli Zaretskii
2021-10-21 14:07 ` Aaron Jensen
2021-10-21 17:36 ` Eli Zaretskii
2021-10-21 17:46 ` Aaron Jensen
2021-10-21 18:04 ` Eli Zaretskii
2021-10-21 20:27 ` Aaron Jensen
2021-10-22 2:28 ` Aaron Jensen
2021-10-22 6:10 ` Eli Zaretskii
2021-10-22 13:58 ` Aaron Jensen [this message]
2021-10-26 13:23 ` Aaron Jensen
2021-10-26 14:05 ` Eli Zaretskii
2021-10-28 15:51 ` Eli Zaretskii
2021-10-28 18:12 ` Aaron Jensen
2021-10-28 18:20 ` Eli Zaretskii
2021-10-31 10:33 ` Alan Third
2021-10-31 16:42 ` Aaron Jensen
2021-10-21 13:40 ` Eli Zaretskii
2021-10-15 17:32 ` Alan Third
2021-10-15 17:54 ` Stefan Monnier
2021-10-15 18:28 ` Aaron Jensen
2021-10-04 8:28 ` martin rudalics
2021-09-27 19:26 ` Stefan Monnier
2021-09-27 23:02 ` Aaron Jensen
2021-09-28 2:29 ` Aaron Jensen
2021-09-29 5:10 ` Aaron Jensen
2021-09-29 9:28 ` martin rudalics
2021-09-28 5:50 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAHyO48zhme7qpCWvKy128Gfq-6Jmdz7qtuoWrBcX=kbceGOSkA@mail.gmail.com' \
--to=aaronjensen@gmail.com \
--cc=alan@idiocy.org \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=gregory@heytings.org \
--cc=mituharu@math.s.chiba-u.ac.jp \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).