GNU bug report logs - #43756
Fix for TTY menus mouse interaction

Previous Next

Package: emacs;

Reported by: Jared Finder <jared <at> finder.org>

Date: Fri, 2 Oct 2020 06:12:02 UTC

Severity: normal

Tags: fixed, patch

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 43756 in the body.
You can then email your comments to 43756 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Fri, 02 Oct 2020 06:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jared Finder <jared <at> finder.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 02 Oct 2020 06:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: bug-gnu-emacs <at> gnu.org
Subject: Fix for TTY menus mouse interaction
Date: Thu, 01 Oct 2020 22:56:34 -0700
[Message part 1 (text/plain, inline)]
Attached is a simple bugfix for tmm.el in Emacs. Currently when the top
level menu is displayed (like when pressing F10), the menu entries are
not in the same order as they are displayed in the menu bar.
Additionally, clicking on any menu entry other than "Help" jumps
straight into the menu clicked on, but clicking on "Help" displays the
root menu. 

Let me know if you need more details to reproduce the issues. In this
case, I think the issues fixed are straightforward. 

  -- MJF
[Message part 2 (text/html, inline)]
[0001-Fixing-small-bugs-in-tmm.el.patch (text/x-diff, attachment)]

Added tag(s) patch. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Fri, 02 Oct 2020 14:35:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Fri, 02 Oct 2020 14:38:01 GMT) Full text and rfc822 format available.

Message #10 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jared Finder <jared <at> finder.org>
Cc: 43756 <at> debbugs.gnu.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Fri, 02 Oct 2020 16:37:38 +0200
Jared Finder <jared <at> finder.org> writes:

> Let me know if you need more details to reproduce the issues. In this
> case, I think the issues fixed are straightforward.

Yes, a recipe for reproducing this problem would be nice (including what
you're seeing and what you're expecting to see), starting from "emacs -Q".

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Fri, 02 Oct 2020 16:46:02 GMT) Full text and rfc822 format available.

Message #13 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43756 <at> debbugs.gnu.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Fri, 02 Oct 2020 09:45:33 -0700
On 2020-10-02 7:37 am, Lars Ingebrigtsen wrote:
> Jared Finder <jared <at> finder.org> writes:
> 
>> Let me know if you need more details to reproduce the issues. In this
>> case, I think the issues fixed are straightforward.
> 
> Yes, a recipe for reproducing this problem would be nice (including 
> what
> you're seeing and what you're expecting to see), starting from "emacs 
> -Q".

Environment:

* Emacs repo from git://git.sv.gnu.org/emacs.git, commit 
f6277911eb2c520aec8f0efd80c91999226e3322
* Run on Debian under Windows Subsystem for Linux 2 (the VM version). 
I've also seen this on MacOS and native Win32 builds of Emacs.

Steps to reproduce:

emacs -Q
M-x ielm
M-x xterm-mouse-mode
Click on File in the menu bar.
--> observe that you get the File menu displayed via tmm.el
Click on Edit, Options, Buffers, Tools, IELM in the menu bar.
--> observe that you get the menu clicked on displayed via tmm.el.

Now the buggy parts:

Click on the "C" in Complete in the menu bar.
--> The Help menu displays. I expect the Complete menu to display.
Click on the "I" in In/Out in the menu bar.
--> The Signals menu displays. I expect the In/Out menu to display.
Click on the "H" in Help in the menu bar.
--> The root menu displays. I expect the Help menu to display.
Run M-x tmm-menubar
--> The menu listed is in the order File, Edit, Options, Buffers, Tools, 
IELM, Help, Signals, In/Out, Complete. I expect the menu to be displayed 
in the same order as the menu bar display.

  -- MJF




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Fri, 02 Oct 2020 19:37:02 GMT) Full text and rfc822 format available.

Message #16 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jared Finder <jared <at> finder.org>
Cc: 43756 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Fri, 02 Oct 2020 22:35:55 +0300
> Cc: 43756 <at> debbugs.gnu.org
> Date: Fri, 02 Oct 2020 09:45:33 -0700
> From: Jared Finder via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
> 
> * Emacs repo from git://git.sv.gnu.org/emacs.git, commit 
> f6277911eb2c520aec8f0efd80c91999226e3322
> * Run on Debian under Windows Subsystem for Linux 2 (the VM version). 
> I've also seen this on MacOS and native Win32 builds of Emacs.

Native Windows build doesn't support xterm-mouse, and the native mouse
clicks work correctly there.  If you have a recipe for the native
Windows build that shows incorrect menus popping down, please show
that.

> emacs -Q
> M-x ielm
> M-x xterm-mouse-mode

Ah, xterm-mouse-mode.  AFAIR, no one has made TTY menus work with
xterm-mouse-mode.  The first thing to do is to disable tmm-menubar,
and then you need to cause a mouse click call menu-bar-open with the
2nd argument set to the X coordinate of the click.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Fri, 02 Oct 2020 19:55:01 GMT) Full text and rfc822 format available.

