Subject: Re: bug#69915: 30.0.50; mouse-autoselect-window has no effect in terminal

From: Jared Finder <[email-masked]>
Date: Thu, 21 Mar 2024 10:00:51 -0700

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