From: Jared Finder via "Emacs development discussions." <emacs-devel@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: mouse-face and help echo support for xterm mouse
Date: Wed, 04 Nov 2020 09:54:11 -0800 [thread overview]
Message-ID: <5928a03c79bcf0afee270de1df4d9fa5@finder.org> (raw)
In-Reply-To: <jwv1rh9p14g.fsf-monnier+emacs@gnu.org>
On 2020-11-04 7:56 am, Stefan Monnier wrote:
>
> diff --git a/src/term.c b/src/term.c
> index ff1aabfed2..a03a246415 100644
> --- a/src/term.c
> +++ b/src/term.c
> @@ -2562,7 +2562,8 @@
> ie.kind = NO_EVENT;
> ie.arg = Qnil;
>
> - if (event->type & (GPM_MOVE | GPM_DRAG)) {
> + if (event->type & (GPM_MOVE | GPM_DRAG))
> + {
Old code style is OLD. Apparently this formatting is from when the
function was first added in 2007. :)
> @@ -2577,29 +2578,45 @@
> || !NILP (previous_help_echo_string))
> do_help = 1;
>
> - goto done;
> + eassert (ie.kind == NO_EVENT);
This is the assert for the mouse movement path. Please remember this
value.
> }
> - else {
> + else
> + {
> f->mouse_moved = 0;
> + eassert (ie.kind == NO_EVENT);
> term_mouse_click (&ie, event, f);
> + eassert (ie.kind == GPM_CLICK_EVENT);
> if (tty_handle_tab_bar_click (f, event->x, event->y,
> (ie.modifiers & down_modifier) != 0,
> &ie))
> {
> + eassert (ie.kind == GPM_CLICK_EVENT
> + || ie.kind == TAB_BAR_EVENT);
> /* tty_handle_tab_bar_click stores 2 events in the event
> queue, so we are done here. */
> + /* FIXME: Actually, `tty_handle_tab_bar_click` returns true
> + without storing any events, when
> + (ie.modifiers & down_modifier) != 0 */
> count += 2;
> return count;
> }
> + eassert (ie.kind == GPM_CLICK_EVENT);
This assert is for the mouse click path, please remember this value.
> }
>
> - done:
> - if (ie.kind != NO_EVENT)
> + if (ie.kind != NO_EVENT) /* FIXME: We retest the previous if's
> condition! */
> {
> + /* FIXME: `hold_quit` could already hold a previous event,
> + so it risks crushing that previous event.
> + What am I missing? */
> kbd_buffer_store_event_hold (&ie, hold_quit);
This is the meat of the refactor.
Given the current code hold_quit will never hold a previous event.
tty_read_avail_input initializes hold_quit right before calling
handle_one_term_event and and sets kind to NO_EVENT. This is the first
and only time in this function hold_quit is passed to any other
function.
Because it is the first time passed, we can safely deduce that
hold_quit->kind will still be NO_EVENT *unless* a previous loop
iteration changed it.
Because it is the only time passed, we can safely deduce that
hold_quit->kind can only changed in a previous loop iteration by this
function storing a quit event. However, this can not happen. hold_quit
would get set by kbd_buffer_store_buffered_event which
kbd_buffer_store_event_hold calls. To get set, the following must all
be true:
1. An event of kind ASCII_KEYSTROKE_EVENT must be processed.
2. And that event's character code must be quit_char.
3. And that event must be on the current frame's KBOARD (not quite sure
what this means).
However, 1 will never be true as the only events that ever reach this
point are of kind GPM_CLICK_EVENT, as deduced from the above asserts.
> count++;
> }
>
> if (do_help
> + /* FIXME: `hold_quit` is never NULL?! */
Agreed.
> + /* FIXME: Why do we test `hold_quit->kind != NO_EVENT` here?
> + This either comes from `ie` (via kbd_buffer_store_event_hold
> above)
> + or from an earlier call to us (tty_read_avail_input calls us
> in a
> + loop with the same `hold_quit` struct). */
And from above reasoning, we know that hold_quit is always non-NULL and
hold_quit->kind is always NO_EVENT.
-- MJF
next prev parent reply other threads:[~2020-11-04 17:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-01 5:46 mouse-face and help echo support for xterm mouse Jared Finder via Emacs development discussions.
2020-11-01 13:39 ` Stefan Monnier
2020-11-01 15:56 ` Jared Finder via Emacs development discussions.
2020-11-04 6:54 ` Jared Finder via Emacs development discussions.
2020-11-04 14:13 ` Stefan Monnier
2020-11-04 15:46 ` Eli Zaretskii
2020-11-04 15:56 ` Stefan Monnier
2020-11-04 17:54 ` Jared Finder via Emacs development discussions. [this message]
2020-11-04 18:47 ` Stefan Monnier
2020-11-04 18:51 ` Eli Zaretskii
2020-11-04 19:05 ` Stefan Monnier
2020-11-04 19:10 ` Jared Finder via Emacs development discussions.
2020-11-04 15:19 ` Eli Zaretskii
2020-11-05 8:15 ` Jared Finder via Emacs development discussions.
2020-11-05 14:45 ` Stefan Monnier
2020-11-05 19:58 ` Jared Finder via Emacs development discussions.
2020-11-05 20:18 ` Stefan Monnier
2020-11-06 5:23 ` Jared Finder via Emacs development discussions.
2020-11-06 6:00 ` Eli Zaretskii
2020-11-06 6:46 ` Jared Finder via Emacs development discussions.
2020-11-06 7:39 ` Eli Zaretskii
2020-11-07 1:22 ` Jared Finder via Emacs development discussions.
2020-11-14 12:38 ` Eli Zaretskii
2020-11-14 12:35 ` 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=5928a03c79bcf0afee270de1df4d9fa5@finder.org \
--to=emacs-devel@gnu.org \
--cc=eliz@gnu.org \
--cc=jared@finder.org \
--cc=monnier@iro.umontreal.ca \
/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).