unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: David Hart <david@iamdavidhart.com>
To: alan@idiocy.org
Cc: iqgrande@gmail.com, 34213@debbugs.gnu.org
Subject: bug#34213: 27.0.50; Menu bar requires 2 clicks, is unresponsive, or has delays on macOS Mojave
Date: Mon, 6 Apr 2020 03:19:25 -0700	[thread overview]
Message-ID: <CAOcguANxY8KohTVxs+mob0wBNNCPr0RXcOYzQV_xCiQs=11h2A@mail.gmail.com> (raw)
In-Reply-To: <A8465976-601F-410C-AD3F-206F8238D641@gmail.com>

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

The mechanism used in the ns port of emacs to cancel menu tracking, and to
post a CGEvent to resume it after menus have been updated via lisp no
longer works on recent macOS versions.

The cause of this bug is due to Apple tightening security in macOS, and no
longer allowing apps to post arbitrary CGEvents to the system.

You can observe a console message on macOS Catalina when the first click
fails: "Sender is prohibited from synthesizing events".

A proposed fix is included inline below, using a newer API
'CGEventPostToPid' instead of CGEventPost. The newer API accepts a pid
specifying the recipient, and when the recipient is the same pid as the
sending process, the event gets posted successfully.

Note: the newer API is only available in macOS versions 10.11 and greater.

David


Fix more menu bar requires 2 clicks (bug#34213)

diff --git a/src/nsterm.m b/src/nsterm.m
index 3ce2233..4dbe1c2 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -4523,7 +4523,7 @@ in certain situations (rapid incoming events).
                                                   menu_mouse_point,
                                                   kCGMouseButtonLeft);
       CGEventSetType (event, kCGEventLeftMouseDown);
-      CGEventPost (kCGHIDEventTap, event);
+      CGEventPostToPid([NSProcessInfo processInfo].processIdentifier,
event);
       CFRelease (event);
       CFRelease (source);

[-- Attachment #2: Type: text/html, Size: 2025 bytes --]

  parent reply	other threads:[~2020-04-06 10:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-26 22:14 bug#34213: 27.0.50; Menu bar requires 2 clicks, is unresponsive, or has delays on macOS Mojave Anthony Michael Agelastos
2019-01-30 19:57 ` Alan Third
2020-04-06 10:19 ` David Hart [this message]
2020-04-06 18:54   ` Alan Third
2020-09-30 15:42     ` Lars Ingebrigtsen

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='CAOcguANxY8KohTVxs+mob0wBNNCPr0RXcOYzQV_xCiQs=11h2A@mail.gmail.com' \
    --to=david@iamdavidhart.com \
    --cc=34213@debbugs.gnu.org \
    --cc=alan@idiocy.org \
    --cc=iqgrande@gmail.com \
    /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).