Message #19 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43756 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Fri, 02 Oct 2020 12:54:54 -0700
On 2020-10-02 12:35 pm, Eli Zaretskii wrote:
>> Cc: 43756 <at> debbugs.gnu.org
>> Date: Fri, 02 Oct 2020 09:45:33 -0700
>> From: Jared Finder via "Bug reports for GNU Emacs,
>>  the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>> 
>> * Emacs repo from git://git.sv.gnu.org/emacs.git, commit
>> f6277911eb2c520aec8f0efd80c91999226e3322
>> * Run on Debian under Windows Subsystem for Linux 2 (the VM version).
>> I've also seen this on MacOS and native Win32 builds of Emacs.
> 
> Native Windows build doesn't support xterm-mouse, and the native mouse
> clicks work correctly there.  If you have a recipe for the native
> Windows build that shows incorrect menus popping down, please show
> that.

On Windows builds, only the M-x tmm-menubar step is broken, with the 
order in the displayed menu bar being different then in the tmm-menubar 
popup. This is *only* about text based menus, not the native platform 
ones.

>> emacs -Q
>> M-x ielm
>> M-x xterm-mouse-mode
> 
> Ah, xterm-mouse-mode.  AFAIR, no one has made TTY menus work with
> xterm-mouse-mode.  The first thing to do is to disable tmm-menubar,
> and then you need to cause a mouse click call menu-bar-open with the
> 2nd argument set to the X coordinate of the click.

I think this may be getting mixed up with my feature proposal on 
emacs-devel? I did find this bug when working on making the TTY menus 
work with xterm-mouse-mode and they both affect menus. The patches I 
attached in that thread follow the pattern you described.

This bug report is separable from the rest of that feature. It's also 
much smaller, just two lines. :) This fixes the current behavior of the 
command tmm-menubar-mouse, which is bound to <menu-bar> <mouse-1>.

  -- MJF




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Sat, 03 Oct 2020 07:24:02 GMT) Full text and rfc822 format available.

Message #22 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jared Finder <jared <at> finder.org>
Cc: 43756 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Sat, 03 Oct 2020 10:23:09 +0300
> Date: Fri, 02 Oct 2020 12:54:54 -0700
> From: Jared Finder <jared <at> finder.org>
> Cc: larsi <at> gnus.org, 43756 <at> debbugs.gnu.org
> 
> > Ah, xterm-mouse-mode.  AFAIR, no one has made TTY menus work with
> > xterm-mouse-mode.  The first thing to do is to disable tmm-menubar,
> > and then you need to cause a mouse click call menu-bar-open with the
> > 2nd argument set to the X coordinate of the click.
> 
> I think this may be getting mixed up with my feature proposal on 
> emacs-devel? I did find this bug when working on making the TTY menus 
> work with xterm-mouse-mode and they both affect menus. The patches I 
> attached in that thread follow the pattern you described.
> 
> This bug report is separable from the rest of that feature. It's also 
> much smaller, just two lines. :) This fixes the current behavior of the 
> command tmm-menubar-mouse, which is bound to <menu-bar> <mouse-1>.

So you are saying that when tmm-menubar-mouse is invoked by mouse
clicks, it shows incorrect menus after "M-x ielm", but only if you
click on the menu items specific to IELM?  It sounds like tmm-menubar
has a bug in its translation of the X coordinate of the click to the
menu-bar item, perhaps because it considers only the global menu
keymap.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Sat, 03 Oct 2020 17:45:02 GMT) Full text and rfc822 format available.

Message #25 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43756 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Sat, 03 Oct 2020 10:44:32 -0700
[Message part 1 (text/plain, inline)]
On 2020-10-03 12:23 am, Eli Zaretskii wrote:
>> Date: Fri, 02 Oct 2020 12:54:54 -0700
>> From: Jared Finder <jared <at> finder.org>
>> Cc: larsi <at> gnus.org, 43756 <at> debbugs.gnu.org
>> 
>> > Ah, xterm-mouse-mode.  AFAIR, no one has made TTY menus work with
>> > xterm-mouse-mode.  The first thing to do is to disable tmm-menubar,
>> > and then you need to cause a mouse click call menu-bar-open with the
>> > 2nd argument set to the X coordinate of the click.
>> 
>> I think this may be getting mixed up with my feature proposal on
>> emacs-devel? I did find this bug when working on making the TTY menus
>> work with xterm-mouse-mode and they both affect menus. The patches I
>> attached in that thread follow the pattern you described.
>> 
>> This bug report is separable from the rest of that feature. It's also
>> much smaller, just two lines. :) This fixes the current behavior of 
>> the
>> command tmm-menubar-mouse, which is bound to <menu-bar> <mouse-1>.
> 
> So you are saying that when tmm-menubar-mouse is invoked by mouse
> clicks, it shows incorrect menus after "M-x ielm", but only if you
> click on the menu items specific to IELM?  It sounds like tmm-menubar
> has a bug in its translation of the X coordinate of the click to the
> menu-bar item, perhaps because it considers only the global menu
> keymap.

I think the issue is that the ordering of elements in 
menu-bar-final-items controls the order of the display menu bar, but 
tmm-menubar-keymap does not currently take that into account. It was 
pure luck that my first patch fixed anything. :)

Attached is a new patch and more detailed repro steps.

First, the ordering bug (the changes inside tmm-menubar-keymap):

Environment:

* Emacs repo from git://git.sv.gnu.org/emacs.git, commit 
f6277911eb2c520aec8f0efd80c91999226e3322
* Run on Debian under Windows Subsystem for Linux 2 (the VM version). 
I've also seen this on MacOS and native Win32 builds of Emacs.

Steps to reproduce:

emacs -Q
M-x load-library <RET> tmm <RET>

Defining the following stripped down version of tmm-menubar makes it 
easier to visually compare the displayed menu bar with what tmm-menubar 
would show:

(defun menubar-items ()
  "Simplified version of tmm-menubar."
  (let ((column 0)
        (menu-bar (tmm-menubar-keymap))
        list)
    (catch 'done
      (map-keymap
       (lambda (key binding)
         (pcase binding
           ((or `(,(and (pred stringp) name) . ,_) ;Simple menu item.
                `(menu-item ,name ,_cmd            ;Extended menu item.
                            . ,(and props
                                    (guard (let ((visible
                                                  (plist-get props 
:visible)))
                                             (or (null visible)
                                                 (eval visible)))))))
            (push (cons name column) list)
            (setq column (+ column (length name) 1)))))
       menu-bar)
    (nreverse list))))

M-x ielm

Eval (menubar-items)
--> observe that the ordering of menu items returned is not the same as 
the displayed menu bar.
--> With my patch this is correct.

Eval (setf menu-bar-final-items '(help-menu completion signals inout))
Force redisplay via C-l
--> observe that the ordering of menu items in the displayed menu bar 
has changed.

Eval (menubar-items)
--> observe that the ordering of menu items returned has not changed.
--> With my patch this is correct.

Repeat above steps for other values of menu-bar-final-items. You can add 
'file to the list, set it to nil, etc.


The click bug is a simple fix in tmm-menubar since the lambda passed in 
to map-keymap always checks against the previous menu item (e.g. 
prev-key), therefore missing the last item. Repro steps are same as 
before.

  -- MJF
[0001-Fixing-small-bugs-in-tmm.el.patch (text/x-diff, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Mon, 05 Oct 2020 08:25:01 GMT) Full text and rfc822 format available.

Message #28 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Jared Finder <jared <at> finder.org>
Cc: 43756 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Mon, 05 Oct 2020 10:24:00 +0200
Jared Finder <jared <at> finder.org> writes:

> Attached is a new patch and more detailed repro steps.

Thanks; with that recipe I could reproduce the bugs here with emacs -Q
-nw, and your patch fixes the problem, so I've applied it to Emacs 28.

It was small enough to apply without a copyright assignment (but I
forgot to put in a copyright exempt marker again *sigh*).  If you think
it's possible that you'll submit further patches in the future, it might
be a good idea to do the copyright assignment process now -- would you
be willing to do so?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 05 Oct 2020 08:25:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 43756 <at> debbugs.gnu.org and Jared Finder <jared <at> finder.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Mon, 05 Oct 2020 08:25:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Mon, 05 Oct 2020 14:54:01 GMT) Full text and rfc822 format available.

Message #35 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Jared Finder <jared <at> finder.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 43756 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Mon, 05 Oct 2020 07:53:17 -0700
On 2020-10-05 1:24 am, Lars Ingebrigtsen wrote:
> Jared Finder <jared <at> finder.org> writes:
> 
>> Attached is a new patch and more detailed repro steps.
> 
> Thanks; with that recipe I could reproduce the bugs here with emacs -Q
> -nw, and your patch fixes the problem, so I've applied it to Emacs 28.
> 
> It was small enough to apply without a copyright assignment (but I
> forgot to put in a copyright exempt marker again *sigh*).  If you think
> it's possible that you'll submit further patches in the future, it 
> might
> be a good idea to do the copyright assignment process now -- would you
> be willing to do so?

Yay! Happy to sign a copyright assignment. Let's start that process.

  -- MJF




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43756; Package emacs. (Mon, 05 Oct 2020 15:04:01 GMT) Full text and rfc822 format available.

Message #38 received at 43756 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jared Finder <jared <at> finder.org>
Cc: 43756 <at> debbugs.gnu.org, larsi <at> gnus.org
Subject: Re: bug#43756: Fix for TTY menus mouse interaction
Date: Mon, 05 Oct 2020 18:03:54 +0300
> Date: Mon, 05 Oct 2020 07:53:17 -0700
> From: Jared Finder <jared <at> finder.org>
> Cc: Eli Zaretskii <eliz <at> gnu.org>, 43756 <at> debbugs.gnu.org
> 
> Yay! Happy to sign a copyright assignment. Let's start that process.

Form sent off-list.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 03 Nov 2020 12:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 227 days ago.

Previous Next


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