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: Mon, 25 Oct 2021 19:47:42 +0800 Message-ID: <87tuh5wckh.fsf@yahoo.com> References: <87pms0csf2.fsf@yahoo.com> <87v91s2f9y.fsf@gmail.com> <87h7dcat6a.fsf@yahoo.com> <87k0i73mao.fsf@gmail.com> <878ryn8bx7.fsf@yahoo.com> <877de26gho.fsf@yahoo.com> <87tuh64us7.fsf@yahoo.com> 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="864"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Robert Pluim , sds@gnu.org, 19120@debbugs.gnu.org To: Alan Third Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 25 13:57:28 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 1meybX-000AZR-2I for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 Oct 2021 13:57:27 +0200 Original-Received: from localhost ([::1]:35850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1meybV-0001UI-7F for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 25 Oct 2021 07:57:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1meyTO-0001C1-DD for bug-gnu-emacs@gnu.org; Mon, 25 Oct 2021 07:49:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1meyTO-0004nG-3A for bug-gnu-emacs@gnu.org; Mon, 25 Oct 2021 07:49:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1meyTN-0005b6-Uf for bug-gnu-emacs@gnu.org; Mon, 25 Oct 2021 07:49:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Po Lu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 25 Oct 2021 11:49:01 +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.163516249021425 (code B ref 19120); Mon, 25 Oct 2021 11:49:01 +0000 Original-Received: (at 19120) by debbugs.gnu.org; 25 Oct 2021 11:48:10 +0000 Original-Received: from localhost ([127.0.0.1]:41763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1meySM-0005Yr-Tp for submit@debbugs.gnu.org; Mon, 25 Oct 2021 07:48:10 -0400 Original-Received: from sonic310-23.consmr.mail.ne1.yahoo.com ([66.163.186.204]:35170) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1meySL-0005YZ-4e for 19120@debbugs.gnu.org; Mon, 25 Oct 2021 07:47:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1635162471; bh=UwNPuC4vcAMMjd9T25/UvSzoco81JaT95dIfdfoTjcM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From:Subject:Reply-To; b=gyY0Wwi/KuqH+AkVB80ppRFgcl+UhEfVFrWPUzNySuvOWaP1r/VL8+dYxv1VxbFPN7lOfcWdeYRTY53qRo+sootrYOpVROorPgoGM/bSVGI1iy2x5RMKRgzqNslCYA0nxyzHRug35PRRudIjxA0qn3jA1XzK5yjz671GfXWxFKnI5PjCs/NpeYDGq+YLoQHhNE+Ji1PUxBEzUpfcKeoEQ7ursKS11Y9PJs/tBaMhk7d5/5g58d7eU+8nNTeMHHCCEtyGfCndQ2yqspsjkBrNLik3CJ2mL31BgF4ebnDJ5HY4zXqnDRinEtUGVuUsWlt6cyy15V9YH7Ncycz403AsmQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1635162471; bh=Nlpru8cQbFaGH7coFDTU7GsZZUp6FgZUEE5qHEJq/wb=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=j4gVVPTxLlqL8UlWqH4zijgDsoeEqUfgiCjHsKnr/NIITnbQ3DNsQBOdjByXQs0VyjSpNUkUE7uihT9l4+Jyd/j0VWrMv5avL+yaZGFKgRIHCb3uzBbDx2sp5jQ675SxlzHWdVk6g6krlPCPmAp0F43gB1CwF4Qx1fZ79noRfMoL7qOWLc8gc0V5SXo9vfFMMWYyIj3gSUoMRS8uTyoN63eVIKUIqAlkGOhEklvWcvNqSRAnea6Ruwri9JDT/I3k36yhQT7urZ6s+ylI6O/Jod1UPCVuDvLZjaT9TI8BRiwPH6+XhaeBBy3lwRF7GAivR2jTgTQ/7L1zlyBzA8motw== X-YMail-OSG: vZ7kkCEVM1lK5oahJAFc46ypD5qsXEfW0gnIKojjm5PbL9R68244WNdvts8ZTY8 JZSwNKbwrILi3Ix4zhZSxme3SvmkJsKL4QxKORWOeFXee_R6B6lNBe1mkqWMO5KbvEAATZTWy.93 o.mTYFYhdf26d7XxuC8xut0CaBe8SpRjh9swADc.dolEcsWEbuFLr3mrTdWXLkK47LqHqeP3tTba zWwN7b3son4tpaOToKdsuMrSkME5_8KrwBvxKbdiDoah5DPezZfRTiB34k.fw.9sykfKvNCg38sC ME4yA2_zlnm.QMbuBh73xzA2kxog49syZWt1PGC5mAcj6kaAy5AVN3OFIcJICg7dWwfQ.2XNrcKG vGgIrwmOM0AAHbOjjivfRk0_ikFw7ID6DVAKDvj2ysswHHhsqLmVfLDLd7mkXO.vCcaZ3Th_IEJa UBu92dcb0zSn4yIVPde3tpSRitKuhMHrmeMcEDP62RqLt1Pqo56XF1ivHgS1WlWA0n5QQMoKkRSX 91If.kVaNxlX7iQXKARNxIIshmn96FO.1rYmTviD6yFLen3uTqDDyhOZR4xTEypwY7oQEfwnqbPF _pBBfATIqJar0GGG0NGomp6XPhumhIfu5JxKk8mftKuoZacWVXm.qVJ4egXLX2JkQGoPj9kqedcv ZPBpPKm.nVhS0Zz5wXCSmLTVRC6fI.zuPLKyqAw0ZcsB5f7Pw14QekRQrx8p1GRr6hr2YCgjWGqm JGDWW7ZkPxJoxlvl8M4PoZN1xOyO94WwfBtxvJxKewmvA4O5CWpP1WetRBbWjwvMA2PVR_hHMnBC nS5NJnazuT5GwhMczloLrTU4AGVwbKg5nto.7in5ib X-Sonic-MF: Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic310.consmr.mail.ne1.yahoo.com with HTTP; Mon, 25 Oct 2021 11:47:51 +0000 Original-Received: by kubenode502.mail-prod1.omega.sg3.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 3b882b968b9e95774653e1cc703ee60a; Mon, 25 Oct 2021 11:47:45 +0000 (UTC) In-Reply-To: (Alan Third's message of "Mon, 25 Oct 2021 10:08:30 +0100") X-Mailer: WebService/1.1.19198 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:218261 Archived-At: --=-=-= Content-Type: text/plain Alan Third writes: > Perhaps we'd be better sticking with NSApplication's > 'postEvent:atStart:'? I don't know if it can do the same thing. Thanks, please test. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Support-opening-the-toolkit-menu-bar-on-NS.patch >From 24c019196c865268a2ad3aedf5706b54b80e4e2c 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 | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ src/nsterm.m | 1 + 3 files changed, 61 insertions(+), 3 deletions(-) diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el index fafc99eb95..b66f620276 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 29201e6907..b93d3a79bd 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -439,6 +439,44 @@ ns_update_menubar (f, deep_p); } +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 + NSWindow *window = [FRAME_NS_VIEW (frame) window]; + NSScreen *screen = [window screen]; + + NSRect screen_frame = [screen frame]; + [app postEvent: [NSEvent mouseEventWithType: NSLeftMouseDown + location: NSMakePoint (NSMinX (screen_frame), + NSMinY (screen_frame) + 10) + modifierFlags: 0 + timestamp: 0 + windowNumber: [window windowNumber] + context: [NSGraphicsContext currentContext] + eventNumber: 0 + clickCount: 1 + pressure: 1.0f] + atStart: YES]; +#endif + break; + } + } + unblock_input (); +} /* ========================================================================== @@ -1916,6 +1954,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 @@ -1927,6 +1981,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 c10b6feca1..d9c28cb191 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -5078,6 +5078,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 --=-=-=--