diff options
author | Adrian Robert <Adrian.B.Robert@gmail.com> | 2009-02-07 11:04:22 +0000 |
---|---|---|
committer | Adrian Robert <Adrian.B.Robert@gmail.com> | 2009-02-07 11:04:22 +0000 |
commit | 3175b12ae7dc142799e993a3bc5e076d47e20bd4 (patch) | |
tree | 2a0cd5461010b7f3fdd1da04e63f4abad2d6d448 /src/nsmenu.m | |
parent | 8434d0b8c0fe9870c4cf97079c69e29995e8f1e7 (diff) | |
download | emacs-3175b12ae7dc142799e993a3bc5e076d47e20bd4.tar.gz |
* nsterm.m (EmacsApp-sendEvent:): Defer NSApplicationDefined event
when modal window is active. (Bug #2152)
(applicationShouldTerminate:): Remove now-unneeded while loop
around NSRunAlertPanel.
* nsmenu.m (popupSession): New file-global variable.
(pop_down_menu): End the popupSession before closing dialog.
(ns_popup_dialog): BLOCK_INPUT around dialog presentation.
(EmacsDialogPanel-runDialogAt:): Don't place window (superfluous),
don't query NSApp for events (just sleep instead).
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r-- | src/nsmenu.m | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m index c6d4c21a179..f6b2075a841 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m @@ -73,6 +73,7 @@ EmacsMenu *mainMenu, *svcsMenu, *dockMenu; /* Nonzero means a menu is currently active. */ static int popup_activated_flag; +static NSModalSession popupSession; /* NOTE: toolbar implementation is at end, following complete menu implementation. */ @@ -1495,6 +1496,7 @@ pop_down_menu (Lisp_Object arg) struct Lisp_Save_Value *p = XSAVE_VALUE (arg); popup_activated_flag = 0; BLOCK_INPUT; + [NSApp endModalSession: popupSession]; [((EmacsDialogPanel *) (p->pointer)) close]; [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; UNBLOCK_INPUT; @@ -1554,6 +1556,8 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) p.x = (int)f->left_pos + ((int)FRAME_COLUMN_WIDTH (f) * f->text_cols)/2; p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; + + BLOCK_INPUT; dialog = [[EmacsDialogPanel alloc] initFromContents: contents isQuestion: isQ]; { @@ -1567,6 +1571,7 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) [dialog close]; [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; + UNBLOCK_INPUT; return tem; } @@ -1872,27 +1877,21 @@ void process_dialog (id window, Lisp_Object list) - (Lisp_Object)runDialogAt: (NSPoint)p { - NSEvent *e; - NSModalSession session; int ret; - [self center]; /*XXX p ignored? */ - [self orderFront: NSApp]; - - session = [NSApp beginModalSessionForWindow: self]; + popupSession = [NSApp beginModalSessionForWindow: self]; while (popup_activated_flag - && (ret = [NSApp runModalSession: session]) == NSRunContinuesResponse) + && (ret = [NSApp runModalSession: popupSession]) + == NSRunContinuesResponse) { - 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);*/ + /* Run this for timers.el, indep of atimers; might not return. + TODO: use return value to avoid calling every iteration. */ + timer_check (1); + [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; } - [NSApp endModalSession: session]; + [NSApp endModalSession: popupSession]; - { // FIXME: BIG UGLY HACK!!! + { /* FIXME: BIG UGLY HACK!!! */ Lisp_Object tmp; *(EMACS_INT*)(&tmp) = ret; return tmp; |