Subject: Re: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2

From: Po Lu <[email-masked]>
Date: Tue, 22 Aug 2023 14:59:00 +0800

Adrián Medraño Calvo <[email-masked]> writes:

> I prepared a patch (attached below) introducing a new lisp variable
> holding the last "mouse-autoselected” window.  With this patch EXWM
> can simply select the Emacs window corresponding to the managed X
> window and set it as last “mouse-autoselected” window;
> mouse-autoselect works normally after that.  No more sending Motion
> events.
>
> Using a single variable introduces a significant change, though: when
> `mouse-autoselect-window’ is enabled and emacs runs in different
> terminals, “mouse-autoselecting” a window on a terminal changes the
> last “mouse-autoselected” window for all other terminals.  Slightly
> moving the mouse in a different terminal (within a single Emacs
> window) will “mouse-autoselect” that window, whereas that would not
> have been the case before this patch, as the last “mouse-autoselected”
> window was terminal-specific.  It’s not clear to me whether this
> behaviour will be beneficial, neutral or unacceptable.  Moreover, this
> behaviour is consistent with the behaviour introduced in the first
> patch I sent, where I proposed to merge the last “mouse-autoselected”
> window for Motion and XI_Motion events (other terminals were not
> affected).

Thanks.  Taking into account your experiences with the TEST extension,
I'm inclined towards believing that such a change is TRT, but the
variable should be made terminal-local instead.  (Emacs Lisp does
provide such a facility.)

Also, there are a few difficulties with the patch you attached.  First
of all, it obsoletes an existing variable without due reason, and that
should be avoided.  Secondly, :version specifiers within the patch
should be revised to mention Emacs 30, since such a large change is not
apposite for the release branch.

Finally, you missed the new terminal backend introduced in Emacs 30,
src/androidterm.c.