/* NeXT/Open/GNUstep and MacOSX Cocoa menu and toolbar module.
- Copyright (C) 2007-2012 Free Software Foundation, Inc.
+ Copyright (C) 2007-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
========================================================================== */
-/* 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. */
static EmacsMenu *last_submenu = nil;
BOOL needsSet = NO;
const char *submenuTitle = [[submenu title] UTF8String];
- extern int waiting_for_input;
- int owfi;
+ bool owfi;
Lisp_Object items;
widget_value *wv, *first_wv, *prev_wv = 0;
int i;
long t;
#endif
- NSTRACE (set_frame_menubar);
+ NSTRACE (ns_update_menubar);
if (f != SELECTED_FRAME ())
return;
/* Fully parse one or more of the submenus. */
int n = 0;
int *submenu_start, *submenu_end;
- int *submenu_top_level_items, *submenu_n_panes;
+ bool *submenu_top_level_items;
+ int *submenu_n_panes;
struct buffer *prev = current_buffer;
Lisp_Object buffer;
ptrdiff_t specpdl_count = SPECPDL_INDEX ();
= alloca (previous_menu_items_used * sizeof *previous_items);
/* lisp preliminaries */
- buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
+ buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->contents;
specbind (Qinhibit_quit, Qt);
specbind (Qdebug_on_next_call, Qnil);
record_unwind_save_match_data ();
ns_update_menubar (f, deep_p, nil);
}
+void
+x_activate_menubar (struct frame *f)
+{
+ NSArray *a = [[NSApp mainMenu] itemArray];
+ /* Update each submenu separately so ns_update_menubar doesn'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 ();
+}
+
+
+
/* ==========================================================================
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
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
}
#ifdef NS_IMPL_GNUSTEP
if ([[self window] isVisible])
[self sizeToFit];
-#else
-#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_2
- if ([self supermenu] == nil)
- [self sizeToFit];
-#endif
#endif
}
/* run a menu in popup mode */
- (Lisp_Object)runMenuAt: (NSPoint)p forFrame: (struct frame *)f
- keymaps: (int)keymaps
+ keymaps: (bool)keymaps
{
EmacsView *view = FRAME_NS_VIEW (f);
NSEvent *e, *event;
========================================================================== */
Lisp_Object
-ns_menu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
+ns_menu_show (FRAME_PTR f, int x, int y, bool for_click, bool keymaps,
Lisp_Object title, const char **error)
{
EmacsMenu *pmenu;
#if 0
/* FIXME: a couple of one-line differences prevent reuse */
- wv = digest_single_submenu (0, menu_items_used, Qnil);
+ wv = digest_single_submenu (0, menu_items_used, 0);
#else
{
widget_value *save_wv = 0, *prev_wv = 0;
FRAME_TOOLBAR_HEIGHT (f) =
NSHeight ([window frameRectForContentRect: NSMakeRect (0, 0, 0, 0)])
- FRAME_NS_TITLEBAR_HEIGHT (f);
+ if (FRAME_TOOLBAR_HEIGHT (f) < 0) // happens if frame is fullscreen.
+ FRAME_TOOLBAR_HEIGHT (f) = 0;
unblock_input ();
}
wr.size = [textField frame].size;
[win setFrame: wr display: YES];
+ [win setLevel: NSPopUpMenuWindowLevel];
[win orderFront: self];
[win display];
timer = [NSTimer scheduledTimerWithTimeInterval: (float)seconds target: self
static Lisp_Object
pop_down_menu (Lisp_Object arg)
{
- struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
- struct Popdown_data *unwind_data = (struct Popdown_data *) p->pointer;
+ struct Popdown_data *unwind_data = XSAVE_POINTER (arg, 0);
block_input ();
if (popup_activated_flag)
NSTRACE (x-popup-dialog);
- check_ns ();
+ check_window_system ();
isQ = NILP (header);
unwind_data->pool = pool;
unwind_data->dialog = dialog;
- record_unwind_protect (pop_down_menu, make_save_value (unwind_data, 0));
+ record_unwind_protect (pop_down_menu, make_save_pointer (unwind_data));
popup_activated_flag = 1;
tem = [dialog runDialogAt: p];
unbind_to (specpdl_count, Qnil); /* calls pop_down_menu */