From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2 Date: Sat, 04 Feb 2023 10:25:12 +0200 Message-ID: <831qn5vnvb.fsf@gnu.org> References: <16B04B25-8EB8-4967-947B-C03DF3690ADF@medranocalvo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19378"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61241@debbugs.gnu.org To: =?UTF-8?Q?Adri=C3=A1n_?= =?UTF-8?Q?Medra=C3=B1o?= Calvo , Po Lu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Feb 04 09:26:10 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pODsA-0004t7-CC for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 04 Feb 2023 09:26:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pODs4-0001NM-MP; Sat, 04 Feb 2023 03:26:05 -0500 Original-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 ) id 1pODs2-0001N5-Gn for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2023 03:26:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pODs2-00083Z-4C for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2023 03:26:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pODs1-0007eO-VT for bug-gnu-emacs@gnu.org; Sat, 04 Feb 2023 03:26:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Feb 2023 08:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61241 X-GNU-PR-Package: emacs Original-Received: via spool by 61241-submit@debbugs.gnu.org id=B61241.167549913029368 (code B ref 61241); Sat, 04 Feb 2023 08:26:01 +0000 Original-Received: (at 61241) by debbugs.gnu.org; 4 Feb 2023 08:25:30 +0000 Original-Received: from localhost ([127.0.0.1]:40626 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pODrW-0007dc-7y for submit@debbugs.gnu.org; Sat, 04 Feb 2023 03:25:30 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40936) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pODrU-0007dN-67 for 61241@debbugs.gnu.org; Sat, 04 Feb 2023 03:25:28 -0500 Original-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 ) 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==; Original-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 ) id 1pODr8-0000ct-C6; Sat, 04 Feb 2023 03:25:18 -0500 In-Reply-To: <16B04B25-8EB8-4967-947B-C03DF3690ADF@medranocalvo.com> (adrian@medranocalvo.com) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:254757 Archived-At: > From: Adrián Medraño Calvo > > 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: > From: =?UTF-8?q?Adri=C3=A1n=20Medra=C3=B1o=20Calvo?= > > 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?