GNU bug report logs - #69915
30.0.50; mouse-autoselect-window has no effect in terminal

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: Olaf Rogalsky <olaf.rogalsky@HIDDEN>; Done: Eli Zaretskii <eliz@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 69915-done <at> debbugs.gnu.org:


Received: (at 69915-done) by debbugs.gnu.org; 6 Apr 2024 10:15:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 06 06:15:53 2024
Received: from localhost ([127.0.0.1]:38350 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rt35V-0002Dy-6O
	for submit <at> debbugs.gnu.org; Sat, 06 Apr 2024 06:15:53 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:37048)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rt35T-0002D8-Ce
 for 69915-done <at> debbugs.gnu.org; Sat, 06 Apr 2024 06:15:52 -0400
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 1rt35H-00071v-34; Sat, 06 Apr 2024 06:15:39 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=LVH43GStOiyCeODdgl4VzuDXuJKz1+I6FR4al4oQzx4=; b=KSmxwbricEed
 Pem5dDAaii1kVQfpHFSIqAiJ8RXlCS88qmWyEQuf7JINpveR8Vq3bixizM4KE5eiQ9nyiU3M7B33F
 ENd7LvO3Jv+uxvXaHM7K/lhTA/DMcdQHY3m9QwpgS/iEeK0n7ytB/dYpsIESWVepDDrEiHIBbw1R8
 FsIRCW9AwqvUPVTpSdZvnaqJT4R7PBz7C23scCdT/LFx6v5D2/KduG3wOWycPUVsn+J/k5UDnRkgH
 BVvIgRDF/S1IF8sajZrUp7DI0NX5t0eOwZur9DfSb6xPzamCSmPJ7ZTB67heT0Xlcjw2dAHnpf0IY
 jjH8uhnEI2IUsv1K4h8I8w==;
Date: Sat, 06 Apr 2024 13:15:36 +0300
Message-Id: <86r0fi3ign.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jared Finder <jared@HIDDEN>
In-Reply-To: <a9f23e08946102dd7fcd8dd4daf1790a@HIDDEN> (message from Jared
 Finder on Thu, 04 Apr 2024 09:32:28 -0700)
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN> <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
 <86zfud9uqa.fsf@HIDDEN> <4b7f7d0f711e2dc81c3ffffa8efb4714@HIDDEN>
 <3f7cc786-af09-4095-8a8f-9a34ebfeaa2a@HIDDEN>
 <a9f23e08946102dd7fcd8dd4daf1790a@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69915-done
Cc: olaf.rogalsky@HIDDEN, rudalics@HIDDEN, 69915-done <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 (---)

> Date: Thu, 04 Apr 2024 09:32:28 -0700
> From: Jared Finder <jared@HIDDEN>
> Cc: Eli Zaretskii <eliz@HIDDEN>, olaf.rogalsky@HIDDEN,
>  69915 <at> debbugs.gnu.org
> 
> Eli, given this feedback I don't think Olaf's patch should be altered as 
> it currently uses window-minibuffer-p.  Let me know if you would like 
> any further changes.

Thanks, I installed both Olaf's and your changes, and I'm therefore
closing this bug.

P.S. Please note that @heading is not TRT inside a @subsection; I
fixed that.




Notification sent to Olaf Rogalsky <olaf.rogalsky@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Eli Zaretskii <eliz@HIDDEN>:
You have taken responsibility. Full text available.

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


Received: (at 69915) by debbugs.gnu.org; 4 Apr 2024 16:41:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 04 12:41:38 2024
Received: from localhost ([127.0.0.1]:34623 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rsQ9h-0002Hk-SF
	for submit <at> debbugs.gnu.org; Thu, 04 Apr 2024 12:41:38 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:58004)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rsQ9g-0002Hc-0c
 for 69915 <at> debbugs.gnu.org; Thu, 04 Apr 2024 12:41:36 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1712248890; bh=7fEPNN2c7VblAqnuHnPNNBwTgXpjzTF7Ms0fZQA0eQY=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=MVLrfktPvf7pVNNlphaa+0W5ARt0r4nkgWDLN+wuC1iO/cBidDcDwHMJbrQylB2B2
 NP9w6DZ80MUDt9HLu1/uriAEYTGskybNbm+d7Dn3c3SGV/LYDS7aZ6pvWUXmqgWdnD
 62z32SrMQ1xmBohKUkzDSAEgl0anrWOZMBBLGMm43gJLsMrivs5hMOIl0lFfr+A7vs
 zNciM6wUtxElIJHk/rf0mc4uZ8ngniJOQvVAc6qir3iGMN3BIQSPq/f2GUhTYF61Wf
 9//cqh8rmI/2s1ZMbhn/MofkSUGBtBTJ6YAZHVpJPs9npOAlIrngMFLwHEC4UVeqM/
 ZS2vE9r7mnJbQ==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id 4952444E;
 Thu,  4 Apr 2024 16:41:30 +0000 (UTC)
MIME-Version: 1.0
Date: Thu, 04 Apr 2024 09:41:30 -0700
From: Jared Finder <jared@HIDDEN>
To: martin rudalics <rudalics@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
In-Reply-To: <a9f23e08946102dd7fcd8dd4daf1790a@HIDDEN>
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN> <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
 <86zfud9uqa.fsf@HIDDEN> <4b7f7d0f711e2dc81c3ffffa8efb4714@HIDDEN>
 <3f7cc786-af09-4095-8a8f-9a34ebfeaa2a@HIDDEN>
 <a9f23e08946102dd7fcd8dd4daf1790a@HIDDEN>
Message-ID: <30d065bc022ec0dce9bb84f0b7b2be01@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz@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 (-)

Apologies, the manual quoting I did here for context was incorrectly 
done in the previous email.  I have corrected that.

>>>> Jared and Olaf, so I think the minibuffer test in the patch should
>>>> stay, but please see Martin's suggestions above.
>>> 
>>> Martin, did you mean we should change Olaf's patch to xt-mouse.el use
>>> minibuffer-window-active-p or we should change handle-select-window 
>>> in
>>> window.el to use minibuffer-window-active-p?
>>> 
>>> I have a preference to keep xt-mouse.el aligned with xterm.c as well
>>> as other native code checks, all which use MINI_WINDOW_P
>>> (window-minibuffer-p in Lisp) currently.
>> 
>> 'minibuffer-window-active-p' should be more accurate but I do not 
>> fully
>> understand its semantics any more.  For anything you and Olaf do, I'd
>> recommend 'window-minibuffer-p' / MINI_WINDOW_P.
> 
> Eli, given this feedback I don't think Olaf's patch should be altered 
> as it currently uses window-minibuffer-p.  Let me know if you would 
> like any further changes.
> 
>   -- MJF




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

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


Received: (at 69915) by debbugs.gnu.org; 4 Apr 2024 16:32:37 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Apr 04 12:32:37 2024
Received: from localhost ([127.0.0.1]:34618 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rsQ0y-0001QX-RD
	for submit <at> debbugs.gnu.org; Thu, 04 Apr 2024 12:32:37 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:43344)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rsQ0w-0001QH-8a
 for 69915 <at> debbugs.gnu.org; Thu, 04 Apr 2024 12:32:35 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1712248348; bh=UM+uC7GUYtImfjYMppN5kE4mReuhCZqX2PjImayW+BA=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=vP5+XloPHDF9W9UpJiWPOL3O3v+cH4aISCQhx9CcEVwTeZXVR42UVIHB/pNXuPm52
 8f0SunwsxFuQxbPIz/kt8KVwNe7SeLKmeK4fT1MZJXp6vDWfAWlDvQIAdqDxsVjKvv
 2bPULESWJQZzhBTMIacdONfgiKvb97YfTKvJDoOZWTM+jPzQ9HTn1+Gbb40Rkfw4/n
 RxP3KTh6R2ljiQzGbE0kUXbFnIYSwPDoHFv8RUT5RZtUUHEIZY1A5y3XNda5Hs/ZDB
 Mm1acc8OneqVQsq5iSNkJOxLYFUOmPpwzMNIEfBJP+ETQaDkld8HBOmFifM6rykJlJ
 j1nvMfg3k/VTw==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id 540A644E;
 Thu,  4 Apr 2024 16:32:28 +0000 (UTC)
MIME-Version: 1.0
Date: Thu, 04 Apr 2024 09:32:28 -0700
From: Jared Finder <jared@HIDDEN>
To: martin rudalics <rudalics@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
In-Reply-To: <3f7cc786-af09-4095-8a8f-9a34ebfeaa2a@HIDDEN>
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN> <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
 <86zfud9uqa.fsf@HIDDEN> <4b7f7d0f711e2dc81c3ffffa8efb4714@HIDDEN>
 <3f7cc786-af09-4095-8a8f-9a34ebfeaa2a@HIDDEN>
Message-ID: <a9f23e08946102dd7fcd8dd4daf1790a@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz@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 (-)

On 2024-04-01 04:40, Eli Zaretskii wrote:
> On 2024-04-02 00:50, martin rudalics wrote:
>> Jared and Olaf, so I think the minibuffer test in the patch should
>> stay, but please see Martin's suggestions above.
> 
>> Martin, did you mean we should change Olaf's patch to xt-mouse.el use
>> minibuffer-window-active-p or we should change handle-select-window in
>> window.el to use minibuffer-window-active-p?
>> 
>> I have a preference to keep xt-mouse.el aligned with xterm.c as well
>> as other native code checks, all which use MINI_WINDOW_P
>> (window-minibuffer-p in Lisp) currently.
> 
> 'minibuffer-window-active-p' should be more accurate but I do not fully
> understand its semantics any more.  For anything you and Olaf do, I'd
> recommend 'window-minibuffer-p' / MINI_WINDOW_P.

Eli, given this feedback I don't think Olaf's patch should be altered as 
it currently uses window-minibuffer-p.  Let me know if you would like 
any further changes.

   -- MJF




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

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


Received: (at 69915) by debbugs.gnu.org; 2 Apr 2024 07:51:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Apr 02 03:51:00 2024
Received: from localhost ([127.0.0.1]:52180 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rrYv4-0005JN-MZ
	for submit <at> debbugs.gnu.org; Tue, 02 Apr 2024 03:51:00 -0400
Received: from mout.gmx.net ([212.227.15.15]:33849)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rudalics@HIDDEN>) id 1rrYv0-0005IS-Oz
 for 69915 <at> debbugs.gnu.org; Tue, 02 Apr 2024 03:50:56 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.at;
 s=s31663417; t=1712044241; x=1712649041; i=rudalics@HIDDEN;
 bh=4xzvMXRB3sh7ypf0tvqucArenrOTnV6zYCuCMtDl05Q=;
 h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:
 In-Reply-To;
 b=DjQk8MjYiBYEtxlhOK0yv6MaZ+uLxY/8CCaop3lJWdtM+PEZwuWMP57jKEKHli8O
 zr8+8mUPfNWTrjlpHe4I5cXF3tswiVpjlOGXdM1kbu0hGlw4ZsU8S7LiXGKD784WW
 uUa2NeQJpmeJOgJg40LLq965VvhPZyLChXmX1khHj6iMrixZsfXVz27sSNH6oNraA
 pYpT73CtOdb8pTImdeHVZ1i9P1OLxxgduwxz3Ty/DQxXI4mfXdUjS4qXqIji3yYR5
 ZkMt3x5bH4JOsoirdQ2ASz/36aZfad6ioAp9QzDHQJqABJwkSNq+96Tl1gfGaKh45
 F6Ny6QEtXHRbOI//Dw==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from [192.168.31.113] ([213.142.97.124]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MOiHl-1sBgb945IF-00QE2i; Tue, 02
 Apr 2024 09:50:41 +0200
Message-ID: <3f7cc786-af09-4095-8a8f-9a34ebfeaa2a@HIDDEN>
Date: Tue, 2 Apr 2024 09:50:40 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
To: Jared Finder <jared@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN> <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
 <86zfud9uqa.fsf@HIDDEN> <4b7f7d0f711e2dc81c3ffffa8efb4714@HIDDEN>
Content-Language: en-US
From: martin rudalics <rudalics@HIDDEN>
In-Reply-To: <4b7f7d0f711e2dc81c3ffffa8efb4714@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K1:5gYRDec2TJr+hVZsz968Xsf78GEZpPu553jVQuEpUgkr0wNcDlM
 hmkcEG3vwYoVL7733WHKcrQlgQ1iF4cqYaOkZALV5beXVUhewEeqbtDjy2IOKR7yMIm8poS
 TeghqB7ua25/BGSgKZDwmMHdeCsA6Xh9xl5WV7d/CpM5pWcqrk/Ts3bO6gB3kq/JbU6Vhf0
 Mcw5WhZa4kWfO4pjNF+Bw==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:xjwAi673+1g=;e6aRiowZ45pRcDRF/h9ys3Gbmgq
 hJcO2iYBgW0uA1hgzDFeoygOMFOYtNKvtMR9+qXEovQK3eapVeH+181MeBJa4ppr40a0Z9KPO
 xGXHOUi2kQjroUlRagCDmWabstTf4fY7SxaVsqdCFI7ElgMGCZONLUgK98viYva0NfRkE7qgw
 ZqqZz5tkzaQW0j5NB98ApfLK4rUZxnm6c5U/I5lW6yuCbSJjoDFqRbl9ZcdMT0ow3ZGbNdSd3
 KCoe/HOuccX9n9EmKJNwo4EWZ7xu4v03iyWjccADq0Uth5It+n1Ldel/9Zai768SBSstcta9B
 AIJwKb3Qb5hrnxgktF7A4mBeP5QPyjnZZUT+LD7JX5HSnm686oPQC3NMdzuTd2W6x73yCLr0m
 Xk8yqO8Bh9zIq9rXMTDzVZZLGFfAS6PRUbT0abIuKzgFSi+or5tGRRLMBKieRHXR7htnaCFuO
 Ld5/M/2sXIwgcsFmm29yqx86epAyJ7TT2/DUxhsEU9M3+8y+aaG5KeZoQlZqV2fTlwFU/6rNw
 ZTI5pv0FYTH8jriVRBPDw5xp4RLr49wiQhO2FCxQ1rw4JwAj1o6Zw7V2O9HW+DUdRp6GQoGjh
 vEeSfpsX4bIF5Hv7FyKSvYnMLT6ZPhsmXE+jxfhTFsOGxOzvuxXLP/rySHodd3te/+I8b9Tn/
 0dimpNmuZTMhFQFSOj1c8+YB8y062THHXCimcwKuC2HREIPyRFQwb5I4Vgt96McJL5UqR6WJh
 LycTQAOu7mxTBDHCo/dB1/qm03vQtiWBMc2fKpJlkkWsWnsxOGJ9XNewSDXYvePLa36l3MA+q
 JP39kDG6ZpQ7W14d/SAgYkFAMjw91nAI0Y3Q8rJFvkvbQ=
