aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsmenu.m
diff options
context:
space:
mode:
Diffstat (limited to 'src/nsmenu.m')
-rw-r--r--src/nsmenu.m43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 210f4530d7a..657b9306942 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -73,7 +73,6 @@ EmacsMenu *mainMenu, *svcsMenu, *dockMenu;
73 73
74/* Nonzero means a menu is currently active. */ 74/* Nonzero means a menu is currently active. */
75static int popup_activated_flag; 75static int popup_activated_flag;
76static NSModalSession popupSession;
77 76
78/* Nonzero means we are tracking and updating menus. */ 77/* Nonzero means we are tracking and updating menus. */
79static int trackingMenu; 78static int trackingMenu;
@@ -1365,8 +1364,6 @@ pop_down_menu (Lisp_Object arg)
1365 { 1364 {
1366 EmacsDialogPanel *panel = unwind_data->dialog; 1365 EmacsDialogPanel *panel = unwind_data->dialog;
1367 popup_activated_flag = 0; 1366 popup_activated_flag = 0;
1368 [NSApp endModalSession: popupSession];
1369
1370 [panel close]; 1367 [panel close];
1371 [unwind_data->pool release]; 1368 [unwind_data->pool release];
1372 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; 1369 [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
@@ -1756,20 +1753,40 @@ void process_dialog (id window, Lisp_Object list)
1756} 1753}
1757 1754
1758 1755
1756
1757- (void)timeout_handler: (NSTimer *)timedEntry
1758{
1759 timer_fired = 1;
1760 [NSApp abortModal];
1761}
1762
1759- (Lisp_Object)runDialogAt: (NSPoint)p 1763- (Lisp_Object)runDialogAt: (NSPoint)p
1760{ 1764{
1761 NSInteger ret; 1765 NSInteger ret = 0;
1762 1766
1763 /* initiate a session that will be ended by pop_down_menu */ 1767 while (popup_activated_flag)
1764 popupSession = [NSApp beginModalSessionForWindow: self];
1765 while (popup_activated_flag
1766 && (ret = [NSApp runModalSession: popupSession])
1767 == NSRunContinuesResponse)
1768 { 1768 {
1769 /* Run this for timers.el, indep of atimers; might not return. 1769 NSTimer *tmo = nil;
1770 TODO: use return value to avoid calling every iteration. */ 1770 EMACS_TIME next_time = timer_check ();
1771 timer_check (); 1771
1772 [NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]]; 1772 if (EMACS_TIME_VALID_P (next_time))
1773 {
1774 double time = EMACS_TIME_TO_DOUBLE (next_time);
1775 tmo = [NSTimer timerWithTimeInterval: time
1776 target: self
1777 selector: @selector (timeout_handler:)
1778 userInfo: 0
1779 repeats: NO];
1780 [[NSRunLoop currentRunLoop] addTimer: tmo
1781 forMode: NSModalPanelRunLoopMode];
1782 }
1783 timer_fired = 0;
1784 ret = [NSApp runModalForWindow: self];
1785 if (! timer_fired)
1786 {
1787 if (tmo != nil) [tmo invalidate]; /* Cancels timer */
1788 break;
1789 }
1773 } 1790 }
1774 1791
1775 { /* FIXME: BIG UGLY HACK!!! */ 1792 { /* FIXME: BIG UGLY HACK!!! */