From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: David Hart Newsgroups: gmane.emacs.bugs 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-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000952bf505a29c9aac" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="38054"; mail-complaints-to="usenet@ciao.gmane.io" Cc: iqgrande@gmail.com, 34213@debbugs.gnu.org To: alan@idiocy.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 06 13:06:13 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 1jLPa0-0009od-AW for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Apr 2020 13:06:12 +0200 Original-Received: from localhost ([::1]:58774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLPZz-0006ve-9t for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Apr 2020 07:06:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58312) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLPZr-0006vV-LA for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2020 07:06:04 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLPZq-0002GB-HB for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2020 07:06:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLPZq-0002Fy-7h for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2020 07:06:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jLPZq-0004OZ-2J for bug-gnu-emacs@gnu.org; Mon, 06 Apr 2020 07:06:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: David Hart Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 06 Apr 2020 11:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34213 X-GNU-PR-Package: emacs Original-Received: via spool by 34213-submit@debbugs.gnu.org id=B34213.158617114016783 (code B ref 34213); Mon, 06 Apr 2020 11:06:02 +0000 Original-Received: (at 34213) by debbugs.gnu.org; 6 Apr 2020 11:05:40 +0000 Original-Received: from localhost ([127.0.0.1]:47239 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLPZT-0004Mc-OK for submit@debbugs.gnu.org; Mon, 06 Apr 2020 07:05:40 -0400 Original-Received: from mail-ot1-f65.google.com ([209.85.210.65]:37085) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLOqz-0001HH-7j for 34213@debbugs.gnu.org; Mon, 06 Apr 2020 06:19:42 -0400 Original-Received: by mail-ot1-f65.google.com with SMTP id g23so14750023otq.4 for <34213@debbugs.gnu.org>; Mon, 06 Apr 2020 03:19:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iamdavidhart-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to:cc; bh=QG+NxktIh0KjGKzAm5zV9lFcxvOwJZ23QQaGLthvcrM=; b=fg9rGtdv/ZJRKumUtKxpWbbB1dgenRd5BTYUxZri+Y6eLfxJob58M5pOHCowkcv80x vSgJG8nd49FDd12KTIY69O8R+3+1D+cc3HdjBrqi5CPZBSeKUBodd/KPOGOcw44d2QxX zf4kFk0ply29Hbj7f7dRBYtt7xyfcQOz10nPRjgjp4Mxf/VE89gJnK+4wxUtFFT5YujN pPmoDBW3WPxXig5Ut5zp1V6BBv6O60o5guiMGMAb3aN21ci6NFFpkWfn11Se9WKhfGd+ HbyZokXt1YU3Lzi3IQlJbPMtD8fB71uftV7bOCBa5m6fLK87K4L2lycmhTKVqlFGz5FW fscA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=QG+NxktIh0KjGKzAm5zV9lFcxvOwJZ23QQaGLthvcrM=; b=FtSp6ba43k3IELAGPBL4Lr8TEY12XUWcGRT9y/4DP84nxTrKYOtr/38EiWiPYzyRvp jYDxz0SIigsmjM5iF7MkfvCoMes0Lt59/to8GA/YmBYvXjToanEJNqRJPRh6zc/FeTY8 hXVM+QSPjA3j5J4an/uKmFvGa6BaQx48yHHaooTkrLrUmqu1GyrYkCIk6w0303svsp0D tF2Jkrp7a1he6BVJlsdSHh5ye3bnA627jwH+acamo2cuMOgwgtzoY7fxBT/DffAggq+y 5GoVKGKTcNvE+sVvmXwVWJm7MY++jv2M8tnngbUqrvibmC4wN6Il8CeTUCb5ZArLDMY4 F/Qg== X-Gm-Message-State: AGi0PuZzJZ4KJQKQZI6qVmTLw824/uQhaLqPXjmVzA0+iQGKHnpreEG2 K7MX3DBYNtBi1LnQyKAFYdscdnga4u+C5Rha6GVaJQ== X-Google-Smtp-Source: APiQypK8+QJbynYeFKrLiG0coEazLgL5Pf82MY2I5xHeK9D8YN2/CSiCxzxLDgJRZP2mQicRiOpHEl0B/1LjNmg7Lx0= X-Received: by 2002:a05:6830:3090:: with SMTP id f16mr16300977ots.211.1586168375613; Mon, 06 Apr 2020 03:19:35 -0700 (PDT) X-Mailman-Approved-At: Mon, 06 Apr 2020 07:05:38 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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:178082 Archived-At: --000000000000952bf505a29c9aac Content-Type: text/plain; charset="UTF-8" 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); --000000000000952bf505a29c9aac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The mechanism used in the ns port of emacs to cancel menu trac= king, 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 lon= ger allowing apps to post arbitrary CGEvents to the system.

<= /div>
You can observe a console message on macOS Catalina when the firs= t click fails: "Sender is prohibited from synthesizing events".= =C2=A0

A proposed fix is included inline below, us= ing a newer API 'CGEventPostToPid' instead of CGEventPost. The newe= r 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)
<= div>
diff --git a/src/nsterm.m b/src/nsterm.m
index= 3ce2233..4dbe1c2 100644
--- a/src/nsterm.m
+++ b/src/n= sterm.m
@@ -4523,7 +4523,7 @@ in certain situations (rapid incomi= ng events).
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0menu_mouse_point,
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0kCGMouseButtonLeft);
=C2= =A0 =C2=A0 =C2=A0 =C2=A0CGEventSetType (event, kCGEventLeftMouseDown);
- =C2=A0 =C2=A0 =C2=A0CGEventPost (kCGHIDEventTap, event);
= + =C2=A0 =C2=A0 =C2=A0CGEventPostToPid([NSProcessInfo processInfo].processI= dentifier, event);
=C2=A0 =C2=A0 =C2=A0 =C2=A0CFRelease (event);<= /div>
=C2=A0 =C2=A0 =C2=A0 =C2=A0CFRelease (source);
=C2=A0

--000000000000952bf505a29c9aac--