X-Spam-Score: 2.8 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  > Martin,
 did you mean we should change Olaf's patch to xt-mouse.el
 use > minibuffer-window-active-p or we should change handle-select-window
 in > window.el to use minibuffer-window-active-p? > > I h [...] 
 Content analysis details:   (2.8 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
 [213.142.97.124 listed in zen.spamhaus.org]
 -0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
 [212.227.15.15 listed in wl.mailspike.net]
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (rudalics[at]gmx.at)
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
 low trust [212.227.15.15 listed in list.dnswl.org]
 -0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <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: 1.8 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  > Martin, did you mean we should change Olaf's patch to xt-mouse.el
    use > minibuffer-window-active-p or we should change handle-select-window
    in > window.el to use minibuffer-window-active-p? > > I h [...] 
 
 Content analysis details:   (1.8 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
                             low trust
                             [212.227.15.15 listed in list.dnswl.org]
  3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
                             [213.142.97.124 listed in zen.spamhaus.org]
 -0.0 RCVD_IN_MSPIKE_H3      RBL: Good reputation (+3)
                             [212.227.15.15 listed in wl.mailspike.net]
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (rudalics[at]gmx.at)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 RCVD_IN_MSPIKE_WL      Mailspike good senders
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

 > Martin, did you mean we should change Olaf's patch to xt-mouse.el use
 > minibuffer-window-active-p or we should change handle-select-window in
 > window.el to use minibuffer-window-active-p?
 >
 > I have a preference to keep xt-mouse.el aligned with xterm.c as well
 > as other native code checks, all which use MINI_WINDOW_P
 > (window-minibuffer-p in Lisp) currently.

'minibuffer-window-active-p' should be more accurate but I do not fully
understand its semantics any more.  For anything you and Olaf do, I'd
recommend 'window-minibuffer-p' / MINI_WINDOW_P.

martin




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

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


Received: (at 69915) by debbugs.gnu.org; 1 Apr 2024 14:08:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 01 10:08:32 2024
Received: from localhost ([127.0.0.1]:51313 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rrIKt-0001U3-Jv
	for submit <at> debbugs.gnu.org; Mon, 01 Apr 2024 10:08:32 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:47038)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rrIKr-0001Tw-HX
 for 69915 <at> debbugs.gnu.org; Mon, 01 Apr 2024 10:08:30 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1711980505; bh=LPyJnS6ihWmKIfryw62+BiiKjOt8GgxQM0PuCAR4Naw=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=dxc+dyC2E3FTQGfB7ySUWKfn/kKIp5PFozpoeE05xBmUENdr8alshnXH+YohDNPNw
 2aV2EiqkLqx1lwl5IbfpXGsqoNhoor+sZayKfp5AT4abw4acXvaIAptjwFavZrIM8E
 fc+HfxhQ5BlDSOQ0LYGGr6AAxzKM4P5lCI+HJxyNm0RDlcSlTRtUItdfQrFmqOe0Cu
 AAkEgEsz8D9mFhxnZQEq9mvFbRCw2eZPtWhMpjgDXKCtpa11cMsM/qdMfVaq6Sj0w3
 5I2Pl5TC6SSZf/cme0gckYVNpj2nEInkA7CoOa5ZuyTKfRYOvp062DBKnA8PDwTWWW
 bJSYbEzFYBM6w==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id 51A9597D;
 Mon,  1 Apr 2024 14:08:25 +0000 (UTC)
MIME-Version: 1.0
Date: Mon, 01 Apr 2024 07:08:25 -0700
From: Jared Finder <jared@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
In-Reply-To: <86zfud9uqa.fsf@HIDDEN>
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN> <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
 <86zfud9uqa.fsf@HIDDEN>
Message-ID: <4b7f7d0f711e2dc81c3ffffa8efb4714@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, martin rudalics <rudalics@HIDDEN>,
 69915 <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: -1.0 (-)

On 2024-04-01 04:40, Eli Zaretskii wrote:
>> Date: Mon, 1 Apr 2024 11:09:47 +0200
>> Cc: olaf.rogalsky@HIDDEN, 69915 <at> debbugs.gnu.org
>> From: martin rudalics <rudalics@HIDDEN>
>> 
>>  > The mini-window test was added by Martin, AFAICT, as part of 
>> rewriting
>>  > the mouse-autoselect-window support.  Martin, do you remember why 
>> you
>>  > added the MINI_WINDOW_P test in xterm.c, but not, for example, in
>>  > w32term.c?
>>  >
>>  > In any case, I couldn't find any problems with the current behavior 
>> on
>>  > MS-Windows when mouse-autoselect-window is non-nil.
>> 
>> The original mini-window test was conceived by Stefan
>> 
>> commit 66c226bf5a1e8289b0ce676d5e4225810a11af91
>> Author: Stefan Monnier <monnier@HIDDEN>
>> Date:   Thu Jan 20 14:23:23 2005 +0000
>> 
>>      (handle-select-window): Don't switch window when we're in the 
>> minibuffer.
>> 
>> and I moved it to xterm.c later.  I don't remember why and all I
>> remember is that the accompanying comment was not mine.
>> 
>> The check is redundant because the condition is tested again here in
>> 'handle-select-window':
>> 
>>                  ;; Don't switch if window autoselection with mouse is 
>> active
>>                  ;; and minibuffer window is selected.
>>                  (and mouse-autoselect-window (window-minibuffer-p))
>> 
>> One could say that the xterm.c code is more efficient because it 
>> doesn't
>> generate a SELECT_WINDOW_EVENT when the selected window is the
>> minibuffer window.  The w32 code generates the event but has it
>> dismissed later in 'handle-select-window'.
>> 
>> In either case I would not remove the check from 
>> 'handle-select-window'
>> because that one is platform-independent so there's no need to 
>> implement
>> anything separately in the backends.
>> 
>> Though it might be more accurate to replace 'window-minibuffer-p' with
>> 'minibuffer-window-active-p' to catch the case where a user, for some
>> reason, selects the minibuffer window manually without activating the
>> minibuffer.  And the 'mouse-autoselect-window' conjunct above is 
>> likely
>> redundant...
> 
> Thanks.
> 
> Jared and Olaf, so I think the minibuffer test in the patch should
> stay, but please see Martin's suggestions above.

Martin, did you mean we should change Olaf's patch to xt-mouse.el use 
minibuffer-window-active-p or we should change handle-select-window in 
window.el to use minibuffer-window-active-p?

I have a preference to keep xt-mouse.el aligned with xterm.c as well as 
other native code checks, all which use MINI_WINDOW_P 
(window-minibuffer-p in Lisp) currently.

   -- MJF




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

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


Received: (at 69915) by debbugs.gnu.org; 1 Apr 2024 11:41:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 01 07:41:05 2024
Received: from localhost ([127.0.0.1]:49748 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rrG2C-00023y-Og
	for submit <at> debbugs.gnu.org; Mon, 01 Apr 2024 07:41:05 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:41822)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rrG2A-00023E-8v
 for 69915 <at> debbugs.gnu.org; Mon, 01 Apr 2024 07:41:03 -0400
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 1rrG20-000651-Nr; Mon, 01 Apr 2024 07:40:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=ItVUrhMtqQBnHMy2FYKgFwbOldnaUR8Q06MMhfAtNQI=; b=YcYk2khV3f9S
 MMy0Yish0JLEh4AV+5+GPw63OAjQ7rHAeBotzoCUbmTePjYuZaaqJZK4QhTYnd6zIha7z5/2s3DhQ
 jufvOYXAvscWeFKeWiqDRZX9AKfiXypA563aD2IIsPRJGxIxKp6VsHYv7JvExUzpIYWE7N8NgDsk4
 /N3JUAcBXjRcAqVsKi3V9JnrydlN26Y/9Pagpf2bwFV3BSX86CtxxVJm732Qi5DqoG1vbNEoAfE4m
 Obt0S8P1zJZMHMUMolWfSa1ZxL5bvhCSmyAXuNOkm0mGRGqyHHra3ut3DlZgO7nA2Tz3N5SgRXjPg
 tR+QduR7otgf5zLjEyVzvg==;
Date: Mon, 01 Apr 2024 14:40:29 +0300
Message-Id: <86zfud9uqa.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: martin rudalics <rudalics@HIDDEN>
In-Reply-To: <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN> (message from
 martin rudalics on Mon, 1 Apr 2024 11:09:47 +0200)
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN> <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <at> debbugs.gnu.org, jared@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: -3.3 (---)

> Date: Mon, 1 Apr 2024 11:09:47 +0200
> Cc: olaf.rogalsky@HIDDEN, 69915 <at> debbugs.gnu.org
> From: martin rudalics <rudalics@HIDDEN>
> 
>  > The mini-window test was added by Martin, AFAICT, as part of rewriting
>  > the mouse-autoselect-window support.  Martin, do you remember why you
>  > added the MINI_WINDOW_P test in xterm.c, but not, for example, in
>  > w32term.c?
>  >
>  > In any case, I couldn't find any problems with the current behavior on
>  > MS-Windows when mouse-autoselect-window is non-nil.
> 
> The original mini-window test was conceived by Stefan
> 
> commit 66c226bf5a1e8289b0ce676d5e4225810a11af91
> Author: Stefan Monnier <monnier@HIDDEN>
> Date:   Thu Jan 20 14:23:23 2005 +0000
> 
>      (handle-select-window): Don't switch window when we're in the minibuffer.
> 
> and I moved it to xterm.c later.  I don't remember why and all I
> remember is that the accompanying comment was not mine.
> 
> The check is redundant because the condition is tested again here in
> 'handle-select-window':
> 
>                  ;; Don't switch if window autoselection with mouse is active
>                  ;; and minibuffer window is selected.
>                  (and mouse-autoselect-window (window-minibuffer-p))
> 
> One could say that the xterm.c code is more efficient because it doesn't
> generate a SELECT_WINDOW_EVENT when the selected window is the
> minibuffer window.  The w32 code generates the event but has it
> dismissed later in 'handle-select-window'.
> 
> In either case I would not remove the check from 'handle-select-window'
> because that one is platform-independent so there's no need to implement
> anything separately in the backends.
> 
> Though it might be more accurate to replace 'window-minibuffer-p' with
> 'minibuffer-window-active-p' to catch the case where a user, for some
> reason, selects the minibuffer window manually without activating the
> minibuffer.  And the 'mouse-autoselect-window' conjunct above is likely
> redundant...

Thanks.

Jared and Olaf, so I think the minibuffer test in the patch should
stay, but please see Martin's suggestions above.




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

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


Received: (at 69915) by debbugs.gnu.org; 1 Apr 2024 09:10:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 01 05:10:06 2024
Received: from localhost ([127.0.0.1]:49567 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rrDg6-000343-04
	for submit <at> debbugs.gnu.org; Mon, 01 Apr 2024 05:10:06 -0400
Received: from mout.gmx.net ([212.227.15.18]:32989)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rudalics@HIDDEN>) id 1rrDg3-00033S-Qf
 for 69915 <at> debbugs.gnu.org; Mon, 01 Apr 2024 05:10:05 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.at;
 s=s31663417; t=1711962590; x=1712567390; i=rudalics@HIDDEN;
 bh=ZSLSP1N8Ls2EYCcle7X+DLlbmATJeHwogaKOA4NaS6k=;
 h=X-UI-Sender-Class:Date:Subject:To:Cc:References:From:
 In-Reply-To;
 b=NC8ey05vvI2qXkRyaHpSTGsXhYf0f5Ah0I3nY4GLNl+4BZnAXAK+ZFbrG+fO1XFg
 o3qRUTzAaaSbuIDpvKFe1D2OHIaq4kd7XTfIT0ogWNR81yCi5fG869rnEd6tL0ngX
 0wudeMxp7pplLAL9YHGGmPzchSgCU7KEV58vHLZpuOhloZJsMw9VoMe18779QFZzm
 SGwlK8JKquLYOSREL+nhhKwr7cqj8k2b/L9K9o9cmFa12rasT5tdaICIe70b+QdEX
 MCMWmEIGj0oY1uCZaJbxj5jhnyLYmQCGlq8u5HGBtG7dpJd1lVnxvFivFbulgYUZL
 pyrnqzU3M5+Xw+n+ww==
X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a
Received: from [192.168.31.113] ([212.95.5.163]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MIwzA-1s5zdP3hJS-00KTZT; Mon, 01
 Apr 2024 11:09:49 +0200
Message-ID: <f5719214-822f-4be0-98ef-b8f1c98c6b99@HIDDEN>
Date: Mon, 1 Apr 2024 11:09:47 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
To: Eli Zaretskii <eliz@HIDDEN>, Jared Finder <jared@HIDDEN>
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
 <86frw6bww3.fsf@HIDDEN>
Content-Language: en-US
From: martin rudalics <rudalics@HIDDEN>
In-Reply-To: <86frw6bww3.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K1:oVmTH0ZJR12GH+d4iyGo+4jp+fv9pHEQN1U8wvpirFv7lzTXiLI
 MsKU85Ga9RHZ2GUFhqU+sSu/DHwExAOFK6/h1B4oSOo8Z2+ii56+A45o1fjKdmiT9rFIche
 +tHx1vdfQCReD5ybUinFhNUrSSnM9FYDlFHLAnak//B3CElpP0+8FWasuXrsS5gcopLw9HD
 VFgX8tDy2xQfKIwXhNgYg==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:9pCSM82NRK8=;jkg2rRRjBP/1ig13j+yZpDMmM94
 f19o4DiHQB/7XPQonbZYEJIFl8jE7pSyPXGp9l52zDFpqg76dpEJZMaZrILf5rkhAn4y4+hQV
 KrDJXou/6plvZKlaW7oDxnucu8XEwKz727JFUkdZq96IjcBKyiRMgPE2+5NP4USrcVgE80HTi
 llgH5MPOjyPJzTolnf4Cz4JpgWgLykNQFUkMJbBEmiWyQWp/0rOVKicmq0bSYsgAOypSrb7Pm
 Pk4ZBqq0S3VpOXL5tO7cpr5zKsxeVowzX33C9TyHppfmuEw9oC1yrC7QOro8Q5KgwYbo1gtKE
 apuYz7doaaDciyGlxqnCyVvh6TVCcNNXKSvQM1fWvEyGGKdPuprVdXAaf5nkZSrCwS1XFZp3C
 klkC+IorVHrYyfIPC6BScwv0wsvm51lQa4eoU8u6iBKMkGFmSrdsgVNmkt4C/i0QtekKeiBP+
 mgAQLOWhQQPAl5ji2nSS1zTet54eHpeo82km6F9IXwPyzHF5vFCvWxF7G4sW/dzXYZFFV6yu7
 StIeP8Qmx+yAB5qMSIItpb7hCE+b44SOKaJ86y4DrL9PW4tqUQOzkTFw6WUR+95OCbXiTLBDK
 /YHP6NMpmc46MgEyuv9AJVsgbOE7lPqCxI7dQX4igf7wrW+G+nI6SP7YYSTyhgV5zv1S8f+op
 5mwarjMcvcL0dxFFRV0MQcnCbv62/e0jQ1w14w6XgdWJJ7YNM9Ve3J65Ly9WExJ1Gqbe3jAUo
 C+OQJNXs0uwOgV7YbX9AOIOu03v8uvDbcxtnC7iRzk68pIgXKB/tzpOKTigDbbo6G4yGKsr9N
 hg6DWHfvfxcaY0ls0BeduoSdZUmgMNzpzOXEq5YOz0OoH/oRmCXTN8r39z6VAtebpq
X-Spam-Score: 2.9 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: >> The intended behavior is that is even with
 mouse-autoselect-window
 set, >> moving the mouse is never supposed to change the selected window
 away >> from the minibuffer. Many platforms explicitly c [...] 
 Content analysis details:   (2.9 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
 low trust [212.227.15.18 listed in list.dnswl.org]
 3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
 [212.95.5.163 listed in zen.spamhaus.org]
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (rudalics[at]gmx.at)
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [212.227.15.18 listed in wl.mailspike.net]
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <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: 1.9 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  >> The intended behavior is that is even with mouse-autoselect-window
    set, >> moving the mouse is never supposed to change the selected window
   away >> from the minibuffer. Many platforms explicitly c [...] 
 
 Content analysis details:   (1.9 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
                             low trust
                             [212.227.15.18 listed in list.dnswl.org]
  3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
                             [212.95.5.163 listed in zen.spamhaus.org]
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
                             [212.227.15.18 listed in wl.mailspike.net]
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (rudalics[at]gmx.at)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

 >> The intended behavior is that is even with mouse-autoselect-window set,
 >> moving the mouse is never supposed to change the selected window away
 >> from the minibuffer.  Many platforms explicitly check if the selected
 >> window is the minibuffer before emitting the <select-window> event, but
 >> not all platforms do (see list above).
 >>
 >> And on all platforms, including ones without the explicit check we get
 >> the intended behavior from our testing.
 >>
 >> So my question is should we copy the explicit check to prevent
 >> <select-window> events from being emitted to xt-mouse.el as well, even
 >> though it does not appear to be necessary from our testing?
 >
 > The mini-window test was added by Martin, AFAICT, as part of rewriting
 > the mouse-autoselect-window support.  Martin, do you remember why you
 > added the MINI_WINDOW_P test in xterm.c, but not, for example, in
 > w32term.c?
 >
 > In any case, I couldn't find any problems with the current behavior on
 > MS-Windows when mouse-autoselect-window is non-nil.

The original mini-window test was conceived by Stefan

commit 66c226bf5a1e8289b0ce676d5e4225810a11af91
Author: Stefan Monnier <monnier@HIDDEN>
Date:   Thu Jan 20 14:23:23 2005 +0000

     (handle-select-window): Don't switch window when we're in the minibuffer.

and I moved it to xterm.c later.  I don't remember why and all I
remember is that the accompanying comment was not mine.

The check is redundant because the condition is tested again here in
'handle-select-window':

                 ;; Don't switch if window autoselection with mouse is active
                 ;; and minibuffer window is selected.
                 (and mouse-autoselect-window (window-minibuffer-p))

One could say that the xterm.c code is more efficient because it doesn't
generate a SELECT_WINDOW_EVENT when the selected window is the
minibuffer window.  The w32 code generates the event but has it
dismissed later in 'handle-select-window'.

In either case I would not remove the check from 'handle-select-window'
because that one is platform-independent so there's no need to implement
anything separately in the backends.

Though it might be more accurate to replace 'window-minibuffer-p' with
'minibuffer-window-active-p' to catch the case where a user, for some
reason, selects the minibuffer window manually without activating the
minibuffer.  And the 'mouse-autoselect-window' conjunct above is likely
redundant...

martin




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

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


Received: (at 69915) by debbugs.gnu.org; 31 Mar 2024 08:58:50 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 31 04:58:49 2024
Received: from localhost ([127.0.0.1]:46579 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rqr1d-0006I3-Fr
	for submit <at> debbugs.gnu.org; Sun, 31 Mar 2024 04:58:49 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:39532)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rqr1b-0006Hc-Cc
 for 69915 <at> debbugs.gnu.org; Sun, 31 Mar 2024 04:58:48 -0400
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 1rqr1S-0000vU-Ro; Sun, 31 Mar 2024 04:58:38 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=4so9+OCQB9GjkNMaM/PFkt+IAySY9Y6selrqFrHQkBE=; b=VxKY1naL8KRD
 zIqXVW4sUM3G7cGE/xX/ro4QvMXCMBbtYR+oFn7g/qcWafmH0S1/3kuizH5MnbWhhDKN/uIf6K5pY
 quw9f0YU1Ko3G/YGZThQKDgEJuyyn3sC26hRUssUcragVY8v8TWbysnj/EVrTdwpoaepYPN/ewrju
 XpqqO8vNrZaA1XK56eEs56oWbXuNm72BIOeffwQflJR6JRwOWo9VfTDv41C4mwMK7RE7rvrlunlVq
 aM1d4+4xnr65VNcG7gsbC8fMft+ZF/+w98QuHUI16jsJqRNrxYpxGkiRZJiDU7WlgSPfOqQQuSHI4
 vaefvM+xa+Mmv4bhgLiM7w==;
Date: Sun, 31 Mar 2024 11:58:36 +0300
Message-Id: <86frw6bww3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jared Finder <jared@HIDDEN>, martin rudalics <rudalics@HIDDEN>
In-Reply-To: <00f0925f3a878950933691973fecd536@HIDDEN> (message from Jared
 Finder on Thu, 28 Mar 2024 07:41:28 -0700)
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN> <00f0925f3a878950933691973fecd536@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <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 (---)

> Date: Thu, 28 Mar 2024 07:41:28 -0700
> From: Jared Finder <jared@HIDDEN>
> Cc: olaf.rogalsky@HIDDEN, 69915 <at> debbugs.gnu.org
> 
> On 2024-03-27 23:11, Eli Zaretskii wrote:
> >> Date: Wed, 27 Mar 2024 14:47:27 -0700
> >> From: Jared Finder <jared@HIDDEN>
> >> Cc: eliz@HIDDEN, 69915 <at> debbugs.gnu.org
> >> 
> >> > On the other hand, looking at msdos.c, there is no test against
> >> > the minibuffer. I believed, that the selection of the minibuffer
> >> > is taken care of at +10638 of window.el. In my tests the patch
> >> > behaves exactly like the documentation, quote: "Mouse
> >> > auto-selection selects the minibuffer window only if it is active,
> >> > and never deselects the active minibuffer window."  I added the
> >> > test, but commented it out.
> >> 
> >> I'm not sure what the right way to proceed here is then.  Eli, can you
> >> give advice?
> >> 
> >> Looking at different OS files that handle mouse_autoselect_window, I 
> >> see
> >> the following state for checks if the selected window is a minibuffer
> >> with MINI_WINDOW_P:
> >> 
> >> pgtkterm.c: checks
> >> w32term.c: does NOT check
> >> w32inevt.c: does NOT check
> >> nsterm.m: checks
> >> xterm.c: checks
> >> msdos.c: does NOT check
> >> haikuterm.c: checks
> >> androidterm.c: checks
> >> term.c: no support for mouse-autoselect-window. :(
> >> 
> >> My gut is to assume that the X and GTK behavior is most likely to be
> >> better tested and more correct, but I defer to Eli here.
> > 
> > I tend to agree.  But, just to be sure, can you or Olaf describe the
> > exact issue and how it could happen, and perhaps show a recipe to try
> > reproducing it?  I'd like to take a closer look at the relevant code.
> 
> The intended behavior is that is even with mouse-autoselect-window set, 
> moving the mouse is never supposed to change the selected window away 
> from the minibuffer.  Many platforms explicitly check if the selected 
> window is the minibuffer before emitting the <select-window> event, but 
> not all platforms do (see list above).
> 
> And on all platforms, including ones without the explicit check we get 
> the intended behavior from our testing.
> 
> So my question is should we copy the explicit check to prevent 
> <select-window> events from being emitted to xt-mouse.el as well, even 
> though it does not appear to be necessary from our testing?

The mini-window test was added by Martin, AFAICT, as part of rewriting
the mouse-autoselect-window support.  Martin, do you remember why you
added the MINI_WINDOW_P test in xterm.c, but not, for example, in
w32term.c?

In any case, I couldn't find any problems with the current behavior on
MS-Windows when mouse-autoselect-window is non-nil.




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

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


Received: (at 69915) by debbugs.gnu.org; 30 Mar 2024 20:18:08 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 30 16:18:08 2024
Received: from localhost ([127.0.0.1]:46202 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rqf9T-000483-DK
	for submit <at> debbugs.gnu.org; Sat, 30 Mar 2024 16:18:07 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:44390)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rqf9Q-00047t-RI
 for 69915 <at> debbugs.gnu.org; Sat, 30 Mar 2024 16:18:06 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1711829881; bh=kvtb+iArbBjgJL0Sn4cWzvOh0keYhXlJkmGNQlcDFEA=;
 h=Date:From:To:Cc:Subject:From;
 b=0wR9QIhkjy7U6VzJr6KFnv6uGnYogAiW5AYQiqVan7g9MsC8ZMZ0di5wdvSPUMLrW
 TPXh7BZgpL25XTRPGX1SvGXGOUUk42TeJACHAm+Vg0xrDPIo+RIPOxctbs5qgrTIv4
 bwPl1tFRexKL88BUgAJB7ah2GDYVeVQ9Pv43lROoM0TR/wd/mtrWFj4vlPvoeOErf5
 KT/g4Y0v693YrGsekUneF/m5BsaGOkoOUz43uy4GhTje7YZa8M4iSKJsze5/2CQSzY
 7R8TcdQbLb7gwzi7eESaQt7MVkki481n5Q9aScMfUH9Omb6MnnXkWTQMv00FcJa/5m
 paUnY1CjWlv1A==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id 9EB4E9B2;
 Sat, 30 Mar 2024 20:18:01 +0000 (UTC)
MIME-Version: 1.0
Date: Sat, 30 Mar 2024 13:18:01 -0700
From: Jared Finder <jared@HIDDEN>
To: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
Message-ID: <d790cf8e6e38441e19e972e9b2a49367@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: multipart/mixed;
 boundary="=_f7681a0e6a021cb402e69c3be2894889"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, Eli Zaretskii <eliz@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 (-)

--=_f7681a0e6a021cb402e69c3be2894889
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=US-ASCII;
 format=flowed

I am happy with the contents of Olaf's patch.  I would just do some 
minor reformatting at this point: converting tabs to spaces, removing 
commented out line, change comment wording slightly.

On 2024-03-30 10:03, Olaf Rogalsky wrote:
> Hi Jared and Eli,
> 
>>> I can't find the documentation of the format of the select-window
>>> event. Maybe its a good idea to add it.
>> Agreed.  I think it should be added to Focus Events in commands.texi.
> 
> But probaly by someone who knows the texi format and has a better
> command of the english language than I do. Sorry.

I took a stab at generating documentation here.  I'm not that familiar 
with texi format either, so I'd appreciate a review.

> PS: sorry for the horrible formatting of the previous messages: I
> usually do not use my gmail account ... Hope, this one comes out 
> better.

No worries, everything looked fine to me!

   -- MJF
--=_f7681a0e6a021cb402e69c3be2894889
Content-Transfer-Encoding: base64
Content-Type: text/x-diff;
 name=0001-Adding-documentation-for-switch-window-event.patch
Content-Disposition: attachment;
 filename=0001-Adding-documentation-for-switch-window-event.patch;
 size=5358

RnJvbSA3Y2Q4MzQ1OGNhYTM5NDBmOGE4MjYyMzNjMTkwM2JjNjlhYWZkZWY4IE1vbiBTZXAgMTcg
MDA6MDA6MDAgMjAwMQpGcm9tOiBKYXJlZCBGaW5kZXIgPGphcmVkQGZpbmRlci5vcmc+CkRhdGU6
IFNhdCwgMzAgTWFyIDIwMjQgMTM6MTQ6NDMgLTA3MDAKU3ViamVjdDogW1BBVENIXSBBZGRpbmcg
ZG9jdW1lbnRhdGlvbiBmb3IgPHN3aXRjaC13aW5kb3c+IGV2ZW50CgoqIGRvYy9saXNwcmVmL2Nv
bW1hbmRzLnRleGkgKEZvY3VzIEV2ZW50cyk6IEFkZGluZyBkb2N1bWVudGF0aW9uCmZvciB0aGUg
c3RydWN0dXJlIG9mIDxzd2l0Y2gtd2luZG93PiBldmVudHMuICBNYWtpbmcgc3VyZSB0byBiZQpj
bGVhciB3aGVuIHJlZmVycmluZyB0byB3aW5kb3cgc3lzdGVtIHdpbmRvd3MgdnMgRW1hY3Mgd2lu
ZG93cy4KKiBkb2MvbGlzcHJlZi93aW5kb3dzLnRleGkgKE1vdXNlIFdpbmRvdyBBdXRvLXNlbGVj
dGlvbik6IEFkZGluZwpsaW5rIHRvIEZvY3VzIEV2ZW50cy4KLS0tCiBkb2MvbGlzcHJlZi9jb21t
YW5kcy50ZXhpIHwgNjYgKysrKysrKysrKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tLS0tCiBk
b2MvbGlzcHJlZi93aW5kb3dzLnRleGkgIHwgIDIgKy0KIDIgZmlsZXMgY2hhbmdlZCwgNDggaW5z
ZXJ0aW9ucygrKSwgMjAgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvZG9jL2xpc3ByZWYvY29t
bWFuZHMudGV4aSBiL2RvYy9saXNwcmVmL2NvbW1hbmRzLnRleGkKaW5kZXggNGZlNDk2OWMwZGIu
LjMzNWE0MWRiYjQ0IDEwMDY0NAotLS0gYS9kb2MvbGlzcHJlZi9jb21tYW5kcy50ZXhpCisrKyBi
L2RvYy9saXNwcmVmL2NvbW1hbmRzLnRleGkKQEAgLTIzMDMsMTUgKzIzMDMsMzQgQEAgRm9jdXMg
RXZlbnRzCiBAc3Vic2VjdGlvbiBGb2N1cyBFdmVudHMKIEBjaW5kZXggZm9jdXMgZXZlbnQKIAor
VGhpcyBzZWN0aW9uIHRhbGtzIGFib3V0IGJvdGggd2luZG93IHN5c3RlbXMgYW5kIEVtYWNzIGZy
YW1lcy4gIFdoZW4KK3RhbGtpbmcgYWJvdXQganVzdCBgYGZyYW1lcycnIG9yIGBgd2luZG93cycn
LCBpdCByZWZlcnMgdG8gRW1hY3MgZnJhbWVzCithbmQgRW1hY3Mgd2luZG93cy4gIFdoZW4gdGFs
a2luZyBhYm91dCB3aW5kb3cgc3lzdGVtIHdpbmRvd3MsIHdoaWNoIGFyZQorYWxzbyBFbWFjcyBm
cmFtZXMsIHRoaXMgc2VjdGlvbiBhbHdheXMgc2F5cyBgYHdpbmRvdyBzeXN0ZW0gd2luZG93Jycu
CisKK0Bub2luZGVudAogV2luZG93IHN5c3RlbXMgcHJvdmlkZSBnZW5lcmFsIHdheXMgZm9yIHRo
ZSB1c2VyIHRvIGNvbnRyb2wgd2hpY2ggd2luZG93Ci1nZXRzIGtleWJvYXJkIGlucHV0LiAgVGhp
cyBjaG9pY2Ugb2Ygd2luZG93IGlzIGNhbGxlZCB0aGUgQGRmbntmb2N1c30uCi1XaGVuIHRoZSB1
c2VyIGRvZXMgc29tZXRoaW5nIHRvIHN3aXRjaCBiZXR3ZWVuIEVtYWNzIGZyYW1lcywgdGhhdAot
Z2VuZXJhdGVzIGEgQGRmbntmb2N1cyBldmVudH0uICBUaGUgbm9ybWFsIGRlZmluaXRpb24gb2Yg
YSBmb2N1cyBldmVudCwKLWluIHRoZSBnbG9iYWwga2V5bWFwLCBpcyB0byBzZWxlY3QgYSBuZXcg
ZnJhbWUgd2l0aGluIEVtYWNzLCBhcyB0aGUgdXNlcgotd291bGQgZXhwZWN0LiAgQHhyZWZ7SW5w
dXQgRm9jdXN9LCB3aGljaCBhbHNvIGRlc2NyaWJlcyBob29rcyByZWxhdGVkCi10byBmb2N1cyBl
dmVudHMuCitzeXN0ZW0gd2luZG93LCBvciBFbWFjcyBmcmFtZSwgZ2V0cyBrZXlib2FyZCBpbnB1
dC4gIFRoaXMgY2hvaWNlIG9mCit3aW5kb3cgc3lzdGVtIHdpbmRvdyBpcyBjYWxsZWQgdGhlIEBk
Zm57Zm9jdXN9LiAgV2hlbiB0aGUgdXNlciBkb2VzCitzb21ldGhpbmcgdG8gc3dpdGNoIGJldHdl
ZW4gRW1hY3MgZnJhbWVzLCB0aGF0IGdlbmVyYXRlcyBhIEBkZm57Zm9jdXMKK2V2ZW50fS4gIEVt
YWNzIGFsc28gZ2VuZXJhdGVzIGZvY3VzIGV2ZW50cyB3aGVuIHVzaW5nCitAdmFye21vdXNlLWF1
dG9zZWxlY3Qtd2luZG93fSB0byBzd2l0Y2ggYmV0d2VlbiBFbWFjcyB3aW5kb3dzIHdpdGhpbgor
RW1hY3MgZnJhbWVzLgorCitBIGZvY3VzIGV2ZW50IGluIHRoZSBtaWRkbGUgb2YgYSBrZXkgc2Vx
dWVuY2Ugd291bGQgZ2FyYmxlIHRoZQorc2VxdWVuY2UuICBTbyBFbWFjcyBuZXZlciBnZW5lcmF0
ZXMgYSBmb2N1cyBldmVudCBpbiB0aGUgbWlkZGxlIG9mIGEga2V5CitzZXF1ZW5jZS4gIElmIHRo
ZSB1c2VyIGNoYW5nZXMgZm9jdXMgaW4gdGhlIG1pZGRsZSBvZiBhIGtleQorc2VxdWVuY2UtLS10
aGF0IGlzLCBhZnRlciBhIHByZWZpeCBrZXktLS10aGVuIEVtYWNzIHJlb3JkZXJzIHRoZSBldmVu
dHMKK3NvIHRoYXQgdGhlIGZvY3VzIGV2ZW50IGNvbWVzIGVpdGhlciBiZWZvcmUgb3IgYWZ0ZXIg
dGhlIG11bHRpLWV2ZW50IGtleQorc2VxdWVuY2UsIGFuZCBub3Qgd2l0aGluIGl0LgogCi1Gb2N1
cyBldmVudHMgYXJlIHJlcHJlc2VudGVkIGluIExpc3AgYXMgbGlzdHMgdGhhdCBsb29rIGxpa2Ug
dGhpczoKK0BoZWFkaW5nIEZvY3VzIGV2ZW50cyBmb3IgZnJhbWVzCisKK1RoZSBub3JtYWwgZGVm
aW5pdGlvbiBvZiBhIGZvY3VzIGV2ZW50IHRoYXQgc3dpdGNoZXMgZnJhbWVzLCBpbiB0aGUKK2ds
b2JhbCBrZXltYXAsIGlzIHRvIHNlbGVjdCB0aGF0IG5ldyBmcmFtZSB3aXRoaW4gRW1hY3MsIGFz
IHRoZSB1c2VyCit3b3VsZCBleHBlY3QuICBAeHJlZntJbnB1dCBGb2N1c30sIHdoaWNoIGFsc28g
ZGVzY3JpYmVzIGhvb2tzIHJlbGF0ZWQgdG8KK2ZvY3VzIGV2ZW50cyBmb3IgZnJhbWVzLiAgRm9j
dXMgZXZlbnRzIGZvciBmcmFtZXMgYXJlIHJlcHJlc2VudGVkIGluCitMaXNwIGFzIGxpc3RzIHRo
YXQgbG9vayBsaWtlIHRoaXM6CiAKIEBleGFtcGxlCiAoc3dpdGNoLWZyYW1lIEB2YXJ7bmV3LWZy
YW1lfSkKQEAgLTIzMjEsMTkgKzIzNDAsMjggQEAgRm9jdXMgRXZlbnRzCiB3aGVyZSBAdmFye25l
dy1mcmFtZX0gaXMgdGhlIGZyYW1lIHN3aXRjaGVkIHRvLgogCiBTb21lIFggd2luZG93IG1hbmFn
ZXJzIGFyZSBzZXQgdXAgc28gdGhhdCBqdXN0IG1vdmluZyB0aGUgbW91c2UgaW50byBhCi13aW5k
b3cgaXMgZW5vdWdoIHRvIHNldCB0aGUgZm9jdXMgdGhlcmUuICBVc3VhbGx5LCB0aGVyZSBpcyBu
byBuZWVkCi1mb3IgYSBMaXNwIHByb2dyYW0gdG8ga25vdyBhYm91dCB0aGUgZm9jdXMgY2hhbmdl
IHVudGlsIHNvbWUgb3RoZXIKLWtpbmQgb2YgaW5wdXQgYXJyaXZlcy4gIEVtYWNzIGdlbmVyYXRl
cyBhIGZvY3VzIGV2ZW50IG9ubHkgd2hlbiB0aGUKLXVzZXIgYWN0dWFsbHkgdHlwZXMgYSBrZXli
b2FyZCBrZXkgb3IgcHJlc3NlcyBhIG1vdXNlIGJ1dHRvbiBpbiB0aGUKLW5ldyBmcmFtZTsganVz
dCBtb3ZpbmcgdGhlIG1vdXNlIGJldHdlZW4gZnJhbWVzIGRvZXMgbm90IGdlbmVyYXRlIGEKLWZv
Y3VzIGV2ZW50LgorZnJhbWUgaXMgZW5vdWdoIHRvIHNldCB0aGUgZm9jdXMgdGhlcmUuICBVc3Vh
bGx5LCB0aGVyZSBpcyBubyBuZWVkIGZvciBhCitMaXNwIHByb2dyYW0gdG8ga25vdyBhYm91dCB0
aGUgZm9jdXMgY2hhbmdlIHVudGlsIHNvbWUgb3RoZXIga2luZCBvZgoraW5wdXQgYXJyaXZlcy4g
IEVtYWNzIGdlbmVyYXRlcyBhIGZvY3VzIGV2ZW50IG9ubHkgd2hlbiB0aGUgdXNlcgorYWN0dWFs
bHkgdHlwZXMgYSBrZXlib2FyZCBrZXkgb3IgcHJlc3NlcyBhIG1vdXNlIGJ1dHRvbiBpbiB0aGUg
bmV3CitmcmFtZTsganVzdCBtb3ZpbmcgdGhlIG1vdXNlIGJldHdlZW4gZnJhbWVzIGRvZXMgbm90
IGdlbmVyYXRlIGEgZm9jdXMKK2V2ZW50LgogCi1BIGZvY3VzIGV2ZW50IGluIHRoZSBtaWRkbGUg
b2YgYSBrZXkgc2VxdWVuY2Ugd291bGQgZ2FyYmxlIHRoZQotc2VxdWVuY2UuICBTbyBFbWFjcyBu
ZXZlciBnZW5lcmF0ZXMgYSBmb2N1cyBldmVudCBpbiB0aGUgbWlkZGxlIG9mIGEga2V5Ci1zZXF1
ZW5jZS4gIElmIHRoZSB1c2VyIGNoYW5nZXMgZm9jdXMgaW4gdGhlIG1pZGRsZSBvZiBhIGtleQot
c2VxdWVuY2UtLS10aGF0IGlzLCBhZnRlciBhIHByZWZpeCBrZXktLS10aGVuIEVtYWNzIHJlb3Jk
ZXJzIHRoZSBldmVudHMKLXNvIHRoYXQgdGhlIGZvY3VzIGV2ZW50IGNvbWVzIGVpdGhlciBiZWZv
cmUgb3IgYWZ0ZXIgdGhlIG11bHRpLWV2ZW50IGtleQotc2VxdWVuY2UsIGFuZCBub3Qgd2l0aGlu
IGl0LgorQGhlYWRpbmcgRm9jdXMgZXZlbnRzIGZvciB3aW5kb3dzCisKK1doZW4gQHZhcnttb3Vz
ZS1hdXRvc2VsZWN0LXdpbmRvd30gaXMgc2V0LCBtb3ZpbmcgdGhlIG1vdXNlIG92ZXIgYSBuZXcK
K3dpbmRvdyB3aXRoaW4gYSBmcmFtZSBjYW4gYWxzbyBzd2l0Y2ggdGhlIHNlbGVjdGVkIHdpbmRv
dy4gIEB4cmVme01vdXNlCitXaW5kb3cgQXV0by1zZWxlY3Rpb259LCB3aGljaCBkZXNjcmliZXMg
dGhlIGJlaGF2aW9yIGZvciBkaWZmZXJlbnQKK3ZhbHVlcy4gIFdoZW4gdGhlIG1vdXNlIGlzIG1v
dmVkIG92ZXIgYSBuZXcgd2luZG93LCBhIGZvY3VzIGV2ZW50IGZvcgorc3dpdGNoaW5nIHdpbmRv
d3MgaXMgZ2VuZXJhdGVkLiAgRm9jdXMgZXZlbnRzIGZvciB3aW5kb3dzIGFyZQorcmVwZXJlc2Vu
dGVkIGluIExpc3AgYXMgbGlzdHMgdGhhdCBsb29rIGxpa2UgdGhpczoKKworQGV4YW1wbGUKKyhz
ZWxlY3Qtd2luZG93IEB2YXJ7bmV3LXdpbmRvd30pCitAZW5kIGV4YW1wbGUKKworQG5vaW5kZW50
Cit3aGVyZSBAdmFye25ldy13aW5kb3d9IGlzIHRoZSB3aW5kb3cgc3dpdGNoZWQgdG8uCiAKIEBu
b2RlIFh3aWRnZXQgRXZlbnRzCiBAc3Vic2VjdGlvbiBYd2lkZ2V0IGV2ZW50cwpkaWZmIC0tZ2l0
IGEvZG9jL2xpc3ByZWYvd2luZG93cy50ZXhpIGIvZG9jL2xpc3ByZWYvd2luZG93cy50ZXhpCmlu
ZGV4IGVlZjA1ZDk0ZmRiLi41NGVmMzg1MTgyMCAxMDA2NDQKLS0tIGEvZG9jL2xpc3ByZWYvd2lu
ZG93cy50ZXhpCisrKyBiL2RvYy9saXNwcmVmL3dpbmRvd3MudGV4aQpAQCAtNjE3Nyw3ICs2MTc3
LDcgQEAgTW91c2UgV2luZG93IEF1dG8tc2VsZWN0aW9uCiB0aGUgbW91c2UgcG9pbnRlci4gIFRo
aXMgYWNjb21wbGlzaGVzIGEgcG9saWN5IHNpbWlsYXIgdG8gdGhhdCBvZgogd2luZG93IG1hbmFn
ZXJzIHRoYXQgZ2l2ZSBmb2N1cyB0byBhIGZyYW1lIChhbmQgdGh1cyB0cmlnZ2VyIGl0cwogc3Vi
c2VxdWVudCBzZWxlY3Rpb24pIHdoZW5ldmVyIHRoZSBtb3VzZSBwb2ludGVyIGVudGVycyBpdHMK
LXdpbmRvdy1zeXN0ZW0gd2luZG93IChAcHhyZWZ7SW5wdXQgRm9jdXN9KS4KK3dpbmRvdy1zeXN0
ZW0gd2luZG93IChAcHhyZWZ7SW5wdXQgRm9jdXN9LCBAcHhyZWZ7Rm9jdXMgRXZlbnRzfSkuCiAK
IEBkZWZvcHQgbW91c2UtYXV0b3NlbGVjdC13aW5kb3cKIElmIHRoaXMgdmFyaWFibGUgaXMgbm9u
LUBjb2Rle25pbH0sIEVtYWNzIHdpbGwgdHJ5IHRvIGF1dG9tYXRpY2FsbHkKLS0gCjIuMzkuMgoK
--=_f7681a0e6a021cb402e69c3be2894889--




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

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


Received: (at 69915) by debbugs.gnu.org; 30 Mar 2024 17:07:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Mar 30 13:07:16 2024
Received: from localhost ([127.0.0.1]:46123 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rqcAl-0002iu-Sq
	for submit <at> debbugs.gnu.org; Sat, 30 Mar 2024 13:07:16 -0400
Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:58372)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <olaf.rogalsky@HIDDEN>) id 1rqcAi-0002i3-Fk
 for 69915 <at> debbugs.gnu.org; Sat, 30 Mar 2024 13:07:14 -0400
Received: by mail-wm1-x331.google.com with SMTP id
 5b1f17b1804b1-4154471fb81so17640315e9.0
 for <69915 <at> debbugs.gnu.org>; Sat, 30 Mar 2024 10:07:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1711818424; x=1712423224; darn=debbugs.gnu.org;
 h=mime-version:message-id:in-reply-to:date:subject:cc:to:from
 :user-agent:references:from:to:cc:subject:date:message-id:reply-to;
 bh=wikve3owC+6MsU944FLoz9rGd34/xJbKs1jEVlj7mps=;
 b=IxQfKZiD+pZX0g8jFQkH2Hdi6SfSg+6m5Hdvf26Gmd6LGmLZjkxVYDBxvlHrtnuyqY
 gWc5NZHz+KPah/hmt6WLF7JVEQV70Rz/bQIHDmbJgw6mPVpP35K9+JqKQG6WM+3fbEbU
 u3okYj88JWp0vuWHHFf1ZEduj/YuobywmBCF9BLYVONPuYrA98a+xiOJ3t6LTPkScjTW
 auvDnPP/2iLHsydPp1T48M4xi2zXTmCNB1ruW2WDuu6ncs2JJdnyq8Vr2JbhrrIl73S9
 /8GE6WoJn7jw6bqf5jcVnCZYQvUynsNr0gfLoT1oOPLkeV24by38DJOvFl0GFdhis7Qc
 XG+g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1711818424; x=1712423224;
 h=mime-version:message-id:in-reply-to:date:subject:cc:to:from
 :user-agent:references:x-gm-message-state:from:to:cc:subject:date
 :message-id:reply-to;
 bh=wikve3owC+6MsU944FLoz9rGd34/xJbKs1jEVlj7mps=;
 b=umMU72QHGp4ykSC2RvN9Mn8TSw/yE1LWp5ly4Uyegofo/+8pUspscE9IgUXlbHFIeY
 0IdFrddEyfJxZDH3F7/igx4Plt9Brw+TCGxoAL6DvfvaSrKEUWqwF5DqG0wzvl62d1jY
 ++Or43ks+tAdiaa481DN7pqMVPz/4+FjyTq6sbTMBxASdEjiqg1IDE0H+wCPG4mzELbq
 VDXWJyMA4SqkwS9Ps8GZMpKsYQuhw7anHUqZZ1mc5dftTLDYes+dp7vy9QSBRpgBRLUE
 ozT1nT1sWlWrmh5E/SYZ+pW+IGrjkJfseTQbLmLQMz9UtpN9PlH3K9F8TmEhKmPRI3z4
 sBTg==
X-Forwarded-Encrypted: i=1;
 AJvYcCVt3hYU4dn/2h1sMoruw7B2bW8+Ob+sN4V2RvfYdULCydgic/8fudsSI+9YQdKMrpG7Z6SO6x/bD/rFcMLrWASzxKjQjBY=
X-Gm-Message-State: AOJu0YzdXUyGrVh6ALXB3flG4MybsbvpPZRrhjk224GXJf8gfk89Ro6Q
 SgRTLh1rorTnPw7ZWfiEKPRVGU9hCjHo4pZWe2bhFJH9YZNBKDt1NE3RPs22+v0=
X-Google-Smtp-Source: AGHT+IGIIMH7/WtxSxNKBszFBo1nBiZbpolIyyVnG0EFl6K6GAVQ2rpr602YcJhr+H2wQr3NBBfVIw==
X-Received: by 2002:adf:e052:0:b0:341:be5f:ff21 with SMTP id
 w18-20020adfe052000000b00341be5fff21mr3544516wrh.55.1711818424189; 
 Sat, 30 Mar 2024 10:07:04 -0700 (PDT)
Received: from blaubaer ([2a02:8070:d283:5000:e9ff:6c98:9df:2a12])
 by smtp.gmail.com with ESMTPSA id
 dp18-20020a0560000c9200b00341de138a2esm6856800wrb.94.2024.03.30.10.07.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Mar 2024 10:07:03 -0700 (PDT)
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN>
User-agent: mu4e 1.9.11; emacs 30.0.50
From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
Date: Sat, 30 Mar 2024 18:03:37 +0100
In-reply-to: <86v856hon0.fsf@HIDDEN>
Message-ID: <87ttkny7gp.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, Jared Finder <jared@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 (-)

--=-=-=
Content-Type: text/plain

Hi Jared and Eli,

Jared Finder <jared@HIDDEN> writes:
> On 2024-03-26 16:50, Olaf Rogalsky wrote:
>> Hi Jared,
>> 
>>> >> <select-window> events shouldn't be generated while the mouse is being
>>> >> dragged. This probably is reflected in fully by track-mouse, but I'd
>>> >> suggest looking at the native code that generates the event to confirm.
>>> > Truly understanding xterm.c unfortunately is beyond my expertise. Nevertheless I
>>> > tested, the behavior. Dragging the mouse from one window to the next
>>> > (while passing over
>>> > the modeline) gives the following sequence of events:
> ... elided comments ...
>>> > Can't follow you here. At which occasion two events might be generated
>>> > and which ones?
>>> > I was thinking that if both a mouse movement and select window
>>> > event should both be returned, like if track-mouse is non-nil and
>>> > you switch windows.  Can you test this case?
>> Test case 1:
>> (track-mouse
>>   (setq mouse-autoselect-window t)
>>   (let (e)
>>     (while (not (eq e ?q))
>>       (setq e (read-key))
>>       (when (and (consp e) (symbolp (car e)))
>>           (message "%s to %s at posn %s" (car e) (caadr e) (posn-x-y
>> (cadr e)))))))
>> Result with patched terminal:
> ... elided results ...
>> For the second test case I use read-key-sequence instead of read-key
>> Test case 2:
>> (track-mouse
>>   (let ((can-return-switch-frame t) e)
>>     (while (not (equal e "q"))
>>       (setq e (read-key-sequence nil nil t can-return-switch-frame
>> nil))
>>       (when (not (stringp e))
>>           (setq e (seq-elt e 0))
>>           (message "%s to %s at posn %s" (car e) (caadr e) (posn-x-y
>> (cadr e)))))))
>> Result with patched terminal:
> ... elided results ...
>> So, read-key behaves differently in the terminal compared to X11:
>> In the terminal, the can-return-switch-frame parameter of
>> read-key-sequence
...
>> But apparently these lines are never executed in the case of the
>> terminal input.
...
> One last experiment is worth trying here.  If this doesn't work out, I
> think a FIXME will be sufficient.  Instead of returning the
> <select-window> event, try pushing the <select-window> event onto
> unread-command-events.  My thought is that this will let native code
> dequeue and handle the event normally, including taking
> can_return_switch_frame into account.  Can you please try this?

Good idea, this solved the inconsistency.


> Looking at xterm.c, I think you also want a test against
> window-minibuffer-p.
...
> My gut is to assume that the X and GTK behavior is most likely to be 
> better tested and more correct, but I defer to Eli here.
>> I tend to agree.  But, just to be sure, can you or Olaf describe the
>> exact issue and how it could happen, and perhaps show a recipe to try
>> reproducing it?  I'd like to take a closer look at the relevant code.

Jared alreaddy answered your question. I added the test against the
minibuffer, like xterm.c and pgtkterm.c do.


>>> I also commented out a condition, which ensures that the selection of a 
>>> window can only occur, if the mouse is in the text area of the window. 
>>> This matches the following sentence of the documentation:
>>> "In either case, the mouse pointer must enter the text area of a window 
>>> in order to trigger its selection."
>>> But I found no situation, where it did matter and msdos.c didn't have 
>>> that test, either. WDYT?
>> I think the documentation is incorrect and this commented out case
>> should be removed.  Local testing on PGTK and Mac shows that the mouse
>> pointer can be over the window dividers, widget scroll bars, or
>> fringes and still have autoselect behavior activate.
> Is this at all relevant for TTY frames?  Everything is "text area" on
> TTY frames, right?  If not, what are the use cases where the mouse
> would be "not in the text area" on a TTY frame, in the context of
> auto-selecting a window?

I interpreted the phrase "text area" as those parts of the frame, which
show the contents of buffers, i.e. without modeline, window separators,
tab-bar, menu-bar. In other words, anything where posn-area returns nil.

Nevertheless, since no other backend checks for the text area, I removed
the out-commented test.


>> I can't find the documentation of the format of the select-window
>> event. Maybe its a good idea to add it.
> Agreed.  I think it should be added to Focus Events in commands.texi.

But probaly by someone who knows the texi format and has a better
command of the english language than I do. Sorry.

Olaf



PS: sorry for the horrible formatting of the previous messages: I
usually do not use my gmail account ... Hope, this one comes out better.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline;
 filename=0001-Fix-user-option-mouse-autoselect-window-for-tty-emac.patch

From 8de818075ff5e583e25d4f408b9333fac2c37a3c Mon Sep 17 00:00:00 2001
From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
Date: Sat, 30 Mar 2024 17:00:51 +0100
Subject: [PATCH] Fix user option mouse-autoselect-window for tty emacs

Generate select-window events, so that mouse-autoselect-window takes
effect in tty emacs, when xterm-mouse-mode is enabled (Bug#69915).
* lisp/xt-mouse.el (xterm-mouse-translate-1):
If mouse-autoselect-window is non-nil, add select-window events to
unread-command-events.
---
 lisp/xt-mouse.el | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 081b8f32456..783718b4ba4 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -60,7 +60,9 @@ xterm-mouse-translate-1
     (let* ((event (xterm-mouse-event extension))
 	   (ev-command (nth 0 event))
 	   (ev-data    (nth 1 event))
+	   (ev-window  (nth 0 ev-data))
 	   (ev-where   (nth 1 ev-data))
+	   (last-window (terminal-parameter nil 'xterm-mouse-last-window))
 	   (vec (vector event))
 	   (is-move (eq 'mouse-movement ev-command))
 	   (is-down (string-match "down-" (symbol-name ev-command))))
@@ -73,6 +75,9 @@ xterm-mouse-translate-1
                                 'mouse-movement
                               'mouse-click)))
 
+      ;; remember window of current mouse position
+      (set-terminal-parameter nil 'xterm-mouse-last-window ev-window)
+
       (cond
        ((null event) nil)		;Unknown/bogus byte sequence!
        (is-down
@@ -84,10 +89,22 @@ xterm-mouse-translate-1
 	vec)
        (is-move
         (xterm-mouse--handle-mouse-movement)
-        (if track-mouse vec
-          ;; Mouse movement events are currently supposed to be
-          ;; suppressed.  Return no event.
-          []))
+        ;; after mouse movement autoselect the mouse window, but ...
+	(cond ((and mouse-autoselect-window
+                    ;; ignore modeline, tab-bar, menu-bar and so forth ...
+		    (windowp ev-window)
+                    ;; and don't deselect the minibuffer ...
+                    (not (window-minibuffer-p (selected-window)))
+                    ;; and select only, if mouse is over a new window ...
+                    (not (eq ev-window last-window))
+                    ;; which is different from the selected window
+		    (not (eq ev-window (selected-window))))
+	       (put 'select-window 'event-kind 'switch-frame)
+	       (push `(select-window (,ev-window)) unread-command-events)
+               [])
+	       ;;(vector `(select-window (,ev-window))))
+              (track-mouse vec)
+              (t [])))
        (t
 	(let* ((down (terminal-parameter nil 'xterm-mouse-last-down))
 	       (down-data (nth 1 down))

--=-=-=--




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

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


Received: (at 69915) by debbugs.gnu.org; 28 Mar 2024 14:41:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 28 10:41:34 2024
Received: from localhost ([127.0.0.1]:40905 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rpqwf-0006vP-UM
	for submit <at> debbugs.gnu.org; Thu, 28 Mar 2024 10:41:34 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:50150)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rpqwc-0006uo-Mu
 for 69915 <at> debbugs.gnu.org; Thu, 28 Mar 2024 10:41:31 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1711636889; bh=m7P5ukUuZxYIrt+KjaKzUl8uAnNju5JHO5FknvFFoCI=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=i+ip8WRqE0deSLnNuVF4Gk4BmQRv0Bw42J0PtdIhSXZMu1EjZq6TaJAwsmKaXVVow
 zhtVSBp/+Lgnjda9ZPJ08R+d3WlJpWlWfW1VrEpXWfg5wnSuNrYsf2/ctB8vQozwYR
 fBVIjz5zVGsYTXIH4vuAjpfQD6g7kAgK3CSg/NRsZ4O3sAHM39yDsjJNpaosTx3X2H
 8a/5utg5C24KGLI2V2/pTR+gNJyOdL54OMA2985G1EL1w/k5tQZgO83bSi17L/KXlC
 UA/5zW8dXlfAqzIlpkQzPRyhWokEdfYPCoUizhV2bU+22za0w2eXPJLflle8tfY/HK
 zQCglIUjf84PA==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id F009760A;
 Thu, 28 Mar 2024 14:41:28 +0000 (UTC)
MIME-Version: 1.0
Date: Thu, 28 Mar 2024 07:41:28 -0700
From: Jared Finder <jared@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
In-Reply-To: <86v856hon0.fsf@HIDDEN>
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
 <86v856hon0.fsf@HIDDEN>
Message-ID: <00f0925f3a878950933691973fecd536@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <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: -1.0 (-)

On 2024-03-27 23:11, Eli Zaretskii wrote:
>> Date: Wed, 27 Mar 2024 14:47:27 -0700
>> From: Jared Finder <jared@HIDDEN>
>> Cc: eliz@HIDDEN, 69915 <at> debbugs.gnu.org
>> 
>> > On the other hand, looking at msdos.c, there is no test against
>> > the minibuffer. I believed, that the selection of the minibuffer
>> > is taken care of at +10638 of window.el. In my tests the patch
>> > behaves exactly like the documentation, quote: "Mouse
>> > auto-selection selects the minibuffer window only if it is active,
>> > and never deselects the active minibuffer window."  I added the
>> > test, but commented it out.
>> 
>> I'm not sure what the right way to proceed here is then.  Eli, can you
>> give advice?
>> 
>> Looking at different OS files that handle mouse_autoselect_window, I 
>> see
>> the following state for checks if the selected window is a minibuffer
>> with MINI_WINDOW_P:
>> 
>> pgtkterm.c: checks
>> w32term.c: does NOT check
>> w32inevt.c: does NOT check
>> nsterm.m: checks
>> xterm.c: checks
>> msdos.c: does NOT check
>> haikuterm.c: checks
>> androidterm.c: checks
>> term.c: no support for mouse-autoselect-window. :(
>> 
>> My gut is to assume that the X and GTK behavior is most likely to be
>> better tested and more correct, but I defer to Eli here.
> 
> I tend to agree.  But, just to be sure, can you or Olaf describe the
> exact issue and how it could happen, and perhaps show a recipe to try
> reproducing it?  I'd like to take a closer look at the relevant code.

The intended behavior is that is even with mouse-autoselect-window set, 
moving the mouse is never supposed to change the selected window away 
from the minibuffer.  Many platforms explicitly check if the selected 
window is the minibuffer before emitting the <select-window> event, but 
not all platforms do (see list above).

And on all platforms, including ones without the explicit check we get 
the intended behavior from our testing.

So my question is should we copy the explicit check to prevent 
<select-window> events from being emitted to xt-mouse.el as well, even 
though it does not appear to be necessary from our testing?

   -- MJF




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

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


Received: (at 69915) by debbugs.gnu.org; 28 Mar 2024 06:11:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 28 02:11:29 2024
Received: from localhost ([127.0.0.1]:38802 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rpiz2-0003h7-NE
	for submit <at> debbugs.gnu.org; Thu, 28 Mar 2024 02:11:29 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:48854)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rpiyy-0003gI-OE
 for 69915 <at> debbugs.gnu.org; Thu, 28 Mar 2024 02:11:27 -0400
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 1rpiyr-0007qV-Jq; Thu, 28 Mar 2024 02:11:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=D0Uh5fxFNi6ZFpPJ9AoilEzLqYGoEYZx3rlMydyrn1k=; b=Dx5OdjQ+GQCp
 Pnt89qE/UzR9dC+TsNwe9+foYBSlQfUZ+bTDWGYRMJ7Bb3PH0w4QewOiC6YIpygIVhdgRvBPkTAC/
 qKirKMs6yEl5bIY41uX8ORSk6mGEwAmVOA1WbnziIW7QEYozD7I1+Cro7DnyZO7cU9+Vqf7fo5IOD
 w2oPj5hxbXbDkb1uGLKvGs97lEVH0BcCYcPJONqoawQHapjLxwo0FERrxXRSo/EIQEZtm3edYM4Fq
 631A80vSoKLr5WMZAPdT6jVa5id5RZKCbubkurpG3X5UMPf51sX5YGLcyNk7rkjUs9yhe3nzyG2cN
 rcOChn+5OEOF1Pybq9Ja4g==;
Date: Thu, 28 Mar 2024 08:11:15 +0200
Message-Id: <86v856hon0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jared Finder <jared@HIDDEN>
In-Reply-To: <ccee203b8dfca24884589cae13bb197e@HIDDEN> (message from Jared
 Finder on Wed, 27 Mar 2024 14:47:27 -0700)
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
References: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <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 (---)

> Date: Wed, 27 Mar 2024 14:47:27 -0700
> From: Jared Finder <jared@HIDDEN>
> Cc: eliz@HIDDEN, 69915 <at> debbugs.gnu.org
> 
> > On the other hand, looking at msdos.c, there is no test against
> > the minibuffer. I believed, that the selection of the minibuffer
> > is taken care of at +10638 of window.el. In my tests the patch
> > behaves exactly like the documentation, quote: "Mouse
> > auto-selection selects the minibuffer window only if it is active,
> > and never deselects the active minibuffer window."  I added the
> > test, but commented it out.
> 
> I'm not sure what the right way to proceed here is then.  Eli, can you 
> give advice?
> 
> Looking at different OS files that handle mouse_autoselect_window, I see 
> the following state for checks if the selected window is a minibuffer 
> with MINI_WINDOW_P:
> 
> pgtkterm.c: checks
> w32term.c: does NOT check
> w32inevt.c: does NOT check
> nsterm.m: checks
> xterm.c: checks
> msdos.c: does NOT check
> haikuterm.c: checks
> androidterm.c: checks
> term.c: no support for mouse-autoselect-window. :(
> 
> My gut is to assume that the X and GTK behavior is most likely to be 
> better tested and more correct, but I defer to Eli here.

I tend to agree.  But, just to be sure, can you or Olaf describe the
exact issue and how it could happen, and perhaps show a recipe to try
reproducing it?  I'd like to take a closer look at the relevant code.

> > I also commented out a condition, which ensures that the selection of a 
> > window can only occur, if the mouse is in the text area of the window. 
> > This matches the following sentence of the documentation:
> > "In either case, the mouse pointer must enter the text area of a window 
> > in order to trigger its selection."
> > But I found no situation, where it did matter and msdos.c didn't have 
> > that test, either. WDYT?
> 
> I think the documentation is incorrect and this commented out case 
> should be removed.  Local testing on PGTK and Mac shows that the mouse 
> pointer can be over the window dividers, widget scroll bars, or fringes 
> and still have autoselect behavior activate.

Is this at all relevant for TTY frames?  Everything is "text area" on
TTY frames, right?  If not, what are the use cases where the mouse
would be "not in the text area" on a TTY frame, in the context of
auto-selecting a window?

> >> > +           (progn
> >> > +             (put 'select-window 'event-kind 'switch-frame)
> >> > +             (setf (car event) 'select-window)
> >> > +             vec)
> >> > I think this should be an event that's just select-window and the window, to line up with what the select-window event looks like on other platforms (I tested PGTK and Windows terminal).  You can verify this by running M-x trace-function RET handle-select-window RET.
> >> > That would instead be something like:
> >> > (progn
> >>   (put 'select-window 'event-kind 'switch-frame)
> >>   (vector `(select-window (,ev-window)))
> > 
> > I can't find the documentation of the format of the select-window 
> > event. Maybe its a good idea to add it.
> 
> Agreed.  I think it should be added to Focus Events in commands.texi.

I agree.

> > Please find below the next iteration of the patch.
> 
> Assuming above comments are addressed, this looks good to me.  I imagine 
> there will be minor comment reformatting to avoid going beyond 80 
> columns.

Thanks, please post the final version after these minor changes for
review.

Thanks.




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

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


Received: (at 69915) by debbugs.gnu.org; 27 Mar 2024 21:47:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 27 17:47:34 2024
Received: from localhost ([127.0.0.1]:38467 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rpb7L-0007nX-GH
	for submit <at> debbugs.gnu.org; Wed, 27 Mar 2024 17:47:34 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:49712)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rpb7J-0007nA-0S
 for 69915 <at> debbugs.gnu.org; Wed, 27 Mar 2024 17:47:30 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1711576047; bh=i76/afDARrIIl01qH6vYOFDD381rtJqjlveEH0UwnVA=;
 h=Date:From:To:Cc:Subject:From;
 b=0t4bT5gOStocNsT8dA7TLbA1bAcHA+4BVAX3QM8pgRlAIRmUG+x69bcXm+totrFeF
 xMn82oG9P20ahO0zc84vp7CTa62zceztJEoSP3cfrlfUhpJMkn2YCJEJhmUvM0AUg5
 Q0+BVv510xx+Ax477BtaLGgWXKjV+aQ4TAhWNfTg+F/aQJB0wJLRDjPnrVylp2JU4J
 0qYbkwiqANq7uUbtm0V0gXIcYnWXGM1bZwMFTL69aEQbPrWd3uV/Cgurd4eNYDh/5+
 Ya9KyKbB1MlPOi1flR8xvz+o82lfXr3VpC+fYvjCPDcWDEDiBZYYQf5oxQlVslv8JV
 +9wwQOnCUlVXw==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id 8F7A960A;
 Wed, 27 Mar 2024 21:47:27 +0000 (UTC)
MIME-Version: 1.0
Date: Wed, 27 Mar 2024 14:47:27 -0700
From: Jared Finder <jared@HIDDEN>
To: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
Message-ID: <ccee203b8dfca24884589cae13bb197e@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, eliz@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 (-)

On 2024-03-26 16:50, Olaf Rogalsky wrote:
> Hi Jared,
> 
>> >> <select-window> events shouldn't be generated while the mouse is being
>> >> dragged. This probably is reflected in fully by track-mouse, but I'd
>> >> suggest looking at the native code that generates the event to confirm.
>> > Truly understanding xterm.c unfortunately is beyond my expertise. Nevertheless I
>> > tested, the behavior. Dragging the mouse from one window to the next
>> > (while passing over
>> > the modeline) gives the following sequence of events:
... elided comments ...
>> > Can't follow you here. At which occasion two events might be generated
>> > and which ones?
>> > I was thinking that if both a mouse movement and select window event should both be returned, like if track-mouse is non-nil and you switch windows.  Can you test this case?
> 
> Test case 1:
> (track-mouse
>   (setq mouse-autoselect-window t)
> 
>   (let (e)
>     (while (not (eq e ?q))
>       (setq e (read-key))
>       (when (and (consp e) (symbolp (car e)))
>           (message "%s to %s at posn %s" (car e) (caadr e) (posn-x-y 
> (cadr e)))))))
> 
> Result with patched terminal:
... elided results ...
> 
> For the second test case I use read-key-sequence instead of read-key
> 
> Test case 2:
> 
> (track-mouse
>   (let ((can-return-switch-frame t) e)
>     (while (not (equal e "q"))
>       (setq e (read-key-sequence nil nil t can-return-switch-frame 
> nil))
>       (when (not (stringp e))
>           (setq e (seq-elt e 0))
>           (message "%s to %s at posn %s" (car e) (caadr e) (posn-x-y 
> (cadr e)))))))
> 
> Result with patched terminal:
... elided results ...
> 
> So, read-key behaves differently in the terminal compared to X11:
> In the terminal, the can-return-switch-frame parameter of 
> read-key-sequence
> has no effect and select-window events are always generated.
> 
> Fyi, the can-return-switch-frame parameter is handled at +10838 
> keyboard.c
> in the monstrous over 1000 lines long function read_key_sequence:
> 
> 	  if (EVENT_HAS_PARAMETERS (key)
> 	      /* Either a `switch-frame' or a `select-window' event.  */
> 	      && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)), Qswitch_frame))
> 	    {
> 	      /* If we're at the beginning of a key sequence, and the caller
> 		 says it's okay, go ahead and return this event.  If we're
> 		 in the midst of a key sequence, delay it until the end.  */
> 	      if (t > 0 || !can_return_switch_frame)
> 		{
> 		  delayed_switch_frame = key;
> 		  goto replay_key;
> 		}
> 	    }
> But apparently these lines are never executed in the case of the 
> terminal input.

Sadly, read_key_sequence in C code is quite a beast.

One last experiment is worth trying here.  If this doesn't work out, I 
think a FIXME will be sufficient.  Instead of returning the 
<select-window> event, try pushing the <select-window> event onto 
unread-command-events.  My thought is that this will let native code 
dequeue and handle the event normally, including taking 
can_return_switch_frame into account.  Can you please try this?

>> > autoselect the mouse window, but ...
>> > +                (windowp ev-window) ; ignore modeline, tab-bar,
>> > menu-bar and so forth ...
>> > +                ;;(not (posn-area (event-start event))) ; also
>> > ignore, if not inside of text area of window ...
>> > +                (not (eq ev-window last-window)) ; but only, if mouse
>> > is over new window ...
>> > +                (not (eq ev-window (selected-window)))) ; which is
>> > different from the selected window
>> > Looking at xterm.c, I think you also want a test against window-minibuffer-p.
> 
> On the other hand, looking at msdos.c, there is no test against the 
> minibuffer. I believed, that
> the selection of the minibuffer is taken care of at +10638 of 
> window.el. In my tests the patch
> behaves exactly like the documentation, quote: "Mouse auto-selection 
> selects the minibuffer window
> only if it is active, and never deselects the active minibuffer 
> window."
> I added the test, but commented it out.

I'm not sure what the right way to proceed here is then.  Eli, can you 
give advice?

Looking at different OS files that handle mouse_autoselect_window, I see 
the following state for checks if the selected window is a minibuffer 
with MINI_WINDOW_P:

pgtkterm.c: checks
w32term.c: does NOT check
w32inevt.c: does NOT check
nsterm.m: checks
xterm.c: checks
msdos.c: does NOT check
haikuterm.c: checks
androidterm.c: checks
term.c: no support for mouse-autoselect-window. :(

My gut is to assume that the X and GTK behavior is most likely to be 
better tested and more correct, but I defer to Eli here.

> I also commented out a condition, which ensures that the selection of a 
> window can only occur, if the mouse is in the text area of the window. 
> This matches the following sentence of the documentation:
> "In either case, the mouse pointer must enter the text area of a window 
> in order to trigger its selection."
> But I found no situation, where it did matter and msdos.c didn't have 
> that test, either. WDYT?

I think the documentation is incorrect and this commented out case 
should be removed.  Local testing on PGTK and Mac shows that the mouse 
pointer can be over the window dividers, widget scroll bars, or fringes 
and still have autoselect behavior activate.

>> > +           (progn
>> > +             (put 'select-window 'event-kind 'switch-frame)
>> > +             (setf (car event) 'select-window)
>> > +             vec)
>> > I think this should be an event that's just select-window and the window, to line up with what the select-window event looks like on other platforms (I tested PGTK and Windows terminal).  You can verify this by running M-x trace-function RET handle-select-window RET.
>> > That would instead be something like:
>> > (progn
>>   (put 'select-window 'event-kind 'switch-frame)
>>   (vector `(select-window (,ev-window)))
> 
> I can't find the documentation of the format of the select-window 
> event. Maybe its a good idea to add it.

Agreed.  I think it should be added to Focus Events in commands.texi.

> Please find below the next iteration of the patch.

Assuming above comments are addressed, this looks good to me.  I imagine 
there will be minor comment reformatting to avoid going beyond 80 
columns.

> diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
> index 081b8f32456..88c6c28b293 100644
> --- a/lisp/xt-mouse.el
> +++ b/lisp/xt-mouse.el
> @@ -60,7 +60,9 @@ xterm-mouse-translate-1
>      (let* ((event (xterm-mouse-event extension))
>            (ev-command (nth 0 event))
>            (ev-data    (nth 1 event))
> +          (ev-window  (nth 0 ev-data))
>            (ev-where   (nth 1 ev-data))
> +          (last-window (terminal-parameter nil 
> 'xterm-mouse-last-window))
>            (vec (vector event))
>            (is-move (eq 'mouse-movement ev-command))
>            (is-down (string-match "down-" (symbol-name ev-command))))
> @@ -73,6 +75,9 @@ xterm-mouse-translate-1
>                                  'mouse-movement
>                                'mouse-click)))
> 
> +      ;; remember window of current mouse position
> +      (set-terminal-parameter nil 'xterm-mouse-last-window ev-window)
> +
>        (cond
>         ((null event) nil)              ;Unknown/bogus byte sequence!
>         (is-down
> @@ -84,10 +89,16 @@ xterm-mouse-translate-1
>         vec)
>         (is-move
>          (xterm-mouse--handle-mouse-movement)
> -        (if track-mouse vec
> -          ;; Mouse movement events are currently supposed to be
> -          ;; suppressed.  Return no event.
> -          []))
> +       (cond ((and mouse-autoselect-window ; after mouse movement 
> autoselect the mouse window, but ...
> +                   (windowp ev-window) ; ignore modeline, tab-bar, 
> menu-bar and so forth ...
> +                   ;;(not (posn-area (event-start event))) ; also 
> ignore, if not inside of text area of window ...
> +                    ;;(not (window-minibuffer-p (selected-window))) ; 
> and don't deselect the minibuffer
> +                    (not (eq ev-window last-window)) ; and select 
> only, if mouse is over a new window ...
> +                   (not (eq ev-window (selected-window)))) ; which is 
> different from the selected window
> +              (put 'select-window 'event-kind 'switch-frame)
> +              (vector `(select-window (,ev-window))))
> +              (track-mouse vec)
> +              (t [])))
>         (t
>         (let* ((down (terminal-parameter nil 'xterm-mouse-last-down))
>                (down-data (nth 1 down))




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

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


Received: (at 69915) by debbugs.gnu.org; 26 Mar 2024 23:50:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 26 19:50:59 2024
Received: from localhost ([127.0.0.1]:35438 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rpGZE-0000kj-HK
	for submit <at> debbugs.gnu.org; Tue, 26 Mar 2024 19:50:59 -0400
Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:46280)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <olaf.rogalsky@HIDDEN>) id 1rpGZB-0000kM-MP
 for 69915 <at> debbugs.gnu.org; Tue, 26 Mar 2024 19:50:55 -0400
Received: by mail-wr1-x436.google.com with SMTP id
 ffacd0b85a97d-33ed5b6bf59so4378208f8f.0
 for <69915 <at> debbugs.gnu.org>; Tue, 26 Mar 2024 16:50:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1711497048; x=1712101848; darn=debbugs.gnu.org;
 h=mime-version:content-transfer-encoding:user-agent:references
 :in-reply-to:date:subject:cc:to:from:message-id:from:to:cc:subject
 :date:message-id:reply-to;
 bh=aTOHF4b7hH2COD5Y4KLla6VEnvS3NWJx5WBVog31PmA=;
 b=T/Teu9qC0/R7rqOQY1XJJH+Dcsg/XW5ZwmU/EVAUpCS53aQBAMyYtyq+TFeKJeLF5L
 8oMQ7Uc/aBP1FaEL6PFJmQ7N+Lz2mN6ZiuQzi42amo2OYLoek9vuFACBmeIwSH4o3pb6
 BTCo7xL4Hix2pLkHqZPxUrnb4IYUvvQ0sx3SSdFqNSFxRYkh6tjZoEvXxunq462bRm7D
 CzOdom4fCVtldMtVFW8K20R0Nxont+Vy7FB94S4HFWxuOQNd6AEW4Sr+2Eg1hOs8dz75
 AcURlDT0lVhrU8abCLjcftFkHkWBzYOZMJGTJvsm2hpIqhreEce0NpBIyXhFV1nznFOo
 nwhQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1711497048; x=1712101848;
 h=mime-version:content-transfer-encoding:user-agent:references
 :in-reply-to:date:subject:cc:to:from:message-id:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=aTOHF4b7hH2COD5Y4KLla6VEnvS3NWJx5WBVog31PmA=;
 b=JEL9ahAksB7PEWvC1RoeTD5NARwU+oF2ZrKBx4ECTewYRmH7TTYr5W2ih4355p36vQ
 TV/ED9UbhEWpKGNyeiCSvu01zpKseQ++axPub6VPkgx/TFwsMxA+r/UGE1PyG7QIPuu+
 c5PIHEF1f53jzaQ/JwkivMwAfjuvyJtknzM6VvHrtgEHyQb2mYkpzry5uiTbKRUrezy8
 bJpErsH+MCwos6rv+AmP/cN/M3MiADtXAZJs7U1Ex88ttg6DV7zKZt/SRgC6Q0/Hrt0J
 U5LHq/PgAYyqkD7SgJ1SXvmMHv1xcJWjJxdp2WlpWukQBMRxjaBX7fyRxXx7hjWyYeLW
 S9jw==
X-Forwarded-Encrypted: i=1;
 AJvYcCU1+JP+rxMDZsLCvhS10j40nOZoWA3YHrcIN5OlLM4QPZi/439OfIvGrHMl0IHvjqyw6YAJYmu0tJWCKYlqZYA7sY5fv+Q=
X-Gm-Message-State: AOJu0YxfmrDZ17I5R+5eaYc9DCmqUZekhW9CBLgsU3XwTZBgD5AhTETj
 n2abnGsZcc6JmcxNNZFJa1N2WIkczesZVJKGJAJnlqzjbo1wyR3l
X-Google-Smtp-Source: AGHT+IF8aCBCMqvo67HVtn4Z1aRAxU0XdH+5vgKZj4RpEs0BvyASOH7M+pSWeqfmdS7So1H0YLV+lA==
X-Received: by 2002:a05:6000:22d:b0:33e:867:b288 with SMTP id
 l13-20020a056000022d00b0033e0867b288mr1722628wrz.63.1711497047634; 
 Tue, 26 Mar 2024 16:50:47 -0700 (PDT)
Received: from noip.localdomain ([2a02:8070:d283:5000:e9ff:6c98:9df:2a12])
 by smtp.gmail.com with ESMTPSA id
 cc5-20020a5d5c05000000b00341d1a1d106sm5165581wrb.19.2024.03.26.16.50.46
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 26 Mar 2024 16:50:47 -0700 (PDT)
Content-Type: text/plain; charset=utf-8; format=flowed
Message-Id: <1711483727985.1884110205.3562502415@HIDDEN>
From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
To: Jared Finder <jared@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
Date: Tue, 26 Mar 2024 23:50:45 +0000
In-Reply-To: <11a3b53941f179d5e9b5d283f05c12be@HIDDEN>
References: <11a3b53941f179d5e9b5d283f05c12be@HIDDEN>
X-Mailer: Vivaldi Mail
User-Agent: Vivaldi Mail/6.5.3206.55
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, eliz@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 (-)


Hi Jared,

 > On 2024-03-24 12:27, Olaf Rogalsky wrote:
 > > Hi Jared,
 > > thanks for your feedback (answering this from my gmail account and
 > > hope this doesn't mess up the debbugs history).
 > > >> Are you certain you need the change to window.el as well? I'd be 
very
 > >> surprised if it is necessary to change
 > > ...
 > >> Is your setup is different somehow?
 > > No, but I forgot to mention, that the "nil <select-window> is 
undefined" error
 > > only occurred, iff mouse-autoselect-window had a numeric value.
 > > With my new patch, the error disappeared. I don't know why, but a
 > > change to window.el
 > > isn't necessary anymore. I still think, that the proposed change would
 > > be correct.
 > 
 > I'll defer to Eli here, but my general sentiment would be to leave 
window.el untouched unless a change is needed.  The event list returned was 
last changed in 2006 so it's reasonably stable.

I can't reproduce the error anymore, so I would leave it as is.


 > >> <select-window> events shouldn't be generated while the mouse is 
being
 > >> dragged. This probably is reflected in fully by track-mouse, but I'd
 > >> suggest looking at the native code that generates the event to 
confirm.
 > > Truly understanding xterm.c unfortunately is beyond my expertise. 
Nevertheless I
 > > tested, the behavior. Dragging the mouse from one window to the next
 > > (while passing over
 > > the modeline) gives the following sequence of events:
 > >  ESC [ < 3 5 ; 5 5 ; 4 1 M ESC [ < 0 ; 5 5 ; 4 1 M ;; 
mouse-drag-region
 > >  ESC [ < 3 2 ; 5 5 ; 4 2 M             ;; anonymous-command
 > >  ESC [ < 3 2 ; 5 5 ; 4 3 M             ;; anonymous-command
 > >  <help-echo> ESC [ < 3 2 ; 5 5 ; 4 4 M ;; ignore
 > >  ESC [ < 3 2 ; 5 6 ; 4 4 M             ;; anonymous-command
 > >  ESC [ < 0 ; 5 6 ; 4 4 m               ;; anonymous-command
 > >  <drag-mouse-1>                        ;; mouse-set-region
 > > So indeed, no select-window event is generated. As a result, dragging
 > > the mouse over the
 > > borders of the window results in a scrolling of the window. This
 > > matches the behavior of the
 > > X11 backend.
 > 
 > Thank you.  There's one remaining difference to handle that I highlight 
in the diff below.
 >
 > >> If there is a case where two events should be generated (not sure if
 > >> this case exists depending on above), we'd want to return both, but 
you
 > >> can only return a single key sequence from the translate function. I
 > >> think this case deserves a FIXME note.
 > > Can't follow you here. At which occasion two events might be generated
 > > and which ones?
 > 
 > I was thinking that if both a mouse movement and select window event 
should both be returned, like if track-mouse is non-nil and you switch 
windows.  Can you test this case?

Test case 1:
(track-mouse
   (setq mouse-autoselect-window t)

   (let (e)
     (while (not (eq e ?q))
       (setq e (read-key))
       (when (and (consp e) (symbolp (car e)))
           (message "%s to %s at posn %s" (car e) (caadr e) (posn-x-y (cadr 
e)))))))

Result with patched terminal:


mouse-movement to #<window 1 on *scratch*> at posn (65 . 40)
mouse-movement to #<window 1 on *scratch*> at posn (65 . 41)
select-window to #<window 4 on *scratch*> at posn (65 . 0)
mouse-movement to #<window 4 on *scratch*> at posn (64 . 0)
mouse-movement to #<window 4 on *scratch*> at posn (64 . 1)
=> select-window event is reported, but at a different posn as the next or
previous mouse-movement. So no simultaneous events for mouse-movement
and select-window.

Result for X11 backend

mouse-movement to #<window 3 on *scratch*> at posn (433 . 983)
mouse-movement to #<window 3 on *scratch*> at posn (432 . 1009)
mouse-movement to #<window 15 on *scratch*> at posn (423 . 0)
mouse-movement to #<window 15 on *scratch*> at posn (420 . 24)
=> no select-window event is reported to read-key at all!

For the second test case I use read-key-sequence instead of read-key

Test case 2:

(track-mouse
   (let ((can-return-switch-frame t) e)
     (while (not (equal e "q"))
       (setq e (read-key-sequence nil nil t can-return-switch-frame nil))
       (when (not (stringp e))
           (setq e (seq-elt e 0))
           (message "%s to %s at posn %s" (car e) (caadr e) (posn-x-y (cadr 
e)))))))

Result with patched terminal:


mouse-movement to #<window 1 on *scratch*> at posn (65 . 40)
mouse-movement to #<window 1 on *scratch*> at posn (65 . 41)
select-window to #<window 4 on *scratch*> at posn (65 . 0)
mouse-movement to #<window 4 on *scratch*> at posn (64 . 0)
mouse-movement to #<window 4 on *scratch*> at posn (64 . 1)
=> same as result for test case 1

Result for X11 backend:

mouse-movement to #<window 1 on *scratch*> at posn (43 . 39)
mouse-movement to #<window 1 on *scratch*> at posn (43 . 40)
select-window to #<window 4 on *scratch*> at posn (43 . 0)
mouse-movement to #<window 4 on *scratch*> at posn (43 . 1)
mouse-movement to #<window 4 on *scratch*> at posn (43 . 2)
=> Now a select window event is reported as in the terminal. And also
for X11: no simultaneous events for mouse-movement and select-window.

So, read-key behaves differently in the terminal compared to X11:
In the terminal, the can-return-switch-frame parameter of read-key-sequence
has no effect and select-window events are always generated.

Fyi, the can-return-switch-frame parameter is handled at +10838 keyboard.c
in the monstrous over 1000 lines long function read_key_sequence:

	  if (EVENT_HAS_PARAMETERS (key)
	      /* Either a `switch-frame' or a `select-window' event.  */
	      && EQ (EVENT_HEAD_KIND (EVENT_HEAD (key)), Qswitch_frame))
	    {
	      /* If we're at the beginning of a key sequence, and the caller
		 says it's okay, go ahead and return this event.  If we're
		 in the midst of a key sequence, delay it until the end.  */
	      if (t > 0 || !can_return_switch_frame)
		{
		  delayed_switch_frame = key;
		  goto replay_key;
		}
	    }
But apparently these lines are never executed in the case of the terminal 
input.


 > >> Did you try out switching frames? I'm not certain if <select-window> 
is
 > >> supposed to be generated when the frame is switched.
 > > Switching frames is not handled in xt-mouse.el. However, if you change
 > > the focus from another
 > > X11 window to the title bar of the terminal or wise-versa, no
 > > switch-frame event is generated. Instead,
 > > xterm-translate-focus-in/xterm-translate-focus-out are called via a
 > > binding in xterm-rxvt-function-map.
 > > These functions toggle the terminal parameter tty-focus-state between
 > > focused and defocused and then
 > > call after-focus-change-function, which also does not generate a
 > > switch-frame event.
 > > As far as I could find out, the X11 backend of emacs doesn't generate
 > > switch-frame events, either.
 > 
 > I was actually referring to using C-x 5 2 and C-x 5 o within a single 
terminal.  I tested this locally and it works fine.

Good!


 > > New patch:
 > > ... other parts of patch look good to me :) ...
 > > @@ -84,10 +89,19 @@ xterm-mouse-translate-1
 > >         vec)
 > >         (is-move
 > >          (xterm-mouse--handle-mouse-movement)
 > > -        (if track-mouse vec
 > > -          ;; Mouse movement events are currently supposed to be
 > > -          ;; suppressed.  Return no event.
 > > -          []))
 > > +       (if (and mouse-autoselect-window ; after mouse movement
 > 
 > Style nit: Can you please do this as a cond instead of a nested (if x y 
(if z u v))?

yes, of cause

 > > autoselect the mouse window, but ...
 > > +                (windowp ev-window) ; ignore modeline, tab-bar,
 > > menu-bar and so forth ...
 > > +                ;;(not (posn-area (event-start event))) ; also
 > > ignore, if not inside of text area of window ...
 > > +                (not (eq ev-window last-window)) ; but only, if mouse
 > > is over new window ...
 > > +                (not (eq ev-window (selected-window)))) ; which is
 > > different from the selected window
 > 
 > Looking at xterm.c, I think you also want a test against 
window-minibuffer-p.

On the other hand, looking at msdos.c, there is no test against the 
minibuffer. I believed, that
the selection of the minibuffer is taken care of at +10638 of window.el. In 
my tests the patch
behaves exactly like the documentation, quote: "Mouse auto-selection 
selects the minibuffer window
only if it is active, and never deselects the active minibuffer window."
I added the test, but commented it out.

I also commented out a condition, which ensures that the selection of a 
window can only occur, if 
the mouse is in the text area of the window. This matches the following 
sentence of the documentation:
"In either case, the mouse pointer must enter the text area of a window in 
order to trigger its selection."
But I found no situation, where it did matter and msdos.c didn't have that 
test, either. WDYT?


 > > +           (progn
 > > +             (put 'select-window 'event-kind 'switch-frame)
 > > +             (setf (car event) 'select-window)
 > > +             vec)
 > 
 > I think this should be an event that's just select-window and the 
window, to line up with what the select-window event looks like on other 
platforms (I tested PGTK and Windows terminal).  You can verify this by 
running M-x trace-function RET handle-select-window RET.
 > 
 > That would instead be something like:
 > 
 > (progn
 >   (put 'select-window 'event-kind 'switch-frame)
 >   (vector `(select-window (,ev-window)))

I can't find the documentation of the format of the select-window event. 
Maybe its a good idea to add it.

Please find below the next iteration of the patch.
Olaf







diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 081b8f32456..88c6c28b293 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -60,7 +60,9 @@ xterm-mouse-translate-1
      (let* ((event (xterm-mouse-event extension))
            (ev-command (nth 0 event))
            (ev-data    (nth 1 event))
+          (ev-window  (nth 0 ev-data))
            (ev-where   (nth 1 ev-data))
+          (last-window (terminal-parameter nil 'xterm-mouse-last-window))
            (vec (vector event))
            (is-move (eq 'mouse-movement ev-command))
            (is-down (string-match "down-" (symbol-name ev-command))))
@@ -73,6 +75,9 @@ xterm-mouse-translate-1
                                  'mouse-movement
                                'mouse-click)))

+      ;; remember window of current mouse position
+      (set-terminal-parameter nil 'xterm-mouse-last-window ev-window)
+
        (cond
         ((null event) nil)              ;Unknown/bogus byte sequence!
         (is-down
@@ -84,10 +89,16 @@ xterm-mouse-translate-1
         vec)
         (is-move
          (xterm-mouse--handle-mouse-movement)
-        (if track-mouse vec
-          ;; Mouse movement events are currently supposed to be
-          ;; suppressed.  Return no event.
-          []))
+       (cond ((and mouse-autoselect-window ; after mouse movement 
autoselect the mouse window, but ...
+                   (windowp ev-window) ; ignore modeline, tab-bar, 
menu-bar and so forth ...
+                   ;;(not (posn-area (event-start event))) ; also ignore, 
if not inside of text area of window ...
+                    ;;(not (window-minibuffer-p (selected-window))) ; and 
don't deselect the minibuffer
+                    (not (eq ev-window last-window)) ; and select only, if 
mouse is over a new window ...
+                   (not (eq ev-window (selected-window)))) ; which is 
different from the selected window
+              (put 'select-window 'event-kind 'switch-frame)
+              (vector `(select-window (,ev-window))))
+              (track-mouse vec)
+              (t [])))
         (t
         (let* ((down (terminal-parameter nil 'xterm-mouse-last-down))
                (down-data (nth 1 down))






































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

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


Received: (at 69915) by debbugs.gnu.org; 26 Mar 2024 13:44:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 26 09:44:39 2024
Received: from localhost ([127.0.0.1]:33082 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rp76V-0000eu-II
	for submit <at> debbugs.gnu.org; Tue, 26 Mar 2024 09:44:39 -0400
Received: from eggs.gnu.org ([209.51.188.92]:50322)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rp76S-0000eH-Vi
 for 69915 <at> debbugs.gnu.org; Tue, 26 Mar 2024 09:44:38 -0400
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 1rp5xk-0008DT-Gj; Tue, 26 Mar 2024 08:31:32 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=f7wFqhRlN0G4aqP3uNwP5RH0uoPn6IXdk8vP4t1B3zc=; b=KK3UYh0/UM/k
 xDsplZpikC0Cjk/rxCx5MbaAC91CQI/n6To0lXHQvjS7GMO2AECkq5Rven22pcex3OtQDL/3OIfih
 Qf8u7WhDoDjaBZz9C81OIZDll5AXN2dOgxt0Q1azz6AJFaUtM3owfk/KcWP4LhwdC7+j8lst4ZddB
 N7zYlpB4DTCTF4tjY6IsOzrRDmNHXyI37ffD+KoRid4plDiouL0R3zSgGozCp5rNIQEEkK1/TTWXu
 +vRckRSKotM4m43QsNHdjutUublMXzoY58wgCbW9BkyLgBj4CqZzFqhv32kZlvfJr4LW/5+sooRsm
 ueaWIy6LsABj0Soqgy2jZg==;
Date: Tue, 26 Mar 2024 14:31:03 +0200
Message-Id: <867chpjhtk.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Jared Finder <jared@HIDDEN>
In-Reply-To: <11a3b53941f179d5e9b5d283f05c12be@HIDDEN> (message from Jared
 Finder on Mon, 25 Mar 2024 14:53:15 -0700)
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
References: <CAFdQyhJaRxi7_=2DLTihV1oGOfU5Sz1-_ZEOgU=pf=CwuZ=0vA@HIDDEN>
 <11a3b53941f179d5e9b5d283f05c12be@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69915
Cc: olaf.rogalsky@HIDDEN, 69915 <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 (---)

> Date: Mon, 25 Mar 2024 14:53:15 -0700
> From: Jared Finder <jared@HIDDEN>
> Cc: eliz@HIDDEN, 69915 <at> debbugs.gnu.org
> 
> On 2024-03-24 12:27, Olaf Rogalsky wrote:
> > Hi Jared,
> > 
> > thanks for your feedback (answering this from my gmail account and
> > hope this doesn't mess up the debbugs history).
> > 
> >> Are you certain you need the change to window.el as well? I'd be very
> >> surprised if it is necessary to change
> > ...
> >> Is your setup is different somehow?
> > No, but I forgot to mention, that the "nil <select-window> is 
> > undefined" error
> > only occurred, iff mouse-autoselect-window had a numeric value.
> > With my new patch, the error disappeared. I don't know why, but a
> > change to window.el
> > isn't necessary anymore. I still think, that the proposed change would
> > be correct.
> 
> I'll defer to Eli here, but my general sentiment would be to leave 
> window.el untouched unless a change is needed.  The event list returned 
> was last changed in 2006 so it's reasonably stable.

I agree.

Olaf, if leaving window.el unchanged causes these errors, please show
a recipe for reproducing it, and let's try to investigate why it
happens, before we decide how to fix it.




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

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


Received: (at 69915) by debbugs.gnu.org; 25 Mar 2024 21:53:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 25 17:53:21 2024
Received: from localhost ([127.0.0.1]:36453 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rosFr-0002cr-DP
	for submit <at> debbugs.gnu.org; Mon, 25 Mar 2024 17:53:20 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:51150)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rosFo-0002cf-7e
 for 69915 <at> debbugs.gnu.org; Mon, 25 Mar 2024 17:53:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1711403595; bh=Ryi9bku00uk8c4d18P2CKGUUZg+gwiDDdzn0eIcF3js=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=xNGN3KDCLlHEcUg0PzcuanGpkETF73TSyYMSp32QtL8hF8DV9YqFi/SaSpDceDzHC
 6ECIgzqGtx7tlemxklbgkJmnxIDb5Qx9xfTYS+oywyKeXoKu45XsI/2l1Dcah6EDwR
 ADm2g6DoAI3XEZ28MsI7rcq61pTPzoI5kQlLnE5Z09JHcrt9TYDVc5LqLlYeUYacA9
 g84zkfNrgnMTUaEEANU8euwesPXKsFSnXqe209eqSqBQjlyvgSuveDLmbDPG4jszGM
 B+wmqnsQm4ADa68qAoioUcqDL/9eyUeGM9xPY8qxQG+OQ6neX3dbYLrmtuUMrCAcc/
 2mipw46RIVzsw==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id C04FB9C1;
 Mon, 25 Mar 2024 21:53:15 +0000 (UTC)
MIME-Version: 1.0
Date: Mon, 25 Mar 2024 14:53:15 -0700
From: Jared Finder <jared@HIDDEN>
To: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
In-Reply-To: <CAFdQyhJaRxi7_=2DLTihV1oGOfU5Sz1-_ZEOgU=pf=CwuZ=0vA@HIDDEN>
References: <CAFdQyhJaRxi7_=2DLTihV1oGOfU5Sz1-_ZEOgU=pf=CwuZ=0vA@HIDDEN>
Message-ID: <11a3b53941f179d5e9b5d283f05c12be@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, eliz@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 (-)

On 2024-03-24 12:27, Olaf Rogalsky wrote:
> Hi Jared,
> 
> thanks for your feedback (answering this from my gmail account and
> hope this doesn't mess up the debbugs history).
> 
>> Are you certain you need the change to window.el as well? I'd be very
>> surprised if it is necessary to change
> ...
>> Is your setup is different somehow?
> No, but I forgot to mention, that the "nil <select-window> is 
> undefined" error
> only occurred, iff mouse-autoselect-window had a numeric value.
> With my new patch, the error disappeared. I don't know why, but a
> change to window.el
> isn't necessary anymore. I still think, that the proposed change would
> be correct.

I'll defer to Eli here, but my general sentiment would be to leave 
window.el untouched unless a change is needed.  The event list returned 
was last changed in 2006 so it's reasonably stable.

>> <select-window> events shouldn't be generated while the mouse is being
>> dragged. This probably is reflected in fully by track-mouse, but I'd
>> suggest looking at the native code that generates the event to 
>> confirm.
> Truly understanding xterm.c unfortunately is beyond my expertise. 
> Nevertheless I
> tested, the behavior. Dragging the mouse from one window to the next
> (while passing over
> the modeline) gives the following sequence of events:
> 
>  ESC [ < 3 5 ; 5 5 ; 4 1 M ESC [ < 0 ; 5 5 ; 4 1 M ;; mouse-drag-region
>  ESC [ < 3 2 ; 5 5 ; 4 2 M             ;; anonymous-command
>  ESC [ < 3 2 ; 5 5 ; 4 3 M             ;; anonymous-command
>  <help-echo> ESC [ < 3 2 ; 5 5 ; 4 4 M ;; ignore
>  ESC [ < 3 2 ; 5 6 ; 4 4 M             ;; anonymous-command
>  ESC [ < 0 ; 5 6 ; 4 4 m               ;; anonymous-command
>  <drag-mouse-1>                        ;; mouse-set-region
> 
> So indeed, no select-window event is generated. As a result, dragging
> the mouse over the
> borders of the window results in a scrolling of the window. This
> matches the behavior of the
> X11 backend.

Thank you.  There's one remaining difference to handle that I highlight 
in the diff below.

>> If there is a case where two events should be generated (not sure if
>> this case exists depending on above), we'd want to return both, but 
>> you
>> can only return a single key sequence from the translate function. I
>> think this case deserves a FIXME note.
> Can't follow you here. At which occasion two events might be generated
> and which ones?

I was thinking that if both a mouse movement and select window event 
should both be returned, like if track-mouse is non-nil and you switch 
windows.  Can you test this case?

>> Did you try out switching frames? I'm not certain if <select-window> 
>> is
>> supposed to be generated when the frame is switched.
> Switching frames is not handled in xt-mouse.el. However, if you change
> the focus from another
> X11 window to the title bar of the terminal or wise-versa, no
> switch-frame event is generated. Instead,
> xterm-translate-focus-in/xterm-translate-focus-out are called via a
> binding in xterm-rxvt-function-map.
> These functions toggle the terminal parameter tty-focus-state between
> focused and defocused and then
> call after-focus-change-function, which also does not generate a
> switch-frame event.
> As far as I could find out, the X11 backend of emacs doesn't generate
> switch-frame events, either.

I was actually referring to using C-x 5 2 and C-x 5 o within a single 
terminal.  I tested this locally and it works fine.

> New patch:
> ... other parts of patch look good to me :) ...
> @@ -84,10 +89,19 @@ xterm-mouse-translate-1
>         vec)
>         (is-move
>          (xterm-mouse--handle-mouse-movement)
> -        (if track-mouse vec
> -          ;; Mouse movement events are currently supposed to be
> -          ;; suppressed.  Return no event.
> -          []))
> +       (if (and mouse-autoselect-window ; after mouse movement

Style nit: Can you please do this as a cond instead of a nested (if x y 
(if z u v))?

> autoselect the mouse window, but ...
> +                (windowp ev-window) ; ignore modeline, tab-bar,
> menu-bar and so forth ...
> +                ;;(not (posn-area (event-start event))) ; also
> ignore, if not inside of text area of window ...
> +                (not (eq ev-window last-window)) ; but only, if mouse
> is over new window ...
> +                (not (eq ev-window (selected-window)))) ; which is
> different from the selected window

Looking at xterm.c, I think you also want a test against 
window-minibuffer-p.

> +           (progn
> +             (put 'select-window 'event-kind 'switch-frame)
> +             (setf (car event) 'select-window)
> +             vec)

I think this should be an event that's just select-window and the 
window, to line up with what the select-window event looks like on other 
platforms (I tested PGTK and Windows terminal).  You can verify this by 
running M-x trace-function RET handle-select-window RET.

That would instead be something like:

(progn
   (put 'select-window 'event-kind 'switch-frame)
   (vector `(select-window (,ev-window)))

Thank you so much for making this patch!

   -- MJF




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

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


Received: (at 69915) by debbugs.gnu.org; 24 Mar 2024 19:30:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Mar 24 15:30:01 2024
Received: from localhost ([127.0.0.1]:47428 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1roTXc-0000hb-KX
	for submit <at> debbugs.gnu.org; Sun, 24 Mar 2024 15:30:01 -0400
Received: from mail-pl1-f175.google.com ([209.85.214.175]:58852)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <olaf.rogalsky@HIDDEN>) id 1roTXW-0000hL-CV
 for 69915 <at> debbugs.gnu.org; Sun, 24 Mar 2024 15:29:59 -0400
Received: by mail-pl1-f175.google.com with SMTP id
 d9443c01a7336-1def3340682so29764045ad.1
 for <69915 <at> debbugs.gnu.org>; Sun, 24 Mar 2024 12:29:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1711308486; x=1711913286; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject
 :date:message-id:reply-to;
 bh=azJunRCKtAwTZPomayKp3Yp65g3Wkn0Nc5AzgQS5OWM=;
 b=FzRZRgCBMXwXeyd++YdExiNrqSqKPzPIabozuBfq5Be02lurv4kbay9ApwIZoF1TUf
 f2VhxEVErcaffPMSpELZ3abSzzx06Pu3ZovZrKtdoHNr+3xB1w7TdvC0Vygzz+fPS6WQ
 fW59VZy0OF8F56hhUA28zYIUQJt560DoOPD2vRlK7Yi0UaH9IjHQLWHBSDbRojS+5nNR
 98dcBZBk7IJ0Xryhv3To7D+BX+PJVNI2ffHwvDWXOQ/lwGPRNFbHHxw5TMj23eNKE7T/
 1fwZPVagmQ6SKUWxByG0rqbng0k5dMsYCtqYjrfGipnt53Labykbyn5wIMu6vkucxSBF
 aRTw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1711308486; x=1711913286;
 h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=azJunRCKtAwTZPomayKp3Yp65g3Wkn0Nc5AzgQS5OWM=;
 b=SWvD7X147RGtu0XRBbqPT4H8lKN+4vbLzC0NGslxQlwI67ZPorzP6DWm1sbqmfR/vE
 kAn3fT4i9UduDIMezZxtFlY+RKk3hmKipIF4+VOHjjNQvFlg0Aj+OEnjRRYvp03mmili
 /HMziOGeIc3R6WctOMxvO9weTnsjAkzVc7kssfIHaOSFjoXyQAOHhBZhGas55DeWqfZ2
 5dghAnVDxinqmoXj16Mi4OznNHZI2aQ4bPGD4yidVIJGc5YHm+ILkMcdG7mO7AHo3q+1
 kasK4HVqvXCARQIW1mmfRwb3CE7VcmVKKHvAt/SZVo2hWg/1CdWD053xaXSHc8lrU6vv
 f1Og==
X-Forwarded-Encrypted: i=1;
 AJvYcCV7Ao/P217YN0O8F/YX09oDvT7UhYtaDgGRLkWgGUpECeoO0msdpUHhqyHjM/Ly+OqqqYVXzXsEAgRZaRDWHCfcwOTwlfU=
X-Gm-Message-State: AOJu0Yy1bbnP4NPWokoPh2pzB6GXrQ/7qYzPdX7t1+mcBze44yilXW8Z
 iH/s9A0iUo4D/qBhPsHYgGBAP9dE9A8Bv/waqjjZHVMhoYMqq9lTfEgi8lIPUJKwQxl5U+5FsGc
 8fcJI68EfheHKRbl1zCckBnCkDGU=
X-Google-Smtp-Source: AGHT+IGUm7HFGYAqQHFXyqQXmeOHfhGy7SDgrZxn3uYYEDcqPcCp03NXV8/dpl3yd1TQRP8AHV8JCQxd5bHdLMlNVwk=
X-Received: by 2002:a17:902:c412:b0:1e0:a7c4:fe61 with SMTP id
 k18-20020a170902c41200b001e0a7c4fe61mr7138065plk.54.1711308486346; Sun, 24
 Mar 2024 12:28:06 -0700 (PDT)
MIME-Version: 1.0
From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
Date: Sun, 24 Mar 2024 20:27:55 +0100
Message-ID: <CAFdQyhJaRxi7_=2DLTihV1oGOfU5Sz1-_ZEOgU=pf=CwuZ=0vA@HIDDEN>
Subject: Re: bug#69915: 30.0.50;
 mouse-autoselect-window has no effect in terminal
To: Jared Finder <jared@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, "eliz@HIDDEN" <eliz@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 (-)

Hi Jared,

thanks for your feedback (answering this from my gmail account and
hope this doesn't mess up the debbugs history).

> A few other pieces of feedback (you may find it easier to generate the
> events in xterm-mouse-translate-1 to address):
Yes, I think you are right. I refactored my code accordingly, see the new patch
below.

> Are you certain you need the change to window.el as well? I'd be very
> surprised if it is necessary to change
...
> Is your setup is different somehow?
No, but I forgot to mention, that the "nil <select-window> is undefined" error
only occurred, iff mouse-autoselect-window had a numeric value.
With my new patch, the error disappeared. I don't know why, but a
change to window.el
isn't necessary anymore. I still think, that the proposed change would
be correct.

> <select-window> events shouldn't be generated while the mouse is being
> dragged. This probably is reflected in fully by track-mouse, but I'd
> suggest looking at the native code that generates the event to confirm.
Truly understanding xterm.c unfortunately is beyond my expertise. Nevertheless I
tested, the behavior. Dragging the mouse from one window to the next
(while passing over
the modeline) gives the following sequence of events:

 ESC [ < 3 5 ; 5 5 ; 4 1 M ESC [ < 0 ; 5 5 ; 4 1 M ;; mouse-drag-region
 ESC [ < 3 2 ; 5 5 ; 4 2 M             ;; anonymous-command
 ESC [ < 3 2 ; 5 5 ; 4 3 M             ;; anonymous-command
 <help-echo> ESC [ < 3 2 ; 5 5 ; 4 4 M ;; ignore
 ESC [ < 3 2 ; 5 6 ; 4 4 M             ;; anonymous-command
 ESC [ < 0 ; 5 6 ; 4 4 m               ;; anonymous-command
 <drag-mouse-1>                        ;; mouse-set-region

So indeed, no select-window event is generated. As a result, dragging
the mouse over the
borders of the window results in a scrolling of the window. This
matches the behavior of the
X11 backend.

> If there is a case where two events should be generated (not sure if
> this case exists depending on above), we'd want to return both, but you
> can only return a single key sequence from the translate function. I
> think this case deserves a FIXME note.
Can't follow you here. At which occasion two events might be generated
and which ones?

> Did you try out switching frames? I'm not certain if <select-window> is
> supposed to be generated when the frame is switched.
Switching frames is not handled in xt-mouse.el. However, if you change
the focus from another
X11 window to the title bar of the terminal or wise-versa, no
switch-frame event is generated. Instead,
xterm-translate-focus-in/xterm-translate-focus-out are called via a
binding in xterm-rxvt-function-map.
These functions toggle the terminal parameter tty-focus-state between
focused and defocused and then
call after-focus-change-function, which also does not generate a
switch-frame event.
As far as I could find out, the X11 backend of emacs doesn't generate
switch-frame events, either.

> Please name the new internal state variable with prefix "xt-mouse--".
I changed it to the terminal parameter xterm-mouse-last-window.

Regards, Olaf

New patch:
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 081b8f32456..8b405262168 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -60,7 +60,9 @@ xterm-mouse-translate-1
     (let* ((event (xterm-mouse-event extension))
           (ev-command (nth 0 event))
           (ev-data    (nth 1 event))
+          (ev-window  (nth 0 ev-data))
           (ev-where   (nth 1 ev-data))
+          (last-window (terminal-parameter nil 'xterm-mouse-last-window))
           (vec (vector event))
           (is-move (eq 'mouse-movement ev-command))
           (is-down (string-match "down-" (symbol-name ev-command))))
@@ -73,6 +75,9 @@ xterm-mouse-translate-1
                                 'mouse-movement
                               'mouse-click)))

+      ;; remember window of current mouse position
+      (set-terminal-parameter nil 'xterm-mouse-last-window ev-window)
+
       (cond
        ((null event) nil)              ;Unknown/bogus byte sequence!
        (is-down
@@ -84,10 +89,19 @@ xterm-mouse-translate-1
        vec)
        (is-move
         (xterm-mouse--handle-mouse-movement)
-        (if track-mouse vec
-          ;; Mouse movement events are currently supposed to be
-          ;; suppressed.  Return no event.
-          []))
+       (if (and mouse-autoselect-window ; after mouse movement
autoselect the mouse window, but ...
+                (windowp ev-window) ; ignore modeline, tab-bar,
menu-bar and so forth ...
+                ;;(not (posn-area (event-start event))) ; also
ignore, if not inside of text area of window ...
+                (not (eq ev-window last-window)) ; but only, if mouse
is over new window ...
+                (not (eq ev-window (selected-window)))) ; which is
different from the selected window
+           (progn
+             (put 'select-window 'event-kind 'switch-frame)
+             (setf (car event) 'select-window)
+             vec)
+          (if track-mouse vec
+            ;; Mouse movement events are currently supposed to be
+            ;; suppressed.  Return no event.
+            [])))
        (t
        (let* ((down (terminal-parameter nil 'xterm-mouse-last-down))
               (down-data (nth 1 down))




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

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


Received: (at 69915) by debbugs.gnu.org; 21 Mar 2024 17:01:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 21 13:01:34 2024
Received: from localhost ([127.0.0.1]:44647 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rnLnK-0001cq-8f
	for submit <at> debbugs.gnu.org; Thu, 21 Mar 2024 13:01:34 -0400
Received: from greenhill.hpalace.com ([192.155.80.58]:48144)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jared@HIDDEN>) id 1rnLnI-0001ci-Vr
 for 69915 <at> debbugs.gnu.org; Thu, 21 Mar 2024 13:01:33 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=finder.org; s=2018;
 t=1711040451; bh=/nbp6cqDbSUnRZvsFlewvZ5OXnZznK3Zc4SG2SOjWTg=;
 h=Date:From:To:Cc:Subject:In-Reply-To:References:From;
 b=S9dg+biMP0/vBydSeqfHTtGzPBFOdPswGvBNwemOgHVZO2Cp59i3NBUDsB64HYPrZ
 oMPa9/PpLd1NsyrDg0LS1ejN39k7K0zfh09K/rOK/dfUhrIDgh3n+Mg6/Feq3DEXNb
 HLc7VoTu76mbsLHyvoR2b9ub590bgF4Dehc9Z5C0zMVGxoV1aHYVf4lXICPCHK7RQv
 rlS2cjo5pEJ0q0fC+0ag9jLzjNLg83i/2wLdPpUa1d1y1J7lyy7WBQYGYK8RtwkhF1
 0d1z2sEduyB7rvV5kgimjTEQu8q3HXnRME05pDDD/N+8wwMfDmkWxR6SE3m+6YvP0g
 PW/l806WVg3xw==
Received: from mail.finder.org (unknown [192.155.80.58])
 by greenhill.hpalace.com (Postfix) with ESMTPSA id DF980881;
 Thu, 21 Mar 2024 17:00:51 +0000 (UTC)
MIME-Version: 1.0
Date: Thu, 21 Mar 2024 10:00:51 -0700
From: Jared Finder <jared@HIDDEN>
To: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
In-Reply-To: <87v85gbwcd.fsf@HIDDEN>
References: <87zfutaram.fsf@HIDDEN> <86sf0k3lcw.fsf@HIDDEN>
 <87v85gbwcd.fsf@HIDDEN>
Message-ID: <339ee67827867e0ec87bdbb1ba46415e@HIDDEN>
X-Sender: jared@HIDDEN
Content-Type: text/plain; charset=US-ASCII;
 format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, Eli Zaretskii <eliz@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 (-)

On 2024-03-20 11:10, Olaf Rogalsky wrote:
>> On an MS-Windows terminal I don't see this problem, so maybe there's
>> more here than meets the eye?
> Yes, same in X11. I wasn't able to track it down. Maybe it is burried
> deep inside of "read_char".

I tried this change locally on master without the change to window.el 
and everything worked fine for me. Are you certain you need the change 
to window.el as well? I'd be very surprised if it is necessary to change 
the structure of the <select-window> event to get autoselect to work.

My repro was just:

src/emacs -nw -Q
M-x xterm-mouse-mode
M-x set-variable RET mouse-autoselect-window RET t
C-x 2
C-x 3
Then moving the mouse between the three visible windows.

Is your setup is different somehow?


A few other pieces of feedback (you may find it easier to generate the 
events in xterm-mouse-translate-1 to address):

<select-window> events shouldn't be generated while the mouse is being 
dragged. This probably is reflected in fully by track-mouse, but I'd 
suggest looking at the native code that generates the event to confirm.

If there is a case where two events should be generated (not sure if 
this case exists depending on above), we'd want to return both, but you 
can only return a single key sequence from the translate function. I 
think this case deserves a FIXME note.

Did you try out switching frames? I'm not certain if <select-window> is 
supposed to be generated when the frame is switched.

Please name the new internal state variable with prefix "xt-mouse--".

   -- MJF




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

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


Received: (at 69915) by debbugs.gnu.org; 20 Mar 2024 18:55:22 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 20 14:55:22 2024
Received: from localhost ([127.0.0.1]:56636 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rn15t-0005FY-2n
	for submit <at> debbugs.gnu.org; Wed, 20 Mar 2024 14:55:22 -0400
Received: from mailout05.t-online.de ([194.25.134.82]:36336)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <olaf.rogalsky@HIDDEN>) id 1rn0vC-0001so-76
 for 69915 <at> debbugs.gnu.org; Wed, 20 Mar 2024 14:44:20 -0400
Received: from fwd87.aul.t-online.de (fwd87.aul.t-online.de [10.223.144.113])
 by mailout05.t-online.de (Postfix) with SMTP id 21E379911;
 Wed, 20 Mar 2024 19:18:43 +0100 (CET)
Received: from blaubaer ([46.5.3.3]) by fwd87.t-online.de
 with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted)
 esmtp id 1rn0WQ-2JvB2n0; Wed, 20 Mar 2024 19:18:42 +0100
References: <87zfutaram.fsf@HIDDEN> <86sf0k3lcw.fsf@HIDDEN>
User-agent: mu4e 1.9.11; emacs 30.0.50
From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in
 terminal
Date: Wed, 20 Mar 2024 19:10:53 +0100
In-reply-to: <86sf0k3lcw.fsf@HIDDEN>
Message-ID: <87v85gbwcd.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-TOI-EXPURGATEID: 150726::1710958722-87FFC968-FD343095/0/0 CLEAN NORMAL
X-TOI-MSGID: 856ef732-c8b6-457e-a9c9-1bae624bed59
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <at> debbugs.gnu.org, Jared Finder <jared@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 (-)


> On an MS-Windows terminal I don't see this problem, so maybe there's
> more here than meets the eye?
Yes, same in X11. I wasn't able to track it down. Maybe it is burried
deep inside of "read_char".

> Anyway, why do you call posn-at-point with first argument nil?  I
Because I was lazy and didn't thought, that "the position of point in that
window is at all relevant".


Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
>> Date: Wed, 20 Mar 2024 15:29:33 +0100
>> 
>> when using emacs in the terminal, the mouse-autoselect-window variable
>> has no effect, i.e. moving the mouse from one window to the next does
>> not change the selected window.
>> 
>> Recipe:
>> --- snip ---
>> emacs -nw
>> M-: (xterm-mouse-mode 1)
>> M-: (setq mouse-autoselect-window t)
>> C-x 2
>> <mouse-motion <<<other window>>> >
>> --- snap ---
>> 
>> The reason is, that xt-mouse.el does not generate <select-window>
>> events. The following patch fixes that.
>
> Thanks.
>
>> To this end, it also fixes a bug in "window.el". Here, the
>> <select-window> event which is added to `last-input-event', does not
>> contain a propper posn field. In X11, this works fine, but in the
>> terminal it results in a "nil <select-window> is undefined" error.
>
> On an MS-Windows terminal I don't see this problem, so maybe there's
> more here than meets the eye?
>
> Anyway, why do you call posn-at-point with first argument nil?  I
> don't think the position of point in that window is at all relevant,
> is it?  Should we perhaps use the position derived from mouse-position
> instead?
>
> Jared, any comments to this patch?


-- 
Olaf Rogalsky
Schwoerhausgasse 5
89073 Ulm
Germany




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

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


Received: (at 69915) by debbugs.gnu.org; 20 Mar 2024 16:44:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 20 12:44:25 2024
Received: from localhost ([127.0.0.1]:49045 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rmz37-0001hh-GC
	for submit <at> debbugs.gnu.org; Wed, 20 Mar 2024 12:44:25 -0400
Received: from eggs.gnu.org ([209.51.188.92]:42384)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1rmz32-0001hS-UW
 for 69915 <at> debbugs.gnu.org; Wed, 20 Mar 2024 12:44:20 -0400
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 1rmz2D-0000CX-4a; Wed, 20 Mar 2024 12:43:30 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=3XGDXMz0uMJ3+NlEC3Gkil1Aa++Rgx56guUXzDnXpdw=; b=cC05t0kR0+eS
 B4jUBOU7Xir9y47NIHmYcS31SgTPKfbTgfBJ8pLG6M72YeUKa9mB4c056AxPo7oSPlMrjTlEBHT9Z
 6VNon71s5uV2l6HLro7er9bYsA6RVcDcETKU8kPIr4kBhdCT4WeKjhHzcI+xMw0VgCQrYem1PLZPR
 N3RPTqIGxt2LA9zQ2LSB4+Z0U8uJ3HUWVOplIMljxf0RnzjzgLSZsOULDBrmrSPTuhABquSz7AL/S
 +jZX0fWoW8Crq7mlJ8cEFjwbXzWHtQm3KH3m4HG6gJWNDYMYXnwq82HtBHrEY2VBi+4lFK/X/cMuR
 1Qdqjv05ocMThyC22rbSKA==;
Date: Wed, 20 Mar 2024 18:43:11 +0200
Message-Id: <86sf0k3lcw.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Olaf Rogalsky <olaf.rogalsky@HIDDEN>, Jared Finder <jared@HIDDEN>
In-Reply-To: <87zfutaram.fsf@HIDDEN> (message from Olaf Rogalsky on Wed, 
 20 Mar 2024 15:29:33 +0100)
Subject: Re: bug#69915: 30.0.50;
 mouse-autoselect-window has no effect in terminal
References: <87zfutaram.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 69915
Cc: 69915 <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: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
> Date: Wed, 20 Mar 2024 15:29:33 +0100
> 
> when using emacs in the terminal, the mouse-autoselect-window variable
> has no effect, i.e. moving the mouse from one window to the next does
> not change the selected window.
> 
> Recipe:
> --- snip ---
> emacs -nw
> M-: (xterm-mouse-mode 1)
> M-: (setq mouse-autoselect-window t)
> C-x 2
> <mouse-motion <<<other window>>> >
> --- snap ---
> 
> The reason is, that xt-mouse.el does not generate <select-window>
> events. The following patch fixes that.

Thanks.

> To this end, it also fixes a bug in "window.el". Here, the
> <select-window> event which is added to `last-input-event', does not
> contain a propper posn field. In X11, this works fine, but in the
> terminal it results in a "nil <select-window> is undefined" error.

On an MS-Windows terminal I don't see this problem, so maybe there's
more here than meets the eye?

Anyway, why do you call posn-at-point with first argument nil?  I
don't think the position of point in that window is at all relevant,
is it?  Should we perhaps use the position derived from mouse-position
instead?

Jared, any comments to this patch?




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

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


Received: (at submit) by debbugs.gnu.org; 20 Mar 2024 14:55:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Mar 20 10:55:24 2024
Received: from localhost ([127.0.0.1]:48709 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rmxLb-00042y-5P
	for submit <at> debbugs.gnu.org; Wed, 20 Mar 2024 10:55:24 -0400
Received: from lists.gnu.org ([209.51.188.17]:38954)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <olaf.rogalsky@HIDDEN>) id 1rmxLV-00042k-Jw
 for submit <at> debbugs.gnu.org; Wed, 20 Mar 2024 10:55:17 -0400
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 <olaf.rogalsky@HIDDEN>)
 id 1rmxKr-00011X-Nu
 for bug-gnu-emacs@HIDDEN; Wed, 20 Mar 2024 10:54:33 -0400
Received: from mailout08.t-online.de ([194.25.134.20])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <olaf.rogalsky@HIDDEN>)
 id 1rmxKb-0004aH-Az
 for bug-gnu-emacs@HIDDEN; Wed, 20 Mar 2024 10:54:32 -0400
Received: from fwd85.aul.t-online.de (fwd85.aul.t-online.de [10.223.144.111])
 by mailout08.t-online.de (Postfix) with SMTP id 9B4A710F19
 for <bug-gnu-emacs@HIDDEN>; Wed, 20 Mar 2024 15:54:13 +0100 (CET)
Received: from blaubaer ([46.5.3.3]) by fwd85.t-online.de
 with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted)
 esmtp id 1rmxKU-1F7fRx0; Wed, 20 Mar 2024 15:54:10 +0100
User-agent: mu4e 1.9.11; emacs 30.0.50
From: Olaf Rogalsky <olaf.rogalsky@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; mouse-autoselect-window has no effect in terminal
Date: Wed, 20 Mar 2024 15:29:33 +0100
X-Debbugs-Cc: 
Message-ID: <87zfutaram.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-TOI-EXPURGATEID: 150726::1710946450-86FFB383-12B572C8/0/0 CLEAN NORMAL
X-TOI-MSGID: 87c22808-00a8-4bce-8004-bfa79fc62a84
Received-SPF: pass client-ip=194.25.134.20;
 envelope-from=olaf.rogalsky@HIDDEN; helo=mailout08.t-online.de
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FROM=0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
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.3 (--)



Hi,

when using emacs in the terminal, the mouse-autoselect-window variable
has no effect, i.e. moving the mouse from one window to the next does
not change the selected window.

Recipe:
--- snip ---
emacs -nw
M-: (xterm-mouse-mode 1)
M-: (setq mouse-autoselect-window t)
C-x 2
<mouse-motion <<<other window>>> >
--- snap ---

The reason is, that xt-mouse.el does not generate <select-window>
events. The following patch fixes that.

To this end, it also fixes a bug in "window.el". Here, the
<select-window> event which is added to `last-input-event', does not
contain a propper posn field. In X11, this works fine, but in the
terminal it results in a "nil <select-window> is undefined" error.

Regards, Olaf


diff --git a/lisp/window.el b/lisp/window.el
index 246708dbd56..8af1cf485bd 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -10645,7 +10645,7 @@ mouse-autoselect-window-select
       ;; autoselection again, set `mouse-autoselect-window-state'."
       (setq mouse-autoselect-window-state 'select)
       (setq unread-command-events
-            (cons (list 'select-window (list window))
+            (cons (list 'select-window (posn-at-point nil window))
                   unread-command-events)))
      ((or (not (numberp mouse-autoselect-window))
           (equal mouse-position mouse-autoselect-window-position))
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el
index 081b8f32456..aaaffb3a534 100644
--- a/lisp/xt-mouse.el
+++ b/lisp/xt-mouse.el
@@ -42,6 +42,8 @@

 (require 'mwheel)

+(defvar last-mouse-window nil)
+
 (defvar xterm-mouse-debug-buffer nil)

 (defun xterm-mouse-translate (_event)
@@ -338,6 +340,15 @@ xterm-mouse-event
           (set-terminal-parameter nil 'xterm-mouse-last-click
                                   (list type this-time click-count x y)))

+        (when (and mouse-autoselect-window
+                   (mouse-movement-p event)
+                   (windowp w)
+                   (not (posn-area (event-start event))))
+          (when (and (not (eq w last-mouse-window))
+                     (not (eq w (selected-window))))
+            (setf (car event) 'select-window))
+          (setq last-mouse-window w))
+
         (set-terminal-parameter nil 'xterm-mouse-x x)
         (set-terminal-parameter nil 'xterm-mouse-y y)
         (setq last-input-event event)))))






In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.38, cairo version 1.18.0) of 2024-01-22 built on blaubaer
Repository revision: 797c688f4ab33a196477fd85f83f7438d113dc7d
Repository branch: master
System Description: Manjaro Linux

Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games
 --with-modules --without-m17n-flt --without-gconf
 --with-native-compilation=yes --with-xinput2 --with-x-toolkit=gtk3
 --without-xaw3d --with-sound=no --with-tree-sitter --without-gpm
 --without-compress-install
 '--program-transform-name=s/\([ec]tags\)/\1.emacs/'
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
LCMS2 LIBOTF LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C.UTF-8
  value of $LC_MONETARY: de_DE.UTF-8
  value of $LC_NUMERIC: de_DE.UTF-8
  value of $LC_TIME: de_DE.UTF-8
  value of $LANG: de_DE.UTF-8
  locale-coding-system: utf-8-unix

Major mode: mu4e-headers

Minor modes in effect:
  mu4e-search-minor-mode: t
  hl-line-mode: t
  mu4e-update-minor-mode: t
  mu4e-context-minor-mode: t
  global-page-break-lines-mode: t
  openwith-mode: t
  winner-mode: t
  recentf-mode: t
  windmove-mode: t
  auto-compile-on-load-mode: t
  auto-compile-on-save-mode: t
  corfu-indexed-mode: t
  corfu-history-mode: t
  corfu-echo-mode: t
  corfu-doc-terminal-mode: t
  corfu-terminal-mode: t
  global-corfu-mode: t
  corfu-mode: t
  marginalia-mode: t
  vertico-mouse-mode: t
  vertico-indexed-mode: t
  vertico-mode: t
  xclip-mode: t
  save-place-mode: t
  global-goto-address-mode: t
  goto-address-mode: t
  savehist-mode: t
  minibuffer-depth-indicate-mode: t
  xterm-mouse-mode: t
  override-global-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  buffer-read-only: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/y1rog/.emacs.d/elpa/popon-0.13/popon hides /home/y1rog/.emacs.d/elpa/popon/popon
/home/y1rog/.emacs.d/elpa/popup-20210317.138/popup hides /usr/share/emacs/site-lisp/popup
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company hides /usr/share/emacs/site-lisp/company-mode/company
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-files hides /usr/share/emacs/site-lisp/company-mode/company-files
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-etags hides /usr/share/emacs/site-lisp/company-mode/company-etags
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-capf hides /usr/share/emacs/site-lisp/company-mode/company-capf
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-keywords hides /usr/share/emacs/site-lisp/company-mode/company-keywords
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-dabbrev-code hides /usr/share/emacs/site-lisp/company-mode/company-dabbrev-code
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-bbdb hides /usr/share/emacs/site-lisp/company-mode/company-bbdb
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-dabbrev hides /usr/share/emacs/site-lisp/company-mode/company-dabbrev
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-template hides /usr/share/emacs/site-lisp/company-mode/company-template
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-gtags hides /usr/share/emacs/site-lisp/company-mode/company-gtags
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-semantic hides /usr/share/emacs/site-lisp/company-mode/company-semantic
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-yasnippet hides /usr/share/emacs/site-lisp/company-mode/company-yasnippet
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-elisp hides /usr/share/emacs/site-lisp/company-mode/company-elisp
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-css hides /usr/share/emacs/site-lisp/company-mode/company-css
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-cmake hides /usr/share/emacs/site-lisp/company-mode/company-cmake
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-clang hides /usr/share/emacs/site-lisp/company-mode/company-clang
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-tng hides /usr/share/emacs/site-lisp/company-mode/company-tng
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-tempo hides /usr/share/emacs/site-lisp/company-mode/company-tempo
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-oddmuse hides /usr/share/emacs/site-lisp/company-mode/company-oddmuse
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-nxml hides /usr/share/emacs/site-lisp/company-mode/company-nxml
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-abbrev hides /usr/share/emacs/site-lisp/company-mode/company-abbrev
/home/y1rog/.emacs.d/elpa/company-20221206.2122/company-ispell hides /usr/share/emacs/site-lisp/company-mode/company-ispell
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-bind-key hides /usr/share/emacs/site-lisp/use-package/use-package-bind-key
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-lint hides /usr/share/emacs/site-lisp/use-package/use-package-lint
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-diminish hides /usr/share/emacs/site-lisp/use-package/use-package-diminish
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-jump hides /usr/share/emacs/site-lisp/use-package/use-package-jump
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package hides /usr/share/emacs/site-lisp/use-package/use-package
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-delight hides /usr/share/emacs/site-lisp/use-package/use-package-delight
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-core hides /usr/share/emacs/site-lisp/use-package/use-package-core
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-ensure hides /usr/share/emacs/site-lisp/use-package/use-package-ensure
/usr/share/emacs/site-lisp/use-package/bind-key hides /usr/share/emacs/30.0.50/lisp/bind-key
/home/y1rog/.emacs.d/elpa/transient-20221202.1727/transient hides /usr/share/emacs/30.0.50/lisp/transient
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-bind-key hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-bind-key
/usr/share/emacs/site-lisp/use-package/use-package-ensure-system-package hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-ensure-system-package
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-lint hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-lint
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-diminish hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-diminish
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-jump hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-jump
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package hides /usr/share/emacs/30.0.50/lisp/use-package/use-package
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-delight hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-delight
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-core hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-core
/home/y1rog/.emacs.d/elpa/use-package-20210207.1926/use-package-ensure hides /usr/share/emacs/30.0.50/lisp/use-package/use-package-ensure

Features:
(shadow emacsbug smerge-mode diff diff-mode shortdoc cus-edit cus-start
cus-load vertico-directory help-fns radix-tree org-element org-persist
org-id org-refile oc-basic ol-eww eww url-queue mm-url ol-rmail ol-mhe
ol-irc ol-info ol-gnus nnselect ol-docview doc-view filenotify jka-compr
image-mode exif ol-bibtex bibtex ol-bbdb ol-w3m ol-doi org-link-doi
shr-color qp mm-archive sort gnus-cite mail-extr textsec uni-scripts
idna-mapping ucs-normalize uni-confusable textsec-check my-email mu4e
mu4e-org org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-src ob-comint org-pcomplete org-list org-footnote org-faces
org-entities ob-emacs-lisp ob-core ob-eval org-cycle org-table ol
org-fold org-fold-core org-keys oc org-loaddefs find-func org-version
org-compat org-macs mu4e-main mu4e-view gnus-art mm-uu mml2015 mm-view
mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo gnus-start
gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 nnoo gnus-spec
gnus-int gnus-range gnus-win gnus nnheader range cal-menu calendar
cal-loaddefs mu4e-headers mu4e-compose mu4e-draft mu4e-actions smtpmail
mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message shr
pixel-fill kinsoku url-file svg xml dom browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util url-parse url-vars flow-fill
mule-util hl-line mu4e-contacts mu4e-update mu4e-folders mu4e-server
mu4e-context mu4e-obsolete mu4e-vars mu4e-helpers mu4e-config
mu4e-window bookmark pp ido message sendmail mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068
epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader page-break-lines rainbow-mode
which-key openwith winner recentf tree-widget wid-edit browse-kill-ring
delsel windmove auto-compile comp comp-cstr cl-extra warnings packed
corfu-indexed corfu-info corfu-history cape-keyword cape corfu-echo
corfu-doc-terminal avl-tree generator corfu-doc corfu-terminal popon
corfu marginalia vertico-mouse vertico-buffer vertico-indexed vertico
xclip comp-run comp-common term/xterm xterm indent-bars treesit compat
noutline outline icons face-remap highlight-parentheses
sanityinc-tomorrow-eighties-theme color-theme-sanityinc-tomorrow color
my-key-bindings my-packages gnuplot-autoloads ediff ediff-merg
ediff-mult ediff-wind ediff-diff ediff-help ediff-init ediff-util
saveplace tramp-sh tramp rx trampver tramp-integration files-x
tramp-message help-mode tramp-compat xdg shell pcomplete comint ansi-osc
ring parse-time iso8601 time-date format-spec auth-source eieio
eieio-core password-cache json subr-x map ansi-color tramp-loaddefs
edmacro kmacro byte-opt diminish my-vertico-corfu my-tex
auctex-autoloads tex-site my-defaults goto-addr thingatpt savehist
mb-depth xt-mouse disp-table my-functions my-xterm cl-seq cl-macs gv
use-package use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core cl-loaddefs
cl-lib bytecomp byte-compile info 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 touch-screen 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 dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo gtk
x-toolkit xinput2 x multi-tty move-toolbar make-network-process
native-compile emacs)

Memory information:
((conses 16 686735 101378) (symbols 48 31301 5)
 (strings 32 132848 5474) (string-bytes 1 3923210) (vectors 16 74276)
 (vector-slots 8 862021 26500) (floats 8 946 9980)
 (intervals 56 5825 1610) (buffers 984 19))

-- 
Olaf Rogalsky
Schwoerhausgasse 5
89073 Ulm
Germany




Acknowledgement sent to Olaf Rogalsky <olaf.rogalsky@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#69915; 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, 6 Apr 2024 10:30:02 UTC

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