From: "Adrián Medraño Calvo" <adrian@medranocalvo.com>
To: 61241@debbugs.gnu.org
Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2
Date: Thu, 2 Feb 2023 23:28:01 +0100 [thread overview]
Message-ID: <16B04B25-8EB8-4967-947B-C03DF3690ADF@medranocalvo.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1481 bytes --]
For the implementation of `mouse-autoselect-window', the entered window
is remembered and then compared when an mouse motion event is received.
Up to Emacs 28, this value was stored in a static local variable named
`last_mouse_window' in the block handling MotionNotify within
`handle_one_xevent'. With the introduction of XInput 2,
`handle_one_xevent' was adjusted to account for XI_Motion events, with
the oversight that a new local static `last_mouse_window' variable was
declared in the new handler block for XI_Motion. As a result, when
Emacs receives motion events from XInput and XInput2 sources
alternatively the value of each `last_mouse_window’ differs, leading to
the window under the motion sometimes not being selected, as the
value `last_mouse_window' is out-of-date for the particular XInput
version.
This bug impacts the GNU ELPA package EXWM. EXWM tries to extrapolate
applicable Emacs functionality to X window management; among others
assigns an Emacs buffer to each managed X window, and positions the X
window over the Emacs window in which the buffer is displayed. When
`mouse-autoselect-windows’ and the user moves the mouse pointer over one
X window managed by EXWM, this X window receives the mouse events and not
Emacs, therefore the Emacs window is not selected. In order to overcome
this, EXWM sends a synthetic MotionNotify event to Emacs.
The attached patch fixes the issue.
Thank you,
Adrián Medraño Calvo.
[-- Attachment #2: 0001-Fix-mouse-autoselect-window-for-alternating-XInput-a.patch --]
[-- Type: application/octet-stream, Size: 1883 bytes --]
From e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c Mon Sep 17 00:00:00 2001
Message-Id: <e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c.1675376734.git.adrian@medranocalvo.com>
From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?=
<adrian@medranocalvo.com>
Date: Wed, 1 Feb 2023 00:00:00 +0000
Subject: [PATCH] Fix `mouse-autoselect-window' for alternating XInput and
XInput 2 events
* src/xterm.c (handle_one_xevent): Move `last_mouse_window' to
main function scope to share value between XInput and XInput 2
handlers.
---
src/xterm.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index 6a4b84babe4..dd20c8c7fe5 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -18364,6 +18364,9 @@ handle_one_xevent (struct x_display_info *dpyinfo,
GdkDisplay *gdpy = gdk_x11_lookup_xdisplay (dpyinfo->display);
#endif
int dx, dy;
+ /* Holds the last window the mouse moved over, used for
+ `mouse-autoselect-window' */
+ static Lisp_Object last_mouse_window;
/* Avoid warnings when SAFE_ALLOCA is not actually used. */
#if defined HAVE_XINPUT2 || defined HAVE_XKB || defined HAVE_X_I18N
@@ -20677,8 +20680,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
&& (f == XFRAME (selected_frame)
|| !NILP (focus_follows_mouse)))
{
- static Lisp_Object last_mouse_window;
-
if (xmotion.window != FRAME_X_WINDOW (f))
{
x_translate_coordinates (f, xmotion.x_root, xmotion.y_root,
@@ -22587,7 +22588,6 @@ handle_one_xevent (struct x_display_info *dpyinfo,
&& (f == XFRAME (selected_frame)
|| !NILP (focus_follows_mouse)))
{
- static Lisp_Object last_mouse_window;
Lisp_Object window = window_from_coordinates (f, ev.x, ev.y, 0, false, false);
/* A window will be autoselected only when it is not
--
2.39.1
[-- Attachment #3: Type: text/plain, Size: 3516 bytes --]
In GNU Emacs 29.0.60 (build 1, x86_64-apple-darwin22.2.0, cairo version
1.17.6) of 2023-01-26 built on amcmac
Repository revision: f8c95d1a7681e861fc22d2a040cda0ddfe23eff4
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101006
System Description: macOS 13.2
Configured using:
'configure --prefix=/Volumes/sys/repos/emacs-cairo/rel
--without-makeinfo --without-dbus --without-ns --with-x-toolkit=no
--with-cairo
PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig:/usr/local/opt/freetype/lib/pkgconfig:/usr/local/opt/fontconfig/lib/pkgconfig:/usr/local/opt/ncurses/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/Cellar/jpeg/9d/lib/pkgconfig:/usr/local/Cellar/libtiff/4.3.0/lib/pkgconfig:/usr/local/opt/harfbuzz/lib/pkgconfig/:/usr/local/opt/harfbuzz/lib/pkgconfig/
'CFLAGS=-Og -g3' --without-jpeg --without-gif --without-xpm
--without-tiff'
Configured features:
ACL CAIRO FREETYPE GLIB GMP GNUTLS GSETTINGS HARFBUZZ JSON LCMS2 LIBXML2
MODULES NOTIFY KQUEUE OLDXMENU PDUMPER PNG RSVG SQLITE3 THREADS WEBP X11
XDBE XIM XINPUT2 ZLIB
Important settings:
value of $LC_ALL: en_US.UTF-8
value of $LANG: en_US
value of $XMODIFIERS: @im=exwm-xim
locale-coding-system: utf-8-unix
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
line-number-mode: t
indent-tabs-mode: t
transient-mark-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils rmc iso-transl tooltip cconv eldoc paren electric
uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel
term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads kqueue lcms2 dynamic-setting
system-font-setting font-render-setting cairo xinput2 x multi-tty
make-network-process emacs)
Memory information:
((conses 16 38318 8147)
(symbols 48 5108 0)
(strings 32 12656 2131)
(string-bytes 1 362604)
(vectors 16 10252)
(vector-slots 8 147251 15877)
(floats 8 42 19)
(intervals 56 263 0)
(buffers 976 10))
next reply other threads:[~2023-02-02 22:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-02 22:28 Adrián Medraño Calvo [this message]
2023-02-04 8:25 ` bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Eli Zaretskii
2023-02-04 8:43 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-02-05 19:04 ` Adrián Medraño Calvo
2023-02-06 1:40 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-08-22 5:45 ` Adrián Medraño Calvo
2023-08-22 6:59 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=16B04B25-8EB8-4967-947B-C03DF3690ADF@medranocalvo.com \
--to=adrian@medranocalvo.com \
--cc=61241@debbugs.gnu.org \
/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).