GNU bug report logs - #61241
29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and XInput 2

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Adrián Medraño Calvo <adrian@HIDDEN>; dated Thu, 2 Feb 2023 22:29:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 61241 <at> debbugs.gnu.org:


Received: (at 61241) by debbugs.gnu.org; 4 Feb 2023 08:46:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 04 03:46:00 2023
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+KV2KWX161tuX6IOtWPPvJwltqoB0Ojq1J1fV59BD3MkHgTqzZYcMyDCoCJ8A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6aMEZxPhCQkLViaA1A5Kt8iuIMdHB0hnG7K89GASElO_V7ize30aGn8gtAAXKZOiMzC
 ppFTpTZtcRvzssFxlnvV47nYAi_2y9_Tpd_s01AgJqONd3OGvlSz9IpAVbxFJ4zl.8ar_rNvoFld
 IReTm.0nFYfN6ryuvqCc14OyYM92SRp1rLfLjD6wusL_oBNCvl_ICx.sh8ulF9OfBMC5VBT84Out
 GEErQ0xvvXX1tKaHC6PN2Qp7V2VPmi5nw6vK2RPZ4mANqz1.CQVjI9vO046DLRUK2nh6rOp17HFv
 GNg8kELRzOCBe7x.PeTIjHPEolFpYM7SogFNVycVL25N9WzF7A3jZ3konVwl08t.YSlFBa1iygn8
 rcj1LvfB1dCXLA9kx4ihaUv_yqdwL7IPy3TC5rjXKCSsAj1rKmty4SQAJTNB14b7iKD209sKw4z0
 UhDTow7SAS4fQgdQpRmyps2c5zP5ddzbOEd9y8pOVomW6UOQDknQO8huMe1U_pki7e.gCxfH3eIF
 SDL1DdPspAk_Otr.0YOLdKN.Euocf33tKx2cNZb0VN0OR35mzisfINimSBEVOIEvYkjWy2gyrSkw
 nPgqxj3xnBkrFnj0AiMdSjzct0_WGmu7waK_mHqYafqu10By_1FM15SI1foIrR29jRCR5qmITZ41
 oQWwPsJt21BphiPH_MhylXkZV2peh8b.NIzeYP7ZKmzNUWjDFTxqHpI.g58yxmHivjqYSXGLI1K_
 J2ev2PpUdmLqs0ZLR8BQk5D.5qLaQ_VwySnf_h7b9AYvAN.pVGsCb22pBcjux9yedCO8IqHb6vne
 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>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#61241: 29.0.60; Incoherent last_mouse_window (xterm.c)
 between XInput and XInput 2
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-Debbugs-Envelope-To: 61241
Cc: 61241 <at> debbugs.gnu.org,
 =?utf-8?Q?Adri=C3=A1n_Medra=C3=B1o?= Calvo <adrian@HIDDEN>
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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61241; Package emacs. Full text available.

Message received at 61241 <at> debbugs.gnu.org:


Received: (at 61241) by debbugs.gnu.org; 4 Feb 2023 08:25:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Feb 04 03:25:30 2023
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>
To: =?utf-8?Q?Adri=C3=A1n_Medra=C3=B1o?= Calvo <adrian@HIDDEN>, Po
 Lu <luangruo@HIDDEN>
In-Reply-To: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN>
 (adrian@HIDDEN)
Subject: Re: bug#61241: 29.0.60;
 Incoherent last_mouse_window (xterm.c) between XInput and XInput 2
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-Debbugs-Envelope-To: 61241
Cc: 61241 <at> debbugs.gnu.org
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?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#61241; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 2 Feb 2023 22:28:18 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Feb 02 17:28:18 2023
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_Medra=C3=B1o_Calvo?= <adrian@HIDDEN>
Content-Type: multipart/mixed;
 boundary="Apple-Mail=_00C787AB-0549-46AC-9266-563CC5017C8E"
Mime-Version: 1.0
Subject: 29.0.60; Incoherent last_mouse_window (xterm.c) between XInput and
 XInput 2
Message-Id: <16B04B25-8EB8-4967-947B-C03DF3690ADF@HIDDEN>
Date: Thu, 2 Feb 2023 23:28:01 +0100
To: bug-gnu-emacs@HIDDEN
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-Debbugs-Envelope-To: submit
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--




Acknowledgement sent to Adrián Medraño Calvo <adrian@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#61241; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 4 Feb 2023 09:00:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.