unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Nick Helm <nick@tenpoint.co.nz>
To: Alan Third <alan@idiocy.org>
Cc: 31371@debbugs.gnu.org
Subject: bug#31371: 26.1; Menu-bar stops working after search
Date: Sun, 13 May 2018 22:09:06 +1200	[thread overview]
Message-ID: <m2o9hjn9z1.fsf@tenpoint.co.nz> (raw)
In-Reply-To: <20180508214024.GB13768@breton.holly.idiocy.org> (Alan Third's message of "Tue, 8 May 2018 22:40:24 +0100")

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

I think I've worked out what's going on here. I've attached a patch -
could you give it a try and see if works for you? 

When the user types in the search field, NSMenu looks for matching
candidates by creating events to open each menu, trigger an update and
read the results. If the search field already contains text, this
happens as soon as the Help menu opens, either when the user clicks Help
or mouse drags onto the Help menu. 

The code in ns_check_menu_open and ns_check_pending_open_menu that
postpones mouse clicks (to fetch menus from Lisp) also tries to postpone
these drag and search events. When it releases a delayed click on Help
(even if the event wasn't a click to begin with), the menu reopens and
the process loops.

The attached patch gets around this by never postponing mouse drag or
non-user mouse down events.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 31371.patch --]
[-- Type: text/x-patch, Size: 1385 bytes --]

--- a/src/nsterm.m	2018-05-13 16:45:39.000000000 +1200
+++ b/src/nsterm.m	2018-05-13 16:44:31.000000000 +1200
@@ -4299,14 +4299,22 @@
           NSEvent *theEvent = [NSApp currentEvent];
           struct frame *emacsframe = SELECTED_FRAME ();
 
-          [menu cancelTracking];
-          menu_will_open_state = MENU_PENDING;
-          emacs_event->kind = MENU_BAR_ACTIVATE_EVENT;
-          EV_TRAILER (theEvent);
-
-          CGEventRef ourEvent = CGEventCreate (NULL);
-          menu_mouse_point = CGEventGetLocation (ourEvent);
-          CFRelease (ourEvent);
+          /*On macOS, the following can cause an event loop when the 
+            Spotlight for Help search field is populated.  Avoid this by
+            not postponing mouse drag and non-user-generated mouse down 
+            events.  (bug#31371).*/
+          if (([theEvent type] == NSEventTypeLeftMouseDown)
+              && [theEvent eventNumber])
+            {
+              [menu cancelTracking];
+              menu_will_open_state = MENU_PENDING;
+              emacs_event->kind = MENU_BAR_ACTIVATE_EVENT;
+              EV_TRAILER (theEvent);
+
+              CGEventRef ourEvent = CGEventCreate (NULL);
+              menu_mouse_point = CGEventGetLocation (ourEvent);
+              CFRelease (ourEvent);
+            }
         }
       else if (menu_will_open_state == MENU_OPENING)
         {

[-- Attachment #3: Type: text/plain, Size: 472 bytes --]



On Wed, 09 May 2018 at 09:40:24 +1200, Alan Third wrote:

> I notice all this code is cocoa only, though. Makes me wonder why
> GNUstep is different. (The menus on GNUstep Emacs are awful, though,
> they flicker constantly.)

I think Cocoa uses a delegate method to update single submenus which
(I've read) isn't supported on GNUStep. This means ns_update_menubar has
to recreate every menu on every call (deep_p is always 1). Maybe that
has something to do with it?




  reply	other threads:[~2018-05-13 10:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-05 14:15 bug#31371: 26.1; Menu-bar stops working after search Nick Helm
2018-05-06 10:14 ` Alan Third
2018-05-07  2:48   ` Nick Helm
2018-05-08  5:24     ` Nick Helm
2018-05-08 21:40     ` Alan Third
2018-05-13 10:09       ` Nick Helm [this message]
2018-05-18 21:33 ` George Plymale II
2018-05-19  4:26   ` Nick Helm
2019-10-11 11:25 ` Stefan Kangas
2019-10-11 12:04   ` Robert Pluim
2019-10-14  1:50   ` Nick
2019-10-14 12:44     ` Stefan Kangas
2019-10-14 12:55       ` Robert Pluim
2019-10-14 13:14       ` Alan Third
2019-11-05 15:13         ` Stefan Kangas
2019-11-09 10:18           ` Stefan Kangas
2019-11-09 11:29             ` Alan Third
2019-12-31 10:29             ` Stefan Kangas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2o9hjn9z1.fsf@tenpoint.co.nz \
    --to=nick@tenpoint.co.nz \
    --cc=31371@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).