GNU bug report logs - #34213
27.0.50; Menu bar requires 2 clicks, is unresponsive, or has delays on macOS Mojave

Previous Next

Package: emacs;

Reported by: Anthony Michael Agelastos <iqgrande <at> gmail.com>

Date: Sat, 26 Jan 2019 23:31:02 UTC

Severity: normal

Merged with 24719, 32864, 44333

Found in versions 26.0.50, 26.1, 27.0.50, 27.1

Done: Alan Third <alan <at> idiocy.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: David Hart <david <at> iamdavidhart.com>
To: alan <at> idiocy.org
Cc: iqgrande <at> gmail.com, 34213 <at> 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
[Message part 1 (text/plain, inline)]
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);
[Message part 2 (text/html, inline)]

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

Previous Next


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