X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Resent-From: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Thu, 02 Feb 2023 22:29:02 +0000 Resent-Message-ID: <handler.61241.B.167537689821343 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 61241 <at> debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.167537689821343 (code B ref -1); Thu, 02 Feb 2023 22:29:02 +0000 Received: (at submit) by debbugs.gnu.org; 2 Feb 2023 22:28:18 +0000 Received: from localhost ([127.0.0.1]:36096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pNi41-0005YA-Ji for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 17:28:18 -0500 Received: from lists.gnu.org ([209.51.188.17]:55830) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <adrian@HIDDEN>) id 1pNi3y-0005Y2-Te for submit <at> debbugs.gnu.org; Thu, 02 Feb 2023 17:28:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <adrian@HIDDEN>) id 1pNi3y-0004lB-JG for bug-gnu-emacs@HIDDEN; Thu, 02 Feb 2023 17:28:14 -0500 Received: from mout-p-102.mailbox.org ([2001:67c:2050:0:465::102]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256) (Exim 4.90_1) (envelope-from <adrian@HIDDEN>) id 1pNi3w-00059v-5h for bug-gnu-emacs@HIDDEN; Thu, 02 Feb 2023 17:28:14 -0500 Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4P7D2D3gRfz9sbn for <bug-gnu-emacs@HIDDEN>; Thu, 2 Feb 2023 23:28:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=medranocalvo.com; s=MBO0001; t=1675376884; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=g/kY5kWZ6N5rlOGuKZGOgZBsLYudXRzPmvVV2qEMN04=; b=bSbYh4jvy2rBPnivsiheiIBaTUdQFkDersd2VGHNZYZcy5syJdFjrnRBL7gOjd/aL8ZzRm ugLE9pr+eimqQCF2rC/HAhFLPCm4I7HKrIUqdxxW+wVF8b6cvRqFmo0qq0wbXkJsdqszyq r93UY7q/g5B3wa52JFlcEKOJYzX2KgwYLybHvYxyRzosetFo+pu+LHlduN8oxrbUwC3cHs P6Km0EdrpMqc7zLY0uCPuP9+bPp0Jb2pIzxPUugjQIudlIApdQcvinb8HI8XvvychpvtTX dNgr8jKp+egw5xoJBnnia30Kgno70WbS4UYEHNDiTWIHFltLm7MJmYfFXC0jug== From: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Content-Type: multipart/mixed; boundary="Apple-Mail=_00C787AB-0549-46AC-9266-563CC5017C8E" Mime-Version: 1.0 Message-Id: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> Date: Thu, 2 Feb 2023 23:28:01 +0100 Received-SPF: pass client-ip=2001:67c:2050:0:465::102; envelope-from=adrian@HIDDEN; helo=mout-p-102.mailbox.org X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.6 (-) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -2.6 (--) --Apple-Mail=_00C787AB-0549-46AC-9266-563CC5017C8E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 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=E2=80=99 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=E2=80=99 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=C3=A1n Medra=C3=B1o Calvo. --Apple-Mail=_00C787AB-0549-46AC-9266-563CC5017C8E Content-Disposition: attachment; filename=0001-Fix-mouse-autoselect-window-for-alternating-XInput-a.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Fix-mouse-autoselect-window-for-alternating-XInput-a.patch" Content-Transfer-Encoding: quoted-printable =46rom=20e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c=20Mon=20Sep=2017=20= 00:00:00=202001=0AMessage-Id:=20= <e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c.1675376734.git.adrian@medranocal= vo.com>=0AFrom:=20=3D?UTF-8?q?Adri=3DC3=3DA1n=3D20Medra=3DC3=3DB1o=3D20Cal= vo?=3D=0A=20<adrian@HIDDEN>=0ADate:=20Wed,=201=20Feb=202023=20= 00:00:00=20+0000=0ASubject:=20[PATCH]=20Fix=20`mouse-autoselect-window'=20= for=20alternating=20XInput=20and=0A=20XInput=202=20events=0A=0A*=20= src/xterm.c=20(handle_one_xevent):=20Move=20`last_mouse_window'=20to=0A= main=20function=20scope=20to=20share=20value=20between=20XInput=20and=20= XInput=202=0Ahandlers.=0A---=0A=20src/xterm.c=20|=206=20+++---=0A=201=20= file=20changed,=203=20insertions(+),=203=20deletions(-)=0A=0Adiff=20= --git=20a/src/xterm.c=20b/src/xterm.c=0Aindex=206a4b84babe4..dd20c8c7fe5=20= 100644=0A---=20a/src/xterm.c=0A+++=20b/src/xterm.c=0A@@=20-18364,6=20= +18364,9=20@@=20handle_one_xevent=20(struct=20x_display_info=20*dpyinfo,=0A= =20=20=20GdkDisplay=20*gdpy=20=3D=20gdk_x11_lookup_xdisplay=20= (dpyinfo->display);=0A=20#endif=0A=20=20=20int=20dx,=20dy;=0A+=20=20/*=20= Holds=20the=20last=20window=20the=20mouse=20moved=20over,=20used=20for=0A= +=20=20=20=20=20`mouse-autoselect-window'=20*/=0A+=20=20static=20= Lisp_Object=20last_mouse_window;=0A=20=0A=20=20=20/*=20Avoid=20warnings=20= when=20SAFE_ALLOCA=20is=20not=20actually=20used.=20=20*/=0A=20#if=20= defined=20HAVE_XINPUT2=20||=20defined=20HAVE_XKB=20||=20defined=20= HAVE_X_I18N=0A@@=20-20677,8=20+20680,6=20@@=20handle_one_xevent=20= (struct=20x_display_info=20*dpyinfo,=0A=20=09=09&&=20(f=20=3D=3D=20= XFRAME=20(selected_frame)=0A=20=09=09=20=20=20=20||=20!NILP=20= (focus_follows_mouse)))=0A=20=09=20=20=20=20=20=20{=0A-=09=09static=20= Lisp_Object=20last_mouse_window;=0A-=0A=20=09=09if=20(xmotion.window=20= !=3D=20FRAME_X_WINDOW=20(f))=0A=20=09=09=20=20{=0A=20=09=09=20=20=20=20= x_translate_coordinates=20(f,=20xmotion.x_root,=20xmotion.y_root,=0A@@=20= -22587,7=20+22588,6=20@@=20handle_one_xevent=20(struct=20x_display_info=20= *dpyinfo,=0A=20=09=09=20=20=20=20=20=20&&=20(f=20=3D=3D=20XFRAME=20= (selected_frame)=0A=20=09=09=09=20=20||=20!NILP=20= (focus_follows_mouse)))=0A=20=09=09=20=20=20=20{=0A-=09=09=20=20=20=20=20= =20static=20Lisp_Object=20last_mouse_window;=0A=20=09=09=20=20=20=20=20=20= Lisp_Object=20window=20=3D=20window_from_coordinates=20(f,=20ev.x,=20= ev.y,=200,=20false,=20false);=0A=20=0A=20=09=09=20=20=20=20=20=20/*=20A=20= window=20will=20be=20autoselected=20only=20when=20it=20is=20not=0A--=20=0A= 2.39.1=0A=0A= --Apple-Mail=_00C787AB-0549-46AC-9266-563CC5017C8E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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=3D/Volumes/sys/repos/emacs-cairo/rel --without-makeinfo --without-dbus --without-ns --with-x-toolkit=3Dno --with-cairo = PKG_CONFIG_PATH=3D/opt/X11/lib/pkgconfig:/usr/local/opt/freetype/lib/pkgco= nfig:/usr/local/opt/fontconfig/lib/pkgconfig:/usr/local/opt/ncurses/lib/pk= gconfig:/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/ha= rfbuzz/lib/pkgconfig/:/usr/local/opt/harfbuzz/lib/pkgconfig/ 'CFLAGS=3D-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=3Dexwm-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))= --Apple-Mail=_00C787AB-0549-46AC-9266-563CC5017C8E--
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Subject: bug#61241: Acknowledgement (29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2) Message-ID: <handler.61241.B.167537689821343.ack <at> debbugs.gnu.org> References: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> X-Gnu-PR-Message: ack 61241 X-Gnu-PR-Package: emacs Reply-To: 61241 <at> debbugs.gnu.org Date: Thu, 02 Feb 2023 22:29:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): bug-gnu-emacs@HIDDEN If you wish to submit further information on this problem, please send it to 61241 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 61241: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D61241 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Resent-From: Eli Zaretskii <eliz@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 04 Feb 2023 08:26:01 +0000 Resent-Message-ID: <handler.61241.B61241.167549913029368 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN>, Po Lu <luangruo@HIDDEN> Cc: 61241 <at> debbugs.gnu.org Received: via spool by 61241-submit <at> debbugs.gnu.org id=B61241.167549913029368 (code B ref 61241); Sat, 04 Feb 2023 08:26:01 +0000 Received: (at 61241) by debbugs.gnu.org; 4 Feb 2023 08:25:30 +0000 Received: from localhost ([127.0.0.1]:40626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pODrW-0007dc-7y for submit <at> debbugs.gnu.org; Sat, 04 Feb 2023 03:25:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:40936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1pODrU-0007dN-67 for 61241 <at> debbugs.gnu.org; Sat, 04 Feb 2023 03:25:28 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1pODrK-0007xT-KF; Sat, 04 Feb 2023 03:25:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=IMLBMPxPD+a82926Ns8H97w5Y0vipT9p36Rd5Havhx4=; b=P8Pxe8ZKIjgtfF6NEV3j gJw4Wt6dczllA8huARVEIR8g4QGt/mP4Ph1Vui3Zs6kIDBBGbZhqLHryzT7lH1wgrkRztlCC2Jn1z BP3B8Pcz7oUquPwnMRW2RUR6zewgbUL+vjSg0oeko5PKQXInUidIB2PsdF4o7aIMB7lhRegPRJwl8 WJmj5xQDgNfupBolQ3kH8i29FqNnZN2cc/mJRP7AtkEMsd8cIwGMNKffW49I7g5jpfrZFYp3XfrEI ytjJKwWmYWtCoRRkUjB9cSqyZL7v6MgIxfU+X9NG1xO7pNhlCou4Hz6/EN6+sb1Ql7vEEW3HTbkJc My0oJWvK9srEKg==; Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <eliz@HIDDEN>) id 1pODr8-0000ct-C6; Sat, 04 Feb 2023 03:25:18 -0500 Date: Sat, 04 Feb 2023 10:25:12 +0200 Message-Id: <831qn5vnvb.fsf@HIDDEN> From: Eli Zaretskii <eliz@HIDDEN> In-Reply-To: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> (adrian@HIDDEN) References: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> MIME-version: 1.0 Content-type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) > From: Adrián Medraño Calvo > <adrian@HIDDEN> > Date: Thu, 2 Feb 2023 23:28:01 +0100 > > 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. > > From e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c Mon Sep 17 00:00:00 2001 > Message-Id: <e16d6ddbfdc4110fbbbcf763cff5a72b0f0df92c.1675376734.git.adrian@HIDDEN> > From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?= > <adrian@HIDDEN> > 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 Po Lu, any comments, or should this go in?
X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Resent-From: Po Lu <luangruo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sat, 04 Feb 2023 08:46:02 +0000 Resent-Message-ID: <handler.61241.B61241.16755003608029 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii <eliz@HIDDEN> Cc: 61241 <at> debbugs.gnu.org, =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Received: via spool by 61241-submit <at> debbugs.gnu.org id=B61241.16755003608029 (code B ref 61241); Sat, 04 Feb 2023 08:46:02 +0000 Received: (at 61241) by debbugs.gnu.org; 4 Feb 2023 08:46:00 +0000 Received: from localhost ([127.0.0.1]:40655 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pOEBM-00025R-Bu for submit <at> debbugs.gnu.org; Sat, 04 Feb 2023 03:46:00 -0500 Received: from sonic316-49.consmr.mail.ne1.yahoo.com ([66.163.187.175]:41591) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <luangruo@HIDDEN>) id 1pOEBJ-000259-Pn for 61241 <at> debbugs.gnu.org; Sat, 04 Feb 2023 03:45:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675500350; bh=FoMFpQSaVpI4rK+MN5/2iVsDcPqMK1pJQ2kqIAzsPDs=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=nEkEWkvYiMV1VRafbJozee0orQrKsgPYFQSRklXImdqmFIh+ZD+wb+McQYxr3NZHR4vhfHyzgc0x2Xv02lmsKdFgPVegsRF35JuM5Hzzulg0kQ9FIPLSPogM2fbdSSk1oX5WOAgRjpfXnj5dLhsWGbs5XOWDyHWalB37tffLxktmAj/vGZwf5RSTb+tPvZaVASsv0KbuWNqsfOYzgWO6jQ2+KV2KWX161tuX6IOtWPPvJwltqoB0Ojq1J1fV59BD3MkHgTqzZYcMyDCoCJ8Aj5w3KkAChS8UDyHAxiSO9DGgxy4oGFpjiL18sM8T8emHQIrwnDoR13f9dMbqL0Xxrg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675500350; bh=RK7k4r29ujDXWOjEVn9kDA3GJdVLSdE3gm+8VjYF76a=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ek+TAt8MJsnX82sK53ie0o1X4rYR/EOXW9sWvHh3JQPf7jRVzLBoqydLwHqvsG0fVsTAtLzC0j0bmdodWMdI8pQDAXgd781eHY7wEUP1u0rp4A74OCLKo5IkFcfJvi44ole9z44DPRulupK9DdBcXOabQlhWUlaAgBlIy2oCIXeUT7k65t4Gf9k/vsHwk4QfCVrAHzCLLNC31mfR2vPtaA2xJqV4IYBxjyR+xXbJSW1G7E3viwZSBXgGyeeVRYxx0UX/AT80VeN2tMfLYkmi5dm5FAiyWgSY/JzZ3ezj7Y3MJDNcq0wXgPqL/Q3lhwygDrQsoka7NxUxnPjUtHSspA== X-YMail-OSG: iNf7ykQVM1lIkeh8Ki_GnxAhaJ.GgGwmcQ8uAu0nSRF9UStI4UKYjln5n4s2LUx b04G1qoxg1KOQm8ZrN5DFSzj4jCMJoxhEPflrfr_dFkQIR4UoR65JHsazI88ICKpDd77zHDXNynf blFnJ6x6Cjodq6k9Rea8V1FaE68rQxHk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sCb22pBcjux9yedCO8IqHb6vne KzZivJtnVOWo- X-Sonic-MF: <luangruo@HIDDEN> Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.ne1.yahoo.com with HTTP; Sat, 4 Feb 2023 08:45:50 +0000 Received: by hermes--production-sg3-9fc5746c8-xxb6k (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID f5c47ba08a3c39f87e5d8cf088747d7d; Sat, 04 Feb 2023 08:43:48 +0000 (UTC) From: Po Lu <luangruo@HIDDEN> In-Reply-To: <831qn5vnvb.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 04 Feb 2023 10:25:12 +0200") References: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> <831qn5vnvb.fsf@HIDDEN> Date: Sat, 04 Feb 2023 16:43:31 +0800 Message-ID: <87zg9t95xo.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.21161 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 2169 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Eli Zaretskii <eliz@HIDDEN> writes: >> From: Adri=C3=A1n Medra=C3=B1o Calvo >> <adrian@HIDDEN> >> Date: Thu, 2 Feb 2023 23:28:01 +0100 >>=20 >> 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=E2=80=99 differs, lea= ding 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. >>=20 >> 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=E2=80=99 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. >>=20 >> The attached patch fixes the issue. Thanks. But first of all, Emacs is not at all prepared to receive both MotionNotify events and XI_Motion events on a frame at the same time in other areas as well, such as focus tracking. This is not possible under an X server. So EXWM should send XI_Motion events when the X server supports XInput 2 (they are Generic Events, and XCB lets you send them, though not Xlib because nobody has written a working event to wire function yet.) Or alternatively, why doesn't exwm just focus the window itself?
X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 References: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> In-Reply-To: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN> Resent-From: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Sun, 05 Feb 2023 19:06:01 +0000 Resent-Message-ID: <handler.61241.B61241.167562390620347 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Po Lu <luangruo@HIDDEN> Cc: 61241 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> Received: via spool by 61241-submit <at> debbugs.gnu.org id=B61241.167562390620347 (code B ref 61241); Sun, 05 Feb 2023 19:06:01 +0000 Received: (at 61241) by debbugs.gnu.org; 5 Feb 2023 19:05:06 +0000 Received: from localhost ([127.0.0.1]:46462 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pOkK2-0005I6-8d for submit <at> debbugs.gnu.org; Sun, 05 Feb 2023 14:05:06 -0500 Received: from mout-p-201.mailbox.org ([80.241.56.171]:43270) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <adrian@HIDDEN>) id 1pOkJz-0005HV-Or for 61241 <at> debbugs.gnu.org; Sun, 05 Feb 2023 14:05:04 -0500 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4P8zNR1KBmz9scb; Sun, 5 Feb 2023 20:04:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=medranocalvo.com; s=MBO0001; t=1675623895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GBimI4n+cxD9ETfPeRbtOp3WfPI9BpFBkL/B5pBeAAA=; b=FipYDGhDwbznLRdji5PV6LnLmwdBb3puCKu6FtQX0uX3pa+rZ0FHP/2/7B+AkblQE/C98M qrwXoWNpvysZnwsYL03eVEt4Vmr2oN+jfTA/Sc+0U3cX4lUbTxuK2198igBjuptFitAyWS 8jtuo3SJEWgRYwuxtggyB2hxXaRkOLsfAXMROMhmiG9mPO4FWDP+BAvClBeSFqja3UEFDd xVYsjeQRChbX7EBTvKww8UEJKqCkMjyLGrNaAoawfs3xF4lsqdaJU7ULAxximg1VU8YIRF oIJiKqCrUhFrqRlR0BvQQiSPwdM5WpDd6x4CGBtFou6YmACxtw4Mc2ngUlzA4w== Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Mime-Version: 1.0 (1.0) Message-Id: <C8F43B70-06CC-4745-9044-524CF8E74F34@HIDDEN> Date: Sun, 5 Feb 2023 20:04:42 +0100 X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) =EF=BB=BF Please see below. > Am 04.02.2023 um 09:45 schrieb Po Lu <luangruo@HIDDEN>: > =EF=BB=BFEli Zaretskii <eliz@HIDDEN> writes: >=20 >>> From: Adri=C3=A1n Medra=C3=B1o Calvo >>> <adrian@HIDDEN> >>> Date: Thu, 2 Feb 2023 23:28:01 +0100 >>> 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=E2=80=99 differs, lea= ding 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=E2=80=99 and the user moves the mouse pointer o= ver one >>> X window managed by EXWM, this X window receives the mouse events and no= t >>> 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. >=20 > Thanks. But first of all, Emacs is not at all prepared to receive both > MotionNotify events and XI_Motion events on a frame at the same time in > other areas as well, such as focus tracking. >=20 > This is not possible under an X server. Thank you. I thought already about fixing this in EXWM by sending the XI_Mot= ion event when Emacs uses XInput 2 (as you propose below), but thought that o= ther users might be in a similar situation. For example, a user using xdotoo= l (I must say that I don't know whether xdotool relies on XInput, XInput 2, X= Test or something else, but for the sake of this example please assume the f= ormer) would observe the same behaviour as us. If I understand correctly, an XInput 2 enabled Emacs must handle regular eve= nts as well because some of its frames might be in terminals supporting only= Xinput 1. If that's the case, would it be possible to drop/reject correspon= ding regular events (e.g. MotionNotifiy) on terminals supporting XInput 2? I= f that's not possible, I=E2=80=99d say it=E2=80=99s better applying the patc= h (or similar) so that, even while unsupported, we do a best effort in reduc= ing inconsistency. > So EXWM should send XI_Motion events when the X server supports XInput 2 > (they are Generic Events, and XCB lets you send them, though not Xlib > because nobody has written a working event to wire function yet.) I'll implement your suggestion in EXWM shortly, in any case before Emacs 29 i= s released. How can I detect whether Emacs uses XInput 2 in a particular ter= minal? > Or alternatively, why doesn't exwm just focus the window itself? (I=E2=80=99m not sure whether I understand your question, please clarify if y= ou think I missed it.) Just focusing the X window (and selecting the related= Emacs window) is not enough for integrating `mouse-autoselect-window', prec= isely because `last_mouse_window' gets out-of-sync, leading to the user bein= g unable to select back the last Emacs window by moving the mouse over it. A= possible solution to this would be to expose `last_mouse_window' to Lisp (e= .g. `mouse-autoselect-last-window'); presumably EXWM could then set its valu= e as part of the above steps and have focus follow the pointer. I=E2=80=99d s= ay this is my preferred solution, what do you think about this?
X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Resent-From: Po Lu <luangruo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Mon, 06 Feb 2023 01:44:01 +0000 Resent-Message-ID: <handler.61241.B61241.167564779012274 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Cc: 61241 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> Received: via spool by 61241-submit <at> debbugs.gnu.org id=B61241.167564779012274 (code B ref 61241); Mon, 06 Feb 2023 01:44:01 +0000 Received: (at 61241) by debbugs.gnu.org; 6 Feb 2023 01:43:10 +0000 Received: from localhost ([127.0.0.1]:46912 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1pOqXF-0003Bu-RJ for submit <at> debbugs.gnu.org; Sun, 05 Feb 2023 20:43:10 -0500 Received: from sonic310-52.consmr.mail.ne1.yahoo.com ([66.163.186.233]:38670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <luangruo@HIDDEN>) id 1pOqXE-0003Bi-AB for 61241 <at> debbugs.gnu.org; Sun, 05 Feb 2023 20:43:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675647782; bh=M3SdR62SISfBFy42BLX/R9+LiwlY7rglf7gGMDbxa+U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=rVuJFgHSlmEIVZGw6piklrv/fk3KMQScMdNenO8aSw8LEVdsPtZEoBu8UjkSbstfSkqwDrEga5C+DrrCT6ug8d+kiTh1lhwrHKi96DLUgVNfzt4QHBpyad3GneE/c/rtooIquazsNdiXYUEekxFLI41I5balFh8/TUTC2UdgEY+/ag0u469sqiRGFgrc6H8GJqF6fMK1hLwi7bUDLDgovLCnV929rt/O7bJudOCXAI/jOUDCKAY9tKsa07J3U6FNMMRmUtGT12+xZzCPCm8gBS9TWbblJRK9F/6//GU88YuFgnYiiDjMHW3p17ping7a5VAuaYl545z7KhWo9bpXSw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1675647782; bh=pugiWmt7D3Dn6n9q+N3XnMrHbDL0+nORimd9sUaX2JH=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=uUplEJVcDYNoulmMP3Pg/wXptYKo0RsI7+SBGz/hTs9TctYGuH9oub2aijC5i/fXldpchnibuv+w9TgL1W5DJU9/eMzPrGxvUpvAMEgv2rJiG56aD0YouYphIl4mj5m5RU5Vw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aYZMA_cxPi_Wlqii QDX8WCM4c0wjrTd3lUur9md073Mf8KFVt5brauWi0G6QaebzIjVOAj0BkNbm7ySrkLJjPyndUjhg zrcxNgl7pC5paDKeNXHO1druhgV08x5ERNq5Q_JK7MOf470ks9zbALstTGWbLChzyYOHir4DMHi6 ZpD6o_Eu582XU_yL78X6Hk9OrOuFQ1XRN5u2LDR0Nv0vpVvsnilnxFJ_9R7NmTZ2QgjvYv7ZXLdg BO8te2wRuNh4MtHA0.12NLHtToCtueIPqvXLP.gnmCHj1IpmejFoP4KPBAZay53GD2qL4Z71bqfD Cs79CAZpWPa2xcMg46M.bhPl8U8kUDZE.kFcnuTYfIPGMBWsZcjFQp61_kfkJ.o470zuGpYwN4ca .9zc- X-Sonic-MF: <luangruo@HIDDEN> Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Mon, 6 Feb 2023 01:43:02 +0000 Received: by hermes--production-sg3-9fc5746c8-ltdwf (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 06bc1d5ec0ef53e786357aa6b0c6aa60; Mon, 06 Feb 2023 01:40:59 +0000 (UTC) From: Po Lu <luangruo@HIDDEN> In-Reply-To: <C8F43B70-06CC-4745-9044-524CF8E74F34@HIDDEN> ("=?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo"'s message of "Sun, 5 Feb 2023 20:04:42 +0100") References: <C8F43B70-06CC-4745-9044-524CF8E74F34@HIDDEN> Date: Mon, 06 Feb 2023 09:40:50 +0800 Message-ID: <87cz6n8tb1.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.21161 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 2431 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Adri=C3=A1n Medra=C3=B1o Calvo <adrian@HIDDEN> writes: > Thank you. I thought already about fixing this in EXWM by sending the > XI_Motion event when Emacs uses XInput 2 (as you propose below), but > thought that other users might be in a similar situation. For example, > a user using xdotool (I must say that I don't know whether xdotool > relies on XInput, XInput 2, XTest or something else, but for the sake > of this example please assume the former) would observe the same > behaviour as us. These tools should use the record or test extensions, which will not have these problems. > If I understand correctly, an XInput 2 enabled Emacs must handle > regular events as well because some of its frames might be in > terminals supporting only Xinput 1. If that's the case, would it be > possible to drop/reject corresponding regular events > (e.g. MotionNotifiy) on terminals supporting XInput 2? If that's not > possible, I=E2=80=99d say it=E2=80=99s better applying the patch (or simi= lar) so that, > even while unsupported, we do a best effort in reducing inconsistency. XInput 1.x is not supported by Emacs. You probably mean the X11 core protocol. It is ok for MotionNotify events to arrive on a display that has not selected for input extension events, since Emacs does not keep track of much state globally across displays. But once they do on a display that has, then a lot can go wrong. > I'll implement your suggestion in EXWM shortly, in any case before > Emacs 29 is released. How can I detect whether Emacs uses XInput 2 in > a particular terminal? The function `x-server-input-extension-version'. > (I=E2=80=99m not sure whether I understand your question, please clarify = if > you think I missed it.) Just focusing the X window (and selecting the > related Emacs window) is not enough for integrating > `mouse-autoselect-window', precisely because `last_mouse_window' gets > out-of-sync, leading to the user being unable to select back the last > Emacs window by moving the mouse over it. A possible solution to this > would be to expose `last_mouse_window' to Lisp > (e.g. `mouse-autoselect-last-window'); presumably EXWM could then set > its value as part of the above steps and have focus follow the > pointer. I=E2=80=99d say this is my preferred solution, what do you think > about this? Sounds reasonable, except it is too late in the Emacs 29 release cycle to implement this there.
X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Resent-From: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 22 Aug 2023 05:47:02 +0000 Resent-Message-ID: <handler.61241.B61241.169268318313176 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Po Lu <luangruo@HIDDEN> Cc: 61241 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> Received: via spool by 61241-submit <at> debbugs.gnu.org id=B61241.169268318313176 (code B ref 61241); Tue, 22 Aug 2023 05:47:02 +0000 Received: (at 61241) by debbugs.gnu.org; 22 Aug 2023 05:46:23 +0000 Received: from localhost ([127.0.0.1]:58316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qYKDe-0003QR-D5 for submit <at> debbugs.gnu.org; Tue, 22 Aug 2023 01:46:22 -0400 Received: from mout-p-101.mailbox.org ([80.241.56.151]:51478) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <adrian@HIDDEN>) id 1qYKDY-0003Py-S5 for 61241 <at> debbugs.gnu.org; Tue, 22 Aug 2023 01:46:20 -0400 Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4RVJHK5qD8z9sSq; Tue, 22 Aug 2023 07:46:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=medranocalvo.com; s=MBO0001; t=1692683165; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=qBUYaK5Oh0dd4yEJzZnYBufeKjwV+OCHpRMYdKXmTMk=; b=mA2nVFTTUxwS5oUZ3lZem4t92IT/o2So9GzIoRQ4l4G6DHAGTi/OXffYBwRuKRmrX0NgpW 7lnc0JNjLgfSS2thJmVeGYAwWofnAWVf4+A7eOb4hdwerC5x+u1pKKJj9y09qmA9eaVH5s 4lwhOQjhtePnmnH49aB9QaJ7+2YMz4+8P+DRvDs9t/PuJPQFVBKCtduN9hhdlO71ArkPAE xlmSkE6KkA6rkHgVNGIbP7+vQ7/I3CN/WU7I3oTt7eGzsr+kJPs2yWihLdTOXYkZnplQlN QiKUDqerYgaxl+zRr/0oMOD4RM0BZAiQxoV+9D6yAgf2TeTFp/Ayf2aNNWHnTw== From: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Message-Id: <E867A8FB-64E8-467C-B02E-DA04BEC4F2E4@HIDDEN> Content-Type: multipart/mixed; boundary="Apple-Mail=_A89BDDC9-8F3E-4A55-B82D-6D39E16121D8" Mime-Version: 1.0 Date: Tue, 22 Aug 2023 07:45:53 +0200 In-Reply-To: <87cz6n8tb1.fsf@HIDDEN> References: <C8F43B70-06CC-4745-9044-524CF8E74F34@HIDDEN> <87cz6n8tb1.fsf@HIDDEN> X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --Apple-Mail=_A89BDDC9-8F3E-4A55-B82D-6D39E16121D8 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Dear Po Lu, > On 6. Feb 2023, at 02:40, Po Lu <luangruo@HIDDEN> wrote: >=20 > Adri=C3=A1n Medra=C3=B1o Calvo <adrian@HIDDEN> writes: >=20 >> Thank you. I thought already about fixing this in EXWM by sending the >> XI_Motion event when Emacs uses XInput 2 (as you propose below), but >> thought that other users might be in a similar situation. For = example, >> a user using xdotool (I must say that I don't know whether xdotool >> relies on XInput, XInput 2, XTest or something else, but for the sake >> of this example please assume the former) would observe the same >> behaviour as us. >=20 > These tools should use the record or test extensions, which will not > have these problems. I=E2=80=99ve tried implementing your suggestion to send an XI_Motion = event to Emacs when the mouse enters the X window managed by EXWM=E2=80=94= to no avail: 1. Using SendEvent: XI2 events are GenericEvents, Xorg disallows sending = GenericEvents within SendEvent. The following seem to be the cause: - = https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/dix/events.c#L55= 17, and especially - = https://gitlab.freedesktop.org/xorg/xserver/-/blob/master/dix/events.c#L55= 41 2. Using XTest: although undocumented (as far as I could see), XTest = does support sending XI device events. The issue is that EXWM wants to, = when entering a managed X window, send XI_Motion events to Emacs as well = so as to trick it into thinking that the pointer entered the Emacs = window corresponding to the mentioned X window; which marks this Emacs = window the last Emacs window the pointer was over. The last think is = critical for focus-follows-mouse to work on EXWM. The obstacle I find = with XTest is that XTest just mimics moving the pointer so, when moving = the pointer to an X window and then using XTest to simulate moving the = pointer there (again), nothing changes: the XI_Motion events are again = sent to this topmost X Window. I couldn=E2=80=99t think of a way of = having the XTest events lead to XI_Motion reaching Emacs in such a = situation.=20 3. I also tried using XWrapPointer which of course does not help as it = generates no motion events. Can you think of a way forward? >> If I understand correctly, an XInput 2 enabled Emacs must handle >> regular events as well because some of its frames might be in >> terminals supporting only Xinput 1. If that's the case, would it be >> possible to drop/reject corresponding regular events >> (e.g. MotionNotifiy) on terminals supporting XInput 2? If that's not >> possible, I=E2=80=99d say it=E2=80=99s better applying the patch (or = similar) so that, >> even while unsupported, we do a best effort in reducing = inconsistency. >=20 > XInput 1.x is not supported by Emacs. You probably mean the X11 core > protocol. >=20 > It is ok for MotionNotify events to arrive on a display that has not > selected for input extension events, since Emacs does not keep track = of > much state globally across displays. >=20 > But once they do on a display that has, then a lot can go wrong. >=20 >> I'll implement your suggestion in EXWM shortly, in any case before >> Emacs 29 is released. How can I detect whether Emacs uses XInput 2 in >> a particular terminal? >=20 > The function `x-server-input-extension-version'. >=20 >> (I=E2=80=99m not sure whether I understand your question, please = clarify if >> you think I missed it.) Just focusing the X window (and selecting the >> related Emacs window) is not enough for integrating >> `mouse-autoselect-window', precisely because `last_mouse_window' gets >> out-of-sync, leading to the user being unable to select back the last >> Emacs window by moving the mouse over it. A possible solution to this >> would be to expose `last_mouse_window' to Lisp >> (e.g. `mouse-autoselect-last-window'); presumably EXWM could then set >> its value as part of the above steps and have focus follow the >> pointer. I=E2=80=99d say this is my preferred solution, what do you = think >> about this? >=20 > Sounds reasonable, except it is too late in the Emacs 29 release cycle > to implement this there. I prepared a patch (attached below) introducing a new lisp variable = holding the last "mouse-autoselected=E2=80=9D window. With this patch = EXWM can simply select the Emacs window corresponding to the managed X = window and set it as last =E2=80=9Cmouse-autoselected=E2=80=9D 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=E2=80=99 is enabled and emacs runs in different = terminals, =E2=80=9Cmouse-autoselecting=E2=80=9D a window on a terminal = changes the last =E2=80=9Cmouse-autoselected=E2=80=9D window for all = other terminals. Slightly moving the mouse in a different terminal = (within a single Emacs window) will =E2=80=9Cmouse-autoselect=E2=80=9D = that window, whereas that would not have been the case before this = patch, as the last =E2=80=9Cmouse-autoselected=E2=80=9D window was = terminal-specific. It=E2=80=99s 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 =E2=80=9Cmouse-autoselected=E2=80=9D = window for Motion and XI_Motion events (other terminals were not = affected). Please let me know your thoughts. Regards, Adri=C3=A1n. --Apple-Mail=_A89BDDC9-8F3E-4A55-B82D-6D39E16121D8 Content-Disposition: attachment; filename=0001-Expose-last-window-under-pointer-to-Lisp.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Expose-last-window-under-pointer-to-Lisp.patch" Content-Transfer-Encoding: quoted-printable =46rom=20d845f06a8155a35fe93769e600b79b951f723863=20Mon=20Sep=2017=20= 00:00:00=202001=0AMessage-ID:=20= <d845f06a8155a35fe93769e600b79b951f723863.1692630504.git.adrian@medranocal= vo.com>=0AFrom:=20=3D?UTF-8?q?Adri=3DC3=3DA1n=3D20Medra=3DC3=3DB1o=3D20Cal= vo?=3D=0A=20<adrian@HIDDEN>=0ADate:=20Tue,=2015=20Aug=202023=20= 00:00:00=20+0000=0ASubject:=20[PATCH]=20Expose=20last=20window=20under=20= pointer=20to=20Lisp=0A=0A*=20src/xdisp.c=20(syms_of_xdisp):=20Add=20= defvar=0A`Vmouse_autoselect_window_last_window'.=0A*=20src/haikuterm.c=20= (haiku_read_socket):=0A*=20src/msdos.c=20(dos_rawgetc):=0A*=20= src/nsterm.m=20([EmacsView=20mouseMoved:]):=0A*=20src/pgtkterm.c=20= (motion_notify_event):=0A*=20src/w32inevt.c=20(do_mouse_event):=0A*=20= src/w32term.c=20(w32_read_socket):=0A*=20src/xterm.c=20= (handle_one_xevent):=20Use=20it=20replacing=20static=0A= `last_mouse_window'.=0A=0A*=20lisp/window.el=20= (mouse-autoselect-window-window)=0A= (mouse-autoselect-window-previous-window):=20Rename=20variable.=0A---=0A=20= lisp/window.el=20=20|=20=208=20+++++---=0A=20src/haikuterm.c=20|=20=205=20= ++---=0A=20src/msdos.c=20=20=20=20=20|=20=206=20++----=0A=20src/nsterm.m=20= =20=20=20|=20=205=20++---=0A=20src/pgtkterm.c=20=20|=20=205=20++---=0A=20= src/w32inevt.c=20=20|=20=207=20++-----=0A=20src/w32term.c=20=20=20|=20=20= 5=20++---=0A=20src/xdisp.c=20=20=20=20=20|=20=207=20+++++++=0A=20= src/xterm.c=20=20=20=20=20|=2011=20++++-------=0A=209=20files=20changed,=20= 28=20insertions(+),=2031=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/window.el=20b/lisp/window.el=0Aindex=2016f16a75418..b2677ea99f3=20= 100644=0A---=20a/lisp/window.el=0A+++=20b/lisp/window.el=0A@@=20-10391,8=20= +10391,10=20@@=20mouse-autoselect-window-position-1=0A=20(defvar=20= mouse-autoselect-window-position=20nil=0A=20=20=20"Last=20mouse=20= position=20recorded=20by=20delayed=20window=20autoselection.")=0A=20=0A= -(defvar=20mouse-autoselect-window-window=20nil=0A+(defvar=20= mouse-autoselect-window-previous-window=20nil=0A=20=20=20"Last=20window=20= recorded=20by=20delayed=20window=20autoselection.")=0A= +(define-obsolete-variable-alias=20'mouse-autoselect-window-window=0A+=20= =20'mouse-autoselect-window-previous-window=20"29.1")=0A=20=0A=20(defvar=20= mouse-autoselect-window-state=20nil=0A=20=20=20"When=20non-nil,=20= special=20state=20of=20delayed=20window=20autoselection.=0A@@=20-10425,7=20= +10427,7=20@@=20mouse-autoselect-window-start=0A=20means=20suspend=20= autoselection."=0A=20=20=20;;=20Record=20values=20for=20MOUSE-POSITION,=20= WINDOW,=20and=20SUSPEND.=0A=20=20=20(setq=20= mouse-autoselect-window-position=20mouse-position)=0A-=20=20(when=20= window=20(setq=20mouse-autoselect-window-window=20window))=0A+=20=20= (when=20window=20(setq=20mouse-autoselect-window-previous-window=20= window))=0A=20=20=20(setq=20mouse-autoselect-window-state=20(when=20= suspend=20'suspend))=0A=20=20=20;;=20Install=20timer=20which=20runs=20= `mouse-autoselect-window-select'=20after=0A=20=20=20;;=20= `mouse-autoselect-window'=20seconds.=0A@@=20-10473,7=20+10475,7=20@@=20= mouse-autoselect-window-select=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(and=20(>=3D=20mouse-autoselect-window=200)=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20If=20= `mouse-autoselect-window'=20is=20non-negative,=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20;;=20select=20window=20if=20it's=20= the=20same=20as=20before.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20(eq=20window=20mouse-autoselect-window-window))=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(eq=20window=20= mouse-autoselect-window-previous-window))=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20;;=20Otherwise=20select=20window=20iff=20the=20mouse=20= is=20at=20the=20same=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= ;;=20position=20as=20before.=20=20Observe=20that=20the=20first=20test=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20after=20starting=20= autoselection=20usually=20fails=20since=20the=0Adiff=20--git=20= a/src/haikuterm.c=20b/src/haikuterm.c=0Aindex=208733b82fb2b..8341fd4cc53=20= 100644=0A---=20a/src/haikuterm.c=0A+++=20b/src/haikuterm.c=0A@@=20= -3471,11=20+3471,10=20@@=20haiku_read_socket=20(struct=20terminal=20= *terminal,=20struct=20input_event=20*hold_quit)=0A=20=0A=20=09=09if=20= (!NILP=20(Vmouse_autoselect_window))=0A=20=09=09=20=20{=0A-=09=09=20=20=20= =20static=20Lisp_Object=20last_mouse_window;=0A=20=09=09=20=20=20=20= Lisp_Object=20window=20=3D=20window_from_coordinates=20(f,=20b->x,=20= b->y,=200,=200,=200);=0A=20=0A=20=09=09=20=20=20=20if=20(WINDOWP=20= (window)=0A-=09=09=09&&=20!EQ=20(window,=20last_mouse_window)=0A+=09=09=09= &&=20!EQ=20(window,=20Vmouse_autoselect_window_last_window)=0A=20=09=09=09= &&=20!EQ=20(window,=20selected_window)=0A=20=09=09=09&&=20= !popup_activated_p=0A=20=09=09=09&&=20!MINI_WINDOW_P=20(XWINDOW=20= (selected_window))=0A@@=20-3486,7=20+3485,7=20@@=20haiku_read_socket=20= (struct=20terminal=20*terminal,=20struct=20input_event=20*hold_quit)=0A=20= =09=09=09inev2.frame_or_window=20=3D=20window;=0A=20=09=09=20=20=20=20=20= =20}=0A=20=0A-=09=09=20=20=20=20last_mouse_window=20=3D=20window;=0A+=09=09= =20=20=20=20Vmouse_autoselect_window_last_window=20=3D=20window;=0A=20=09= =09=20=20}=0A=20=0A=20=09=09if=20(f->auto_raise)=0Adiff=20--git=20= a/src/msdos.c=20b/src/msdos.c=0Aindex=2075a39045cee..333fd9d59e6=20= 100644=0A---=20a/src/msdos.c=0A+++=20b/src/msdos.c=0A@@=20-2652,8=20= +2652,6=20@@=20dos_rawgetc=20(void)=0A=20=09=20=20/*=20Generate=20= SELECT_WINDOW_EVENTs=20when=20needed.=20=20*/=0A=20=09=20=20if=20(!NILP=20= (Vmouse_autoselect_window))=0A=20=09=20=20=20=20{=0A-=09=20=20=20=20=20=20= static=20Lisp_Object=20last_mouse_window;=0A-=0A=20=09=20=20=20=20=20=20= mouse_window=20=3D=20window_from_coordinates=0A=20=09=09(SELECTED_FRAME=20= (),=20mouse_last_x,=20mouse_last_y,=200,=200,=200);=0A=20=09=20=20=20=20=20= =20/*=20A=20window=20will=20be=20selected=20only=20when=20it=20is=20not=0A= @@=20-2661,7=20+2659,7=20@@=20dos_rawgetc=20(void)=0A=20=09=09=20not=20= in=20it.=20=20A=20minibuffer=20window=20will=20be=20selected=20iff=0A=20=09= =09=20it=20is=20active.=20=20*/=0A=20=09=20=20=20=20=20=20if=20(WINDOWP=20= (mouse_window)=0A-=09=09=20=20&&=20!EQ=20(mouse_window,=20= last_mouse_window)=0A+=09=09=20=20&&=20!EQ=20(mouse_window,=20= Vmouse_autoselect_window_last_window)=0A=20=09=09=20=20&&=20!EQ=20= (mouse_window,=20selected_window))=0A=20=09=09{=0A=20=09=09=20=20= event.kind=20=3D=20SELECT_WINDOW_EVENT;=0A@@=20-2671,7=20+2669,7=20@@=20= dos_rawgetc=20(void)=0A=20=09=09=20=20kbd_buffer_store_event=20(&event);=0A= =20=09=09}=0A=20=09=20=20=20=20=20=20/*=20Remember=20the=20last=20window=20= where=20we=20saw=20the=20mouse.=20=20*/=0A-=09=20=20=20=20=20=20= last_mouse_window=20=3D=20mouse_window;=0A+=09=20=20=20=20=20=20= Vmouse_autoselect_window_last_window=20=3D=20mouse_window;=0A=20=09=20=20= =20=20}=0A=20=0A=20=09=20=20previous_help_echo_string=20=3D=20= help_echo_string;=0Adiff=20--git=20a/src/nsterm.m=20b/src/nsterm.m=0A= index=20c809c0b824a..060898bb842=20100644=0A---=20a/src/nsterm.m=0A+++=20= b/src/nsterm.m=0A@@=20-7530,12=20+7530,11=20@@=20-=20(void)mouseMoved:=20= (NSEvent=20*)e=0A=20=20=20if=20(!NILP=20(Vmouse_autoselect_window))=0A=20= =20=20=20=20{=0A=20=20=20=20=20=20=20NSTRACE_MSG=20= ("mouse_autoselect_window");=0A-=20=20=20=20=20=20static=20Lisp_Object=20= last_mouse_window;=0A=20=20=20=20=20=20=20Lisp_Object=20window=0A=20=09=3D= =20window_from_coordinates=20(emacsframe,=20pt.x,=20pt.y,=200,=200,=20= 0);=0A=20=0A=20=20=20=20=20=20=20if=20(WINDOWP=20(window)=0A-=20=20=20=20= =20=20=20=20=20=20&&=20!EQ=20(window,=20last_mouse_window)=0A+=20=20=20=20= =20=20=20=20=20=20&&=20!EQ=20(window,=20= Vmouse_autoselect_window_last_window)=0A=20=20=20=20=20=20=20=20=20=20=20= &&=20!EQ=20(window,=20selected_window)=0A=20=09=20=20&&=20!MINI_WINDOW_P=20= (XWINDOW=20(selected_window))=0A=20=20=20=20=20=20=20=20=20=20=20&&=20= (!NILP=20(focus_follows_mouse)=0A@@=20-7548,7=20+7547,7=20@@=20-=20= (void)mouseMoved:=20(NSEvent=20*)e=0A=20=20=20=20=20=20=20=20=20=20=20= EV_TRAILER2=20(e);=0A=20=20=20=20=20=20=20=20=20}=0A=20=20=20=20=20=20=20= /*=20Remember=20the=20last=20window=20where=20we=20saw=20the=20mouse.=20=20= */=0A-=20=20=20=20=20=20last_mouse_window=20=3D=20window;=0A+=20=20=20=20= =20=20Vmouse_autoselect_window_last_window=20=3D=20window;=0A=20=20=20=20= =20}=0A=20=0A=20=20=20dragging=20=3D=20(e.type=20=3D=3D=20= NSEventTypeLeftMouseDragged);=0Adiff=20--git=20a/src/pgtkterm.c=20= b/src/pgtkterm.c=0Aindex=20e767e15cc07..b343bd99fbe=20100644=0A---=20= a/src/pgtkterm.c=0A+++=20b/src/pgtkterm.c=0A@@=20-5889,7=20+5889,6=20@@=20= motion_notify_event=20(GtkWidget=20*widget,=20GdkEvent=20*event,=0A=20=09= =20=20=20=20=20also=20when=20the=20target=20window=20is=20on=20another=20= frame.=20=20*/=0A=20=09=20=20&&=20(f=20=3D=3D=20XFRAME=20= (selected_frame)=20||=20!NILP=20(focus_follows_mouse)))=0A=20=09{=0A-=09=20= =20static=20Lisp_Object=20last_mouse_window;=0A=20=09=20=20Lisp_Object=20= window=20=3D=20window_from_coordinates=0A=20=09=20=20=20=20(f,=20= event->motion.x,=20event->motion.y,=200,=20false,=20false);=0A=20=0A@@=20= -5902,7=20+5901,7=20@@=20motion_notify_event=20(GtkWidget=20*widget,=20= GdkEvent=20*event,=0A=20=09=20=20=20=20=20autoselection=20the=20window=20= is=20usually=20the=20window's=20text=0A=20=09=20=20=20=20=20area=20= including=20the=20margins.=20=20*/=0A=20=09=20=20if=20(WINDOWP=20= (window)=0A-=09=20=20=20=20=20=20&&=20!EQ=20(window,=20= last_mouse_window)=0A+=09=20=20=20=20=20=20&&=20!EQ=20(window,=20= Vmouse_autoselect_window_last_window)=0A=20=09=20=20=20=20=20=20&&=20!EQ=20= (window,=20selected_window))=0A=20=09=20=20=20=20{=0A=20=09=20=20=20=20=20= =20inev.ie.kind=20=3D=20SELECT_WINDOW_EVENT;=0A@@=20-5910,7=20+5909,7=20= @@=20motion_notify_event=20(GtkWidget=20*widget,=20GdkEvent=20*event,=0A=20= =09=20=20=20=20}=0A=20=0A=20=09=20=20/*=20Remember=20the=20last=20window=20= where=20we=20saw=20the=20mouse.=20=20*/=0A-=09=20=20last_mouse_window=20= =3D=20window;=0A+=09=20=20Vmouse_autoselect_window_last_window=20=3D=20= window;=0A=20=09}=0A=20=0A=20=20=20=20=20=20=20if=20= (!note_mouse_movement=20(f,=20&event->motion))=0Adiff=20--git=20= a/src/w32inevt.c=20b/src/w32inevt.c=0Aindex=2029717954cfd..c800291c2f8=20= 100644=0A---=20a/src/w32inevt.c=0A+++=20b/src/w32inevt.c=0A@@=20-467,7=20= +467,6=20@@=20do_mouse_event=20(MOUSE_EVENT_RECORD=20*event,=0A=20=09=09= struct=20input_event=20*emacs_ev)=0A=20{=0A=20=20=20static=20DWORD=20= button_state=20=3D=200;=0A-=20=20static=20Lisp_Object=20= last_mouse_window;=0A=20=20=20DWORD=20but_change,=20mask,=20flags=20=3D=20= event->dwEventFlags;=0A=20=20=20int=20i;=0A=20=0A@@=20-502,7=20+501,7=20= @@=20do_mouse_event=20(MOUSE_EVENT_RECORD=20*event,=0A=20=09=09=20=20=20= not=20in=20it.=20=20A=20minibuffer=20window=20will=20be=20selected=20iff=0A= =20=09=09=20=20=20it=20is=20active.=20=20*/=0A=20=09=09if=20(WINDOWP=20= (mouse_window)=0A-=09=09=20=20=20=20&&=20!EQ=20(mouse_window,=20= last_mouse_window)=0A+=09=09=20=20=20=20&&=20!EQ=20(mouse_window,=20= Vmouse_autoselect_window_last_window)=0A=20=09=09=20=20=20=20&&=20!EQ=20= (mouse_window,=20selected_window))=0A=20=09=09=20=20{=0A=20=09=09=20=20=20= =20struct=20input_event=20event;=0A@@=20-514,10=20+513,8=20@@=20= do_mouse_event=20(MOUSE_EVENT_RECORD=20*event,=0A=20=09=09=20=20=20=20= event.timestamp=20=3D=20movement_time;=0A=20=09=09=20=20=20=20= kbd_buffer_store_event=20(&event);=0A=20=09=09=20=20}=0A-=09=09= last_mouse_window=20=3D=20mouse_window;=0A+=09=09= Vmouse_autoselect_window_last_window=20=3D=20mouse_window;=0A=20=09=20=20= =20=20=20=20}=0A-=09=20=20=20=20else=0A-=09=20=20=20=20=20=20= last_mouse_window=20=3D=20Qnil;=0A=20=0A=20=09=20=20=20=20= previous_help_echo_string=20=3D=20help_echo_string;=0A=20=09=20=20=20=20= help_echo_string=20=3D=20help_echo_object=20=3D=20help_echo_window=20=3D=20= Qnil;=0Adiff=20--git=20a/src/w32term.c=20b/src/w32term.c=0Aindex=20= 2899e82b295..f9d86637024=20100644=0A---=20a/src/w32term.c=0A+++=20= b/src/w32term.c=0A@@=20-5333,7=20+5333,6=20@@=20w32_read_socket=20= (struct=20terminal=20*terminal,=0A=20=09=09=20=20=20=20=20=20||=20(!NILP=20= (focus_follows_mouse)=0A=20=09=09=09=20=20&&=20!FRAME_NO_ACCEPT_FOCUS=20= (f))))=0A=20=09=09{=0A-=09=09=20=20static=20Lisp_Object=20= last_mouse_window;=0A=20=09=09=20=20Lisp_Object=20window=20=3D=20= window_from_coordinates=0A=20=09=09=20=20=20=20(f,=20LOWORD=20= (msg.msg.lParam),=20HIWORD=20(msg.msg.lParam),=200,=200,=200);=0A=20=0A= @@=20-5342,7=20+5341,7=20@@=20w32_read_socket=20(struct=20terminal=20= *terminal,=0A=20=09=09=20=20=20=20=20not=20in=20it.=20=20Minibuffer=20= window=20will=20be=20selected=0A=20=09=09=20=20=20=20=20only=20when=20it=20= is=20active.=20=20*/=0A=20=09=09=20=20if=20(WINDOWP=20(window)=0A-=09=09=20= =20=20=20=20=20&&=20!EQ=20(window,=20last_mouse_window)=0A+=09=09=20=20=20= =20=20=20&&=20!EQ=20(window,=20Vmouse_autoselect_window_last_window)=0A=20= =09=09=20=20=20=20=20=20&&=20!EQ=20(window,=20selected_window))=0A=20=09=09= =20=20=20=20{=0A=20=09=09=20=20=20=20=20=20inev.kind=20=3D=20= SELECT_WINDOW_EVENT;=0A@@=20-5350,7=20+5349,7=20@@=20w32_read_socket=20= (struct=20terminal=20*terminal,=0A=20=09=09=20=20=20=20}=0A=20=0A=20=09=09= =20=20/*=20Remember=20the=20last=20window=20where=20we=20saw=20the=20= mouse.=20=20*/=0A-=09=09=20=20last_mouse_window=20=3D=20window;=0A+=09=09= =20=20Vmouse_autoselect_window_last_window=20=3D=20window;=0A=20=09=09}=0A= =20=0A=20=09=20=20=20=20=20=20if=20(!w32_note_mouse_movement=20(f,=20= &msg.msg))=0Adiff=20--git=20a/src/xdisp.c=20b/src/xdisp.c=0Aindex=20= 9cddcfeda27..dc0cbb658f6=20100644=0A---=20a/src/xdisp.c=0A+++=20= b/src/xdisp.c=0A@@=20-36854,6=20+36854,13=20@@=20syms_of_xdisp=20(void)=0A= =20of=20your=20window=20manager.=20=20*/);=0A=20=20=20= Vmouse_autoselect_window=20=3D=20Qnil;=0A=20=0A+=20=20DEFVAR_LISP=20= ("mouse-autoselect-window-last-window",=0A+=09=20=20=20=20=20=20=20= Vmouse_autoselect_window_last_window,=0A+=20=20=20=20doc:=20/*=20Last=20= window=20entered=20by=20the=20the=20mouse=20pointer.=0A+This=20variable=20= is=20tracked=20only=20when=20both=20`mouse-autoselect-window'=20and=0A= +`focus-follows-mouse'=20are=20non-nil.=20*/);=0A+=20=20= Vmouse_autoselect_window_last_window=20=3D=20Qnil;=0A+=0A=20=20=20= DEFVAR_LISP=20("auto-resize-tab-bars",=20Vauto_resize_tab_bars,=0A=20=20=20= =20=20doc:=20/*=20Non-nil=20means=20automatically=20resize=20tab-bars.=0A= =20This=20dynamically=20changes=20the=20tab-bar's=20height=20to=20the=20= minimum=20height=0Adiff=20--git=20a/src/xterm.c=20b/src/xterm.c=0Aindex=20= 5840b15bcb7..36ba3103a70=20100644=0A---=20a/src/xterm.c=0A+++=20= b/src/xterm.c=0A@@=20-20681,8=20+20681,6=20@@=20handle_one_xevent=20= (struct=20x_display_info=20*dpyinfo,=0A=20=09=09&&=20(f=20=3D=3D=20= XFRAME=20(selected_frame)=0A=20=09=09=20=20=20=20||=20!NILP=20= (focus_follows_mouse)))=0A=20=09=20=20=20=20=20=20{=0A-=09=09static=20= Lisp_Object=20last_mouse_window;=0A-=0A=20=09=09if=20(xmotion.window=20= !=3D=20FRAME_X_WINDOW=20(f))=0A=20=09=09=20=20{=0A=20=09=09=20=20=20=20= x_translate_coordinates=20(f,=20xmotion.x_root,=20xmotion.y_root,=0A@@=20= -20702,7=20+20700,7=20@@=20handle_one_xevent=20(struct=20x_display_info=20= *dpyinfo,=0A=20=09=09=20=20=20autoselection=20the=20window=20is=20= usually=20the=20window's=20text=0A=20=09=09=20=20=20area=20including=20= the=20margins.=20=20*/=0A=20=09=09if=20(WINDOWP=20(window)=0A-=09=09=20=20= =20=20&&=20!EQ=20(window,=20last_mouse_window)=0A+=09=09=20=20=20=20&&=20= !EQ=20(window,=20Vmouse_autoselect_window_last_window)=0A=20=09=09=20=20=20= =20&&=20!EQ=20(window,=20selected_window))=0A=20=09=09=20=20{=0A=20=09=09= =20=20=20=20inev.ie.kind=20=3D=20SELECT_WINDOW_EVENT;=0A@@=20-20710,7=20= +20708,7=20@@=20handle_one_xevent=20(struct=20x_display_info=20*dpyinfo,=0A= =20=09=09=20=20}=0A=20=0A=20=09=09/*=20Remember=20the=20last=20window=20= where=20we=20saw=20the=20mouse.=20=20*/=0A-=09=09last_mouse_window=20=3D=20= window;=0A+=09=09Vmouse_autoselect_window_last_window=20=3D=20window;=0A=20= =09=20=20=20=20=20=20}=0A=20=0A=20=20=20=20=20=20=20=20=20=20=20=20=20if=20= (!x_note_mouse_movement=20(f,=20&xmotion,=20Qnil))=0A@@=20-22593,7=20= +22591,6=20@@=20handle_one_xevent=20(struct=20x_display_info=20*dpyinfo,=0A= =20=09=09=20=20=20=20=20=20&&=20(f=20=3D=3D=20XFRAME=20(selected_frame)=0A= =20=09=09=09=20=20||=20!NILP=20(focus_follows_mouse)))=0A=20=09=09=20=20=20= =20{=0A-=09=09=20=20=20=20=20=20static=20Lisp_Object=20= last_mouse_window;=0A=20=09=09=20=20=20=20=20=20Lisp_Object=20window=20=3D= =20window_from_coordinates=20(f,=20ev.x,=20ev.y,=200,=20false,=20false);=0A= =20=0A=20=09=09=20=20=20=20=20=20/*=20A=20window=20will=20be=20= autoselected=20only=20when=20it=20is=20not=0A@@=20-22605,7=20+22602,7=20= @@=20handle_one_xevent=20(struct=20x_display_info=20*dpyinfo,=0A=20=09=09= =09=20autoselection=20the=20window=20is=20usually=20the=20window's=20= text=0A=20=09=09=09=20area=20including=20the=20margins.=20=20*/=0A=20=09=09= =20=20=20=20=20=20if=20(WINDOWP=20(window)=0A-=09=09=09=20=20&&=20!EQ=20= (window,=20last_mouse_window)=0A+=09=09=09=20=20&&=20!EQ=20(window,=20= Vmouse_autoselect_window_last_window)=0A=20=09=09=09=20=20&&=20!EQ=20= (window,=20selected_window))=0A=20=09=09=09{=0A=20=09=09=09=20=20= inev.ie.kind=20=3D=20SELECT_WINDOW_EVENT;=0A@@=20-22616,7=20+22613,7=20= @@=20handle_one_xevent=20(struct=20x_display_info=20*dpyinfo,=0A=20=09=09= =09}=0A=20=0A=20=09=09=20=20=20=20=20=20/*=20Remember=20the=20last=20= window=20where=20we=20saw=20the=20mouse.=20=20*/=0A-=09=09=20=20=20=20=20= =20last_mouse_window=20=3D=20window;=0A+=09=09=20=20=20=20=20=20= Vmouse_autoselect_window_last_window=20=3D=20window;=0A=20=09=09=20=20=20= =20}=0A=20=0A=20=09=09=20=20if=20(!x_note_mouse_movement=20(f,=20&ev,=20= source=20?=20source->name=20:=20Qnil))=0A--=20=0A2.41.0=0A=0A= --Apple-Mail=_A89BDDC9-8F3E-4A55-B82D-6D39E16121D8--
X-Loop: help-debbugs@HIDDEN Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Resent-From: Po Lu <luangruo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: bug-gnu-emacs@HIDDEN Resent-Date: Tue, 22 Aug 2023 07:00:01 +0000 Resent-Message-ID: <handler.61241.B61241.169268756421549 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo <adrian@HIDDEN> Cc: 61241 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN> Received: via spool by 61241-submit <at> debbugs.gnu.org id=B61241.169268756421549 (code B ref 61241); Tue, 22 Aug 2023 07:00:01 +0000 Received: (at 61241) by debbugs.gnu.org; 22 Aug 2023 06:59:24 +0000 Received: from localhost ([127.0.0.1]:58436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1qYLMJ-0005bU-MH for submit <at> debbugs.gnu.org; Tue, 22 Aug 2023 02:59:23 -0400 Received: from sonic313-10.consmr.mail.ne1.yahoo.com ([66.163.185.33]:35202) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <luangruo@HIDDEN>) id 1qYLMH-0005bD-56 for 61241 <at> debbugs.gnu.org; Tue, 22 Aug 2023 02:59:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1692687552; bh=Cp++GIWQ9YayqjTSeaT0fcrOVLhGDUDGAT8D1v2mNqU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To; b=HFSPVfWd8UWF/QM2zQwMVsEV9vqVc9bnCEeRrbZCuLn+/U8PHDxuDd6L/vcDEwRU7cCzmdsZo0/8VerZG3rXAZMaukkMUFTr5fX8d6YHM2dqELq71NNVLiXWBt92coz2jDnKyw97oo/UKPCMp3Wb2Cw7YNhDwlsIzdVr9EEpmkoT76JWAHq1YwNzkoIcHu923lzCI0y/Ujs6LnKKZQ+DSYjBwa+UG0Fl/p7FAOmnLz7pB5stLJcksog8fvdXhwZDar/QXgaYn2tv2tXHSNIMiU19y8ZlDRDB+xIpVKmKzSVmLU0p7Ez/QgbaTnU8dvSETNFqkCScjs0XFdqw4xoW5A== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1692687552; bh=4kUtHh/qEMQ+IbXaHQ77D5OTJWejojSt/APJ2ryrnag=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=n91D2OjIAhgPu07gCcMBgg4Lv/0micCCCj0svg1gx68puiYjpcsMOUrBXX/rLtlQVED+MjqgncnH9mu/vDRahxRY0VH73M9kve2Qcwx7yJW8yF5zOaRPVs8ZcwzCWYAc/6XyoyYG0Ogn8d4IC2BVTUGy4DZaSXkKsQWjB7m/xpsNBfnzAo+RxN07Jxw0DS2KPU0R2nT+hW5ytVdRXvKLhoCbEeEMeqMk0043PhBGVhzg01brC3hqX9mFSUJPnE9RkIvIK8gQ1ZjztlSFl48/Yx64Ia0wUEuB9Hqe26pbrvASfLo1chnkeivYYpDSx5VP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rsE4_MTYiJQdo0PGIrn9IDMld7IaYF7UW8p.7gaqT2FW9jQ.y.JAF7rYKHgN.ZLEJbtYT3L3u OfzvE2A3itAm0ld3krxmYW1HFXhBCwOHWezjNBC8Tq7fGw0A8ECQ7qb2BJNGFgV1RGGQEHq1SFud KNBF8h87JO_SEvTiKkvvwIwYLqHZUU86DXcjc6MMg0YSzQL2nN85WHVj2OEPnr.sow0BXp4w- X-Sonic-MF: <luangruo@HIDDEN> X-Sonic-ID: 26765c9f-83a9-45ca-aebe-545b64a604b1 Received: from sonic.gate.mail.ne1.yahoo.com by sonic313.consmr.mail.ne1.yahoo.com with HTTP; Tue, 22 Aug 2023 06:59:12 +0000 Received: by hermes--production-sg3-69654d8bd-gltbk (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 890266537ffbdcdf1f91171a06dbb85a; Tue, 22 Aug 2023 06:59:05 +0000 (UTC) From: Po Lu <luangruo@HIDDEN> In-Reply-To: <E867A8FB-64E8-467C-B02E-DA04BEC4F2E4@HIDDEN> ("=?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo"'s message of "Tue, 22 Aug 2023 07:45:53 +0200") References: <C8F43B70-06CC-4745-9044-524CF8E74F34@HIDDEN> <87cz6n8tb1.fsf@HIDDEN> <E867A8FB-64E8-467C-B02E-DA04BEC4F2E4@HIDDEN> Date: Tue, 22 Aug 2023 14:59:00 +0800 Message-ID: <87msyj8swb.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Mailer: WebService/1.1.21732 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo Content-Length: 2028 X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Adri=C3=A1n Medra=C3=B1o Calvo <adrian@HIDDEN> writes: > I prepared a patch (attached below) introducing a new lisp variable > holding the last "mouse-autoselected=E2=80=9D window. With this patch EX= WM > can simply select the Emacs window corresponding to the managed X > window and set it as last =E2=80=9Cmouse-autoselected=E2=80=9D 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=E2=80=99 is enabled and emacs runs in different > terminals, =E2=80=9Cmouse-autoselecting=E2=80=9D a window on a terminal c= hanges the > last =E2=80=9Cmouse-autoselected=E2=80=9D window for all other terminals.= Slightly > moving the mouse in a different terminal (within a single Emacs > window) will =E2=80=9Cmouse-autoselect=E2=80=9D that window, whereas that= would not > have been the case before this patch, as the last =E2=80=9Cmouse-autosele= cted=E2=80=9D > window was terminal-specific. It=E2=80=99s 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 =E2=80=9Cmouse-autoselec= ted=E2=80=9D > 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.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.