aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsmenu.m
diff options
context:
space:
mode:
authorJoakim Verona2011-12-28 11:34:15 +0100
committerJoakim Verona2011-12-28 11:34:15 +0100
commit2f74c36bf173b5ad01f99e0d1b31b9b8fa5c8f2f (patch)
tree034e65ef002631d0aba8fc1a41e9984fc557e630 /src/nsmenu.m
parentbb29f044aa967831cd664c54eba0de0c701436ce (diff)
parentd23ab8e8726ecb7e3554644857b4a58e5f7408f1 (diff)
downloademacs-2f74c36bf173b5ad01f99e0d1b31b9b8fa5c8f2f.tar.gz
emacs-2f74c36bf173b5ad01f99e0d1b31b9b8fa5c8f2f.zip
upstream
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r--src/nsmenu.m46
1 files changed, 40 insertions, 6 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 951282910ac..94c6b6a6198 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -74,6 +74,10 @@ EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
74static int popup_activated_flag; 74static int popup_activated_flag;
75static NSModalSession popupSession; 75static NSModalSession popupSession;
76 76
77/* Nonzero means we are tracking and updating menus. */
78static int trackingMenu;
79
80
77/* NOTE: toolbar implementation is at end, 81/* NOTE: toolbar implementation is at end,
78 following complete menu implementation. */ 82 following complete menu implementation. */
79 83
@@ -400,6 +404,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
400 items = FRAME_MENU_BAR_ITEMS (f); 404 items = FRAME_MENU_BAR_ITEMS (f);
401 if (NILP (items)) 405 if (NILP (items))
402 { 406 {
407 free_menubar_widget_value_tree (first_wv);
403 [pool release]; 408 [pool release];
404 UNBLOCK_INPUT; 409 UNBLOCK_INPUT;
405 return; 410 return;
@@ -427,6 +432,7 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
427 432
428 if (i == n) 433 if (i == n)
429 { 434 {
435 free_menubar_widget_value_tree (first_wv);
430 [pool release]; 436 [pool release];
431 UNBLOCK_INPUT; 437 UNBLOCK_INPUT;
432 return; 438 return;
@@ -543,21 +549,44 @@ set_frame_menubar (struct frame *f, int first_time, int deep_p)
543 frame = f; 549 frame = f;
544} 550}
545 551
552#ifdef NS_IMPL_COCOA
553#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
554extern NSString *NSMenuDidBeginTrackingNotification;
555#endif
556#endif
557
558#ifdef NS_IMPL_COCOA
559-(void)trackingNotification:(NSNotification *)notification
560{
561 /* Update menu in menuNeedsUpdate only while tracking menus. */
562 trackingMenu = ([notification name] == NSMenuDidBeginTrackingNotification
563 ? 1 : 0);
564}
565#endif
546 566
547/* delegate method called when a submenu is being opened: run a 'deep' call 567/* delegate method called when a submenu is being opened: run a 'deep' call
548 to set_frame_menubar */ 568 to set_frame_menubar */
549- (void)menuNeedsUpdate: (NSMenu *)menu 569- (void)menuNeedsUpdate: (NSMenu *)menu
550{ 570{
551 NSEvent *event;
552 if (!FRAME_LIVE_P (frame)) 571 if (!FRAME_LIVE_P (frame))
553 return; 572 return;
554 event = [[FRAME_NS_VIEW (frame) window] currentEvent]; 573
555 /* HACK: Cocoa/Carbon will request update on every keystroke 574 /* Cocoa/Carbon will request update on every keystroke
556 via IsMenuKeyEvent -> CheckMenusForKeyEvent. These are not needed 575 via IsMenuKeyEvent -> CheckMenusForKeyEvent. These are not needed
557 since key equivalents are handled through emacs. 576 since key equivalents are handled through emacs.
558 On Leopard, even keystroke events generate SystemDefined events, but 577 On Leopard, even keystroke events generate SystemDefined event.
559 their subtype is 8. */ 578 Third-party applications that enhance mouse / trackpad
560 if ([event type] != NSSystemDefined || [event subtype] == 8 579 interaction, or also VNC/Remote Desktop will send events
580 of type AppDefined rather than SysDefined.
581 Menus will fail to show up if they haven't been initialized.
582 AppDefined events may lack timing data.
583
584 Thus, we rely on the didBeginTrackingNotification notification
585 as above to indicate the need for updates.
586 From 10.6 on, we could also use -[NSMenu propertiesToUpdate]: In the
587 key press case, NSMenuPropertyItemImage (e.g.) won't be set.
588 */
589 if (trackingMenu == 0
561 /* Also, don't try this if from an event picked up asynchronously, 590 /* Also, don't try this if from an event picked up asynchronously,
562 as lots of lisp evaluation happens in ns_update_menubar. */ 591 as lots of lisp evaluation happens in ns_update_menubar. */
563 || handling_signal != 0) 592 || handling_signal != 0)
@@ -1795,6 +1824,11 @@ DEFUN ("menu-or-popup-active-p", Fmenu_or_popup_active_p, Smenu_or_popup_active_
1795void 1824void
1796syms_of_nsmenu (void) 1825syms_of_nsmenu (void)
1797{ 1826{
1827#ifndef NS_IMPL_COCOA
1828 /* Don't know how to keep track of this in Next/Open/Gnustep. Always
1829 update menus there. */
1830 trackingMenu = 1;
1831#endif
1798 defsubr (&Sx_popup_dialog); 1832 defsubr (&Sx_popup_dialog);
1799 defsubr (&Sns_reset_menu); 1833 defsubr (&Sns_reset_menu);
1800 defsubr (&Smenu_or_popup_active_p); 1834 defsubr (&Smenu_or_popup_active_p);