diff options
author | Jan Djärv <[email protected]> | 2013-03-30 10:57:27 +0100 |
---|---|---|
committer | Jan Djärv <[email protected]> | 2013-03-30 10:57:27 +0100 |
commit | 6d01f1feafdbcf90b4a602ed6ae4a3f543f5b8b9 (patch) | |
tree | 0ef1e43f227757901b27e5c113203c53af34a827 /src/nsmenu.m | |
parent | 73572c72157ae732679c858bc5f3497473649b2f (diff) |
* nsmenu.m (ns_update_menubar): Correct NSTRACE.
(x_activate_menubar): Update the menu with title that matches
ns_get_pending_menu_title, and call
ns_check_pending_openmenu.
(menuWillOpen:): New method.
(menuNeedsUpdate:): Add check for ! COCOA || OSX < 10.5 (Bug#12698).
* nsterm.h (ns_get_pending_menu_title, ns_check_menu_open)
(ns_check_pending_open_menu): Declare.
* nsterm.m (menu_will_open_state, menu_mouse_point)
(menu_pending_title): New varaibles.
(ns_get_pending_menu_title, ns_check_menu_open)
(ns_check_pending_open_menu): New functions.
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r-- | src/nsmenu.m | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m index b764d3f595..02c5f9e6e5 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -88,14 +88,6 @@ static int trackingMenu; ========================================================================== */ -/* FIXME: not currently used, but should normalize with other terms. */ -void -x_activate_menubar (struct frame *f) -{ - fprintf (stderr, "XXX: Received x_activate_menubar event.\n"); -} - - /* Supposed to discard menubar and free storage. Since we share the menubar among frames and update its context for the focused window, there is nothing to do here. */ @@ -138,7 +130,7 @@ ns_update_menubar (struct frame *f, bool deep_p, EmacsMenu *submenu) long t; #endif - NSTRACE (set_frame_menubar); + NSTRACE (ns_update_menubar); if (f != SELECTED_FRAME ()) return; @@ -512,6 +504,29 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p) ns_update_menubar (f, deep_p, nil); } +void +x_activate_menubar (struct frame *f) +{ + NSArray *a = [[NSApp mainMenu] itemArray]; + /* Update each submenu separatly so ns_update_menubar don't reset + the delegate. */ + int i = 0; + while (i < [a count]) + { + EmacsMenu *menu = (EmacsMenu *)[[a objectAtIndex:i] submenu]; + const char *title = [[menu title] UTF8String]; + if (strcmp (title, ns_get_pending_menu_title ()) == 0) + { + ns_update_menubar (f, true, menu); + break; + } + ++i; + } + ns_check_pending_open_menu (); +} + + + /* ========================================================================== @@ -564,6 +579,14 @@ extern NSString *NSMenuDidBeginTrackingNotification; trackingMenu = ([notification name] == NSMenuDidBeginTrackingNotification ? 1 : 0); } + +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +- (void)menuWillOpen:(NSMenu *)menu +{ + ns_check_menu_open (menu); +} +#endif + #endif /* delegate method called when a submenu is being opened: run a 'deep' call @@ -591,7 +614,12 @@ extern NSString *NSMenuDidBeginTrackingNotification; if (trackingMenu == 0) return; /*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ - ns_update_menubar (frame, 1, self); +#if ! defined(NS_IMPL_COCOA) || \ + MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 + /* Don't know how to do this for anything other than OSX >= 10.5 + This is wrong, as it might run Lisp code in the event loop. */ + ns_update_menubar (frame, true, self); +#endif } |