From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Po Lu via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#19120: 25.0.50; macosx: f10 does NOT go to the menu bar Date: Wed, 20 Oct 2021 10:59:45 +0800 Message-ID: <87pms0csf2.fsf@yahoo.com> References: <700A6A05-B019-4B80-9CBC-880F58EEEE5A@swipnet.se> <8C6577F7-44BC-4BD7-B1A8-082FB5014C02@swipnet.se> Reply-To: Po Lu Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12376"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: 19120@debbugs.gnu.org, sds@gnu.org, alan@idiocy.org To: "Jan D." Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 20 05:01:24 2021 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 1md1r1-00033o-R7 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 20 Oct 2021 05:01:23 +0200 Original-Received: from localhost ([::1]:58224 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1md1qz-00083a-OA for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 19 Oct 2021 23:01:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44086) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1md1qk-00083D-KL for bug-gnu-emacs@gnu.org; Tue, 19 Oct 2021 23:01:07 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:40854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1md1qg-0007KZ-Lo for bug-gnu-emacs@gnu.org; Tue, 19 Oct 2021 23:01:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1md1qg-00038J-AX for bug-gnu-emacs@gnu.org; Tue, 19 Oct 2021 23:01:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 20 Oct 2021 03:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19120 X-GNU-PR-Package: emacs Original-Received: via spool by 19120-submit@debbugs.gnu.org id=B19120.163469880411903 (code B ref 19120); Wed, 20 Oct 2021 03:01:02 +0000 Original-Received: (at 19120) by debbugs.gnu.org; 20 Oct 2021 03:00:04 +0000 Original-Received: from localhost ([127.0.0.1]:52400 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1md1pj-00035t-N4 for submit@debbugs.gnu.org; Tue, 19 Oct 2021 23:00:04 -0400 Original-Received: from sonic316-21.consmr.mail.ne1.yahoo.com ([66.163.187.147]:45059) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1md1ph-00034s-MJ for 19120@debbugs.gnu.org; Tue, 19 Oct 2021 23:00:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1634698796; bh=/8hPmi793V7vPj8Iitw2ZEjrrR4IPWwoiJmjoWtw+zk=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=D+DeKAXodA0reIEoHj4RwGZ9YTWFngRywvAwN6hJqihtkQomU6NmwkUrWc0AqVS4HUYnOlwI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XR3 0BBy3hDy.59jv6xN2eMqUtv9G5Zefk6A3asF1sDbrp9_6k5jsGxDsTYWKHcsR7bDpcoT3uCiMmMi 0prUuygPFr54GyhS7FcEGpfXmj5C3tF3DbYmOZNiKRfXISnjNMMgJn1uoxhhS5xUZDQJzT0OUVcZ N8dBdZ2f8fC3uJki7p_ZIlxev6NCp8svnlOaOAWTScDWF20StQ6wTpk.e7zwn6GIDvebz6uKr_xZ XFPeDZTucltmWKGjy86J4NyM3ftHWANG8hFJTwC2ooserA8VAEe.E.hb2pDXLI.ZMfQK9EePgqVR 9to8sAADEghDBoxIytSItlpkJTMfR4z.NWSaBAAxhHsYOARAX6fte.HoZhLo7yHq1FJ2f4nCUVQ0 K.gx72dmePoXb8f1b54W2IAPwT5c0JKNLytKXg8htOIRa8u2NKPxZadefEfPkX_ZsFbMhj2cQ3.h PoxB8aRrLAXNR0SV52y1Y.8OdATIrxPF_DYXGtNXLo5xhFKbAGISobgwC_i2HGYBTxwq6_djSUiq iv1h1GzEJWiH6Gc1_TlPA2w3z8QSrvmCV4NLQCPQv_ X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic316.consmr.mail.ne1.yahoo.com with HTTP; Wed, 20 Oct 2021 02:59:56 +0000 Original-Received: by kubenode501.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID b6d27b5ed41392a77a8eb372d23870aa; Wed, 20 Oct 2021 02:59:50 +0000 (UTC) In-Reply-To: <8C6577F7-44BC-4BD7-B1A8-082FB5014C02@swipnet.se> (Jan D.'s message of "Sun, 19 Apr 2015 09:44:36 +0200") X-Mailer: WebService/1.1.19116 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo 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:217626 Archived-At: --=-=-= Content-Type: text/plain "Jan D." writes: > He fakes a keyclick on the apple menu. Not that hard to do, patches welcome. I think I may have found a cleaner solution to this. But there is one problem: only the code for GNUstep utilizing [NSMenu display] has been tested. I don't know if the Cocoa-specific code will work. Sam, please test the attached change, thanks. Alan, how does this look to you? Do you think it will work? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Support-opening-the-toolkit-menu-bar-on-NS.patch >From 4e3fe6b4c0027dada181892c019e49f8003612fe Mon Sep 17 00:00:00 2001 From: Po Lu Date: Wed, 20 Oct 2021 10:54:27 +0800 Subject: [PATCH] Support opening the toolkit menu bar on NS * src/nsmenu.m (ns_activate_menubar, Fns_open_menubar): New functions. * src/nsterm.m (ns_create_terminal): Add activate_menubar_hook. * lisp/menu-bar.el (menu-bar-open): Use ns-menu-bar-open on Nextstep. --- lisp/menu-bar.el | 8 +++++--- src/nsmenu.m | 41 ++++++++++++++++++++++++++++++++++++++++- src/nsterm.m | 1 + 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index 980ba2fcd1..2ef24cf111 100644 --- a/lisp/menu-bar.el +++ b/lisp/menu-bar.el @@ -2659,9 +2659,10 @@ menu-bar-open this is the numeric argument to the command. This function decides which method to use to access the menu depending on FRAME's terminal device. On X displays, it calls -`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; otherwise it -calls either `popup-menu' or `tmm-menubar' depending on whether -`tty-menu-open-use-tmm' is nil or not. +`x-menu-bar-open'; on Windows, `w32-menu-bar-open'; +on NS, `ns-menu-bar-open'; otherwise it calls either `popup-menu' +or `tmm-menubar' depending on whether `tty-menu-open-use-tmm' +is nil or not. If FRAME is nil or not given, use the selected frame." (interactive @@ -2670,6 +2671,7 @@ menu-bar-open (cond ((eq type 'x) (x-menu-bar-open frame)) ((eq type 'w32) (w32-menu-bar-open frame)) + ((eq type 'ns) (ns-menu-bar-open frame)) ((and (null tty-menu-open-use-tmm) (not (zerop (or (frame-parameter nil 'menu-bar-lines) 0)))) ;; Make sure the menu bar is up to date. One situation where diff --git a/src/nsmenu.m b/src/nsmenu.m index 333a8b50a1..359a9c3bc8 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -1451,7 +1451,30 @@ - (NSRect) frame @end /* EmacsTooltip */ +void +ns_activate_menubar (struct frame *frame) +{ + if (frame != SELECTED_FRAME () + || !FRAME_EXTERNAL_MENU_BAR (frame)) + return; + block_input (); + NSApplication *app = [NSApplication sharedApplication]; + NSMenu *menu = [app mainMenu]; + for (NSMenuItem *item in [menu itemArray]) + { + if ([item hasSubmenu]) + { +#ifdef NS_IMPL_GNUSTEP + [[item submenu] display]; +#else + [menu performActionForItemAtIndex: [menu indexOfItem: item]]; +#endif + break; + } + } + unblock_input (); +} /* ========================================================================== @@ -1883,7 +1906,6 @@ - (Lisp_Object)runDialogAt: (NSPoint)p @end - /* ========================================================================== Lisp definitions @@ -1906,6 +1928,22 @@ - (Lisp_Object)runDialogAt: (NSPoint)p return popup_activated () ? Qt : Qnil; } +DEFUN ("ns-menu-bar-open", Fns_menu_bar_open, Sns_menu_bar_open, 0, 1, "i", + doc: /* Start key navigation of the menu bar in FRAME. +This initially opens the first menu bar item and you can then navigate with the +arrow keys, select a menu entry with the return key or cancel with the +escape key. If FRAME has no menu bar this function does nothing. + +If FRAME is nil or not given, use the selected frame. */) + (Lisp_Object frame) +{ + struct frame *f = decode_window_system_frame (frame); + + ns_activate_menubar (f); + + return Qnil; +} + /* ========================================================================== Lisp interface declaration @@ -1917,6 +1955,7 @@ - (Lisp_Object)runDialogAt: (NSPoint)p { defsubr (&Sns_reset_menu); defsubr (&Smenu_or_popup_active_p); + defsubr (&Sns_menu_bar_open); DEFSYM (Qdebug_on_next_call, "debug-on-next-call"); } diff --git a/src/nsterm.m b/src/nsterm.m index e0b7143e29..cd322b1fce 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5071,6 +5071,7 @@ static Lisp_Object ns_new_font (struct frame *f, Lisp_Object font_object, terminal->delete_frame_hook = ns_destroy_window; terminal->delete_terminal_hook = ns_delete_terminal; terminal->change_tab_bar_height_hook = ns_change_tab_bar_height; + terminal->activate_menubar_hook = ns_activate_menubar; /* Other hooks are NULL by default. */ return terminal; -- 2.31.1 --=-=-=--