From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jared Finder via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#43756: Fix for TTY menus mouse interaction Date: Sat, 03 Oct 2020 10:44:32 -0700 Message-ID: <3259742e56a80e8ee6bf2628bf180033@finder.org> References: <41afb058e440b1b8e681ce38e1f7b014@finder.org> <871rigwv65.fsf@gnus.org> <3d6b6e0f894ab59c3b0df9394182f498@finder.org> <83k0w8e7z8.fsf@gnu.org> <094def0cf664c29c513b0686929eb808@finder.org> <83ft6vepsy.fsf@gnu.org> Reply-To: Jared Finder Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_d589f7850f1d0c7a2c02dbc91f582526" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9330"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Roundcube Webmail/1.3.15 Cc: 43756@debbugs.gnu.org, larsi@gnus.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 03 19:45:23 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kOlb0-0002JH-GV for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Oct 2020 19:45:22 +0200 Original-Received: from localhost ([::1]:42272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kOlaz-0000PB-Fu for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 03 Oct 2020 13:45:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48352) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kOlaj-0000P3-IR for bug-gnu-emacs@gnu.org; Sat, 03 Oct 2020 13:45:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:32841) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kOlag-0003QI-AG for bug-gnu-emacs@gnu.org; Sat, 03 Oct 2020 13:45:05 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kOlag-0000FQ-8l for bug-gnu-emacs@gnu.org; Sat, 03 Oct 2020 13:45:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jared Finder Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Oct 2020 17:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 43756 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 43756-submit@debbugs.gnu.org id=B43756.1601747075905 (code B ref 43756); Sat, 03 Oct 2020 17:45:02 +0000 Original-Received: (at 43756) by debbugs.gnu.org; 3 Oct 2020 17:44:35 +0000 Original-Received: from localhost ([127.0.0.1]:44387 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kOlaE-0000EW-PZ for submit@debbugs.gnu.org; Sat, 03 Oct 2020 13:44:35 -0400 Original-Received: from greenhill.hpalace.com ([192.155.80.58]:39354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kOlaD-0000EO-Cn for 43756@debbugs.gnu.org; Sat, 03 Oct 2020 13:44:34 -0400 Original-Received: from mail.finder.org (greenhill.hpalace.com [IPv6:2600:3c01::f03c:91ff:fe73:2daa]) by greenhill.hpalace.com (Postfix) with ESMTPSA id 63CE9C38; Sat, 3 Oct 2020 17:44:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=finder.org; s=2018; t=1601747072; bh=2Z/PkOpNeF/YSvheDA6jK4Feu5UpSs9QBxtML4K0dcM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=tvGVXWGycchjQS/Iyb9EWe1tAvw7zRFtVpXF1E/vP3YxzYG7u4o/xpU8ovIdv5MN2 HQh7pyO4N+khqEYsY4+GRIXX3H3yhUPn7vBImRXeQwf3s0GQoR1LdfYyJ5J9z5OfTT us5mtM6ca/RIUve3GgFTa997ERBa4on+ZR8WuQoHA3NY3tIPKf6MCDiX9AZR54H9T+ Lh0C2X+FW2OEzKYLOLZVO40pe5YSKXgVSwSrD3aqFwJ48gchsUcDU7wAWPqX+2tz1z 5hA01th1rVBXDGB1ELJQQXh+V5vP1JtKvZewD3MqRMtFpQy2mppmOzirS4rIr9Ter1 aJvVc6csAhWwQ== In-Reply-To: <83ft6vepsy.fsf@gnu.org> X-Sender: jared@finder.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:189709 Archived-At: --=_d589f7850f1d0c7a2c02dbc91f582526 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On 2020-10-03 12:23 am, Eli Zaretskii wrote: >> Date: Fri, 02 Oct 2020 12:54:54 -0700 >> From: Jared Finder >> Cc: larsi@gnus.org, 43756@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 . > > 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 tmm 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 --=_d589f7850f1d0c7a2c02dbc91f582526 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=0001-Fixing-small-bugs-in-tmm.el.patch Content-Disposition: attachment; filename=0001-Fixing-small-bugs-in-tmm.el.patch; size=2812 RnJvbSAxMmQzYmZjMDFkNjYzMmZiOGE5MDNkZDc1N2VlOTU3NGRhOTZlNDIwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBKYXJlZCBGaW5kZXIgPGphcmVkQGZpbmRlci5vcmc+CkRhdGU6 IFRodSwgMTcgU2VwIDIwMjAgMjI6Mzc6MDAgLTA3MDAKU3ViamVjdDogW1BBVENIIDEvM10gRml4 aW5nIHNtYWxsIGJ1Z3MgaW4gdG1tLmVsLgoKKiBgdG1tLW1lbnViYXIta2V5bWFwJyBub3cgcHJv cGVybHkgc29ydHMgZmluYWwgaXRlbXMuCiogYHRtbS1tZW51YmFyJyBhbGxvd3MgY2xpY2tzIG9u IHRoZSBmaW5hbCBtZW51IGl0ZW0uCi0tLQogbGlzcC90bW0uZWwgICAgfCAyMyArKysrKysrKysr KysrKystLS0tLS0tLQogc3JjL2tleWJvYXJkLmMgfCAgMyArKy0KIDIgZmlsZXMgY2hhbmdlZCwg MTcgaW5zZXJ0aW9ucygrKSwgOSBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQgYS9saXNwL3RtbS5l bCBiL2xpc3AvdG1tLmVsCmluZGV4IGU5ZjNmNWIwMzguLjA3NGVlNzU5M2YgMTAwNjQ0Ci0tLSBh L2xpc3AvdG1tLmVsCisrKyBiL2xpc3AvdG1tLmVsCkBAIC01MCwxNCArNTAsMTggQEAgdG1tLW1l bnViYXIta2V5bWFwCiAgICAgICAgIChtZW51LWVuZCAnKCkpKQogICAgIChtYXAta2V5bWFwCiAg ICAgIChsYW1iZGEgKGtleSBiaW5kaW5nKQotICAgICAgIChwdXNoIChjb25zIGtleSBiaW5kaW5n KQotICAgICAgICAgICAgIDs7IElmIEtFWSBpcyB0aGUgbmFtZSBvZiBhbiBpdGVtIHRoYXQgd2Ug d2FudCB0byBwdXQgbGFzdCwKLSAgICAgICAgICAgICA7OyBtb3ZlIGl0IHRvIHRoZSBlbmQuCi0g ICAgICAgICAgICAgKGlmIChtZW1xIGtleSBtZW51LWJhci1maW5hbC1pdGVtcykKLSAgICAgICAg ICAgICAgICAgbWVudS1lbmQKLSAgICAgICAgICAgICAgIG1lbnUtYmFyKSkpCisgICAgICAgKGxl dCAoKHBvcyAoc2VxLXBvc2l0aW9uIG1lbnUtYmFyLWZpbmFsLWl0ZW1zIGtleSkpCisgICAgICAg ICAgICAgKG1lbnUtaXRlbSAoY29ucyBrZXkgYmluZGluZykpKQorICAgICAgICAgKGlmIHBvcwor ICAgICAgICAgICAgIDs7IElmIEtFWSBpcyB0aGUgbmFtZSBvZiBhbiBpdGVtIHRoYXQgd2Ugd2Fu dCB0byBwdXQKKyAgICAgICAgICAgICA7OyBsYXN0LCBzdG9yZSBpdCBzZXBhcmF0ZWx5IHdpdGgg ZXhwbGljaXQgb3JkZXJpbmcgZm9yCisgICAgICAgICAgICAgOzsgc29ydGluZy4KKyAgICAgICAg ICAgICAocHVzaCAoY29ucyBwb3MgbWVudS1pdGVtKSBtZW51LWVuZCkKKyAgICAgICAgICAgKHB1 c2ggbWVudS1pdGVtIG1lbnUtYmFyKSkpKQogICAgICAodG1tLWdldC1rZXliaW5kIFttZW51LWJh cl0pKQotICAgIGAoa2V5bWFwICxAKG5yZXZlcnNlIG1lbnUtYmFyKSAsQChucmV2ZXJzZSBtZW51 LWVuZCkpKSkKKyAgICBgKGtleW1hcCAsQChucmV2ZXJzZSBtZW51LWJhcikKKyAgICAgICAgICAg ICAsQChtYXBjYXIgJ2NkciAoc29ydCBtZW51LWVuZAorICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIChsYW1iZGEgKGEgYikgKDwgKGNhciBhKSAoY2FyIGIpKSkpKSkpKQogCiA7Ozsj IyNhdXRvbG9hZCAoZGVmaW5lLWtleSBnbG9iYWwtbWFwICJcTS1gIiAndG1tLW1lbnViYXIpCiA7 OzsjIyNhdXRvbG9hZCAoZGVmaW5lLWtleSBnbG9iYWwtbWFwIFttZW51LWJhciBtb3VzZS0xXSAn dG1tLW1lbnViYXItbW91c2UpCkBAIC05Niw3ICsxMDAsMTAgQEAgdG1tLW1lbnViYXIKICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKG9yIChudWxsIHZpc2libGUpCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoZXZhbCB2aXNpYmxl KSkpKSkpKQogICAgICAgICAgICAgICAgICAgKHNldHEgY29sdW1uICgrIGNvbHVtbiAobGVuZ3Ro IG5hbWUpIDEpKSkpKQotICAgICAgICAgICAgIG1lbnUtYmFyKSkpKQorICAgICAgICAgICAgIG1l bnUtYmFyKQorICAgICAgICAgICAgOzsgQ2hlY2sgdGhlIGxhc3QgbWVudSBpdGVtLgorICAgICAg ICAgICAgKHdoZW4gKD4gY29sdW1uIHgtcG9zaXRpb24pCisgICAgICAgICAgICAgIChzZXRxIG1l bnUtYmFyLWl0ZW0gcHJldi1rZXkpKSkpKQogICAgICh0bW0tcHJvbXB0IG1lbnUtYmFyIG5pbCBt ZW51LWJhci1pdGVtKSkpCiAKIDs7OyMjI2F1dG9sb2FkCmRpZmYgLS1naXQgYS9zcmMva2V5Ym9h cmQuYyBiL3NyYy9rZXlib2FyZC5jCmluZGV4IGFmMDc1YTQyYzcuLmVhNWY5NjEzMDQgMTAwNjQ0 Ci0tLSBhL3NyYy9rZXlib2FyZC5jCisrKyBiL3NyYy9rZXlib2FyZC5jCkBAIC0xMjEwNiw3ICsx MjEwNiw4IEBAIHN5bXNfb2Zfa2V5Ym9hcmQgKHZvaWQpCiAKICAgREVGVkFSX0xJU1AgKCJtZW51 LWJhci1maW5hbC1pdGVtcyIsIFZtZW51X2Jhcl9maW5hbF9pdGVtcywKIAkgICAgICAgZG9jOiAv KiBMaXN0IG9mIG1lbnUgYmFyIGl0ZW1zIHRvIG1vdmUgdG8gdGhlIGVuZCBvZiB0aGUgbWVudSBi YXIuCi1UaGUgZWxlbWVudHMgb2YgdGhlIGxpc3QgYXJlIGV2ZW50IHR5cGVzIHRoYXQgbWF5IGhh dmUgbWVudSBiYXIgYmluZGluZ3MuICAqLyk7CitUaGUgb3JkZXIgb2YgdGhpcyBsaXN0IGNvbnRy b2xzIHRoZSBvcmRlciBvZiB0aGUgaXRlbXMuIFRoZSBlbGVtZW50cyBvZiB0aGUgbGlzdAorYXJl IGV2ZW50IHR5cGVzIHRoYXQgbWF5IGhhdmUgbWVudSBiYXIgYmluZGluZ3MuICAqLyk7CiAgIFZt ZW51X2Jhcl9maW5hbF9pdGVtcyA9IFFuaWw7CiAKICAgREVGVkFSX0xJU1AgKCJ0YWItYmFyLXNl cGFyYXRvci1pbWFnZS1leHByZXNzaW9uIiwgVnRhYl9iYXJfc2VwYXJhdG9yX2ltYWdlX2V4cHJl c3Npb24sCi0tIAoyLjIwLjEKCg== --=_d589f7850f1d0c7a2c02dbc91f582526--