diff options
author | Adrian Robert <Adrian.B.Robert@gmail.com> | 2009-02-04 11:31:28 +0000 |
---|---|---|
committer | Adrian Robert <Adrian.B.Robert@gmail.com> | 2009-02-04 11:31:28 +0000 |
commit | c96169a0b1f1725f42ad0e2958599d2fd2929ec6 (patch) | |
tree | 47c4b32fba34862b221c3cc89822d44a1bfde07e /src/nsmenu.m | |
parent | 22b5692c3d5921910c1d9b3bf4b5fffb155694e7 (diff) | |
download | emacs-c96169a0b1f1725f42ad0e2958599d2fd2929ec6.tar.gz |
* nsmenu.m (pop_down_menu): New function.
(ns_popup_dialog): Call it on unwind.
(EmacsDialogPanel-runDialogAt:): Check popup_activated_flag and
call timer_check() (Bug#2154).
(EmacsMenu-menuNeedsUpdate:): Don't call ns_update_menu if
handling_signal is set.
(EmacsMenu-fillWithWidgetValue:): Set submenu title.
* s/darwin.h: Same and NO_SOCK_SIGIO as well.
* nsterm.m (ns_read_socket): Same and don't set handling_signal.
* keyboard.c (poll_for_input_1, handle_async_input): Set
handling_signal under HAVE_NS.
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r-- | src/nsmenu.m | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m index b3c56809733..c6d4c21a179 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -573,7 +573,10 @@ name_is_separator (name) since key equivalents are handled through emacs. On Leopard, even keystroke events generate SystemDefined events, but their subtype is 8. */ - if ([event type] != NSSystemDefined || [event subtype] == 8) + if ([event type] != NSSystemDefined || [event subtype] == 8 + /* Also, don't try this if from an event picked up asynchronously, + as lots of lisp evaluation happens in ns_update_menubar. */ + || handling_signal != 0) return; /*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ ns_update_menubar (frame, 1, self); @@ -688,7 +691,7 @@ name_is_separator (name) if (wv->contents) { - EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: @"Submenu"]; + EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: [item title]]; [self setSubmenu: submenu forItem: item]; [submenu fillWithWidgetValue: wv->contents]; @@ -1485,6 +1488,20 @@ update_frame_tool_bar (FRAME_PTR f) ========================================================================== */ + +static Lisp_Object +pop_down_menu (Lisp_Object arg) +{ + struct Lisp_Save_Value *p = XSAVE_VALUE (arg); + popup_activated_flag = 0; + BLOCK_INPUT; + [((EmacsDialogPanel *) (p->pointer)) close]; + [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; + UNBLOCK_INPUT; + return Qnil; +} + + Lisp_Object ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) { @@ -1539,13 +1556,18 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; dialog = [[EmacsDialogPanel alloc] initFromContents: contents isQuestion: isQ]; - popup_activated_flag = 1; - tem = [dialog runDialogAt: p]; - popup_activated_flag = 0; + { + int specpdl_count = SPECPDL_INDEX (); + record_unwind_protect (pop_down_menu, make_save_value (dialog, 0)); + popup_activated_flag = 1; + tem = [dialog runDialogAt: p]; + popup_activated_flag = 0; + unbind_to (specpdl_count, Qnil); + } [dialog close]; - [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; + return tem; } @@ -1858,12 +1880,14 @@ void process_dialog (id window, Lisp_Object list) [self orderFront: NSApp]; session = [NSApp beginModalSessionForWindow: self]; - while ((ret = [NSApp runModalSession: session]) == NSRunContinuesResponse) + while (popup_activated_flag + && (ret = [NSApp runModalSession: session]) == NSRunContinuesResponse) { - (e = [NSApp nextEventMatchingMask: NSAnyEventMask - untilDate: [NSDate distantFuture] - inMode: NSModalPanelRunLoopMode - dequeue: NO]); + timer_check (1); // for timers.el, indep of atimers; might not return + e = [NSApp nextEventMatchingMask: NSAnyEventMask + untilDate: [NSDate dateWithTimeIntervalSinceNow: 1] + inMode: NSModalPanelRunLoopMode + dequeue: NO]; /*fprintf (stderr, "ret = %d\te = %p\n", ret, e);*/ } [NSApp endModalSession: session]; @@ -1878,7 +1902,6 @@ void process_dialog (id window, Lisp_Object list) @end - /* ========================================================================== Lisp definitions |