diff options
| author | Adrian Robert | 2009-02-04 11:31:28 +0000 |
|---|---|---|
| committer | Adrian Robert | 2009-02-04 11:31:28 +0000 |
| commit | c96169a0b1f1725f42ad0e2958599d2fd2929ec6 (patch) | |
| tree | 47c4b32fba34862b221c3cc89822d44a1bfde07e /src | |
| parent | 22b5692c3d5921910c1d9b3bf4b5fffb155694e7 (diff) | |
| download | emacs-c96169a0b1f1725f42ad0e2958599d2fd2929ec6.tar.gz emacs-c96169a0b1f1725f42ad0e2958599d2fd2929ec6.zip | |
* 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')
| -rw-r--r-- | src/ChangeLog | 19 | ||||
| -rw-r--r-- | src/keyboard.c | 19 | ||||
| -rw-r--r-- | src/nsmenu.m | 47 | ||||
| -rw-r--r-- | src/nsterm.m | 42 | ||||
| -rw-r--r-- | src/s/darwin.h | 9 |
5 files changed, 83 insertions, 53 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b55b8db9917..7952b434b4f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,22 @@ | |||
| 1 | 2009-02-04 Adrian Robert <Adrian.B.Robert@gmail.com> | ||
| 2 | |||
| 3 | * nsmenu.m (pop_down_menu): New function. | ||
| 4 | (ns_popup_dialog): Call it on unwind. | ||
| 5 | (EmacsDialogPanel-runDialogAt:): Check popup_activated_flag and | ||
| 6 | call timer_check() (Bug#2154). | ||
| 7 | (EmacsMenu-menuNeedsUpdate:): Don't call ns_update_menu if | ||
| 8 | handling_signal is set. | ||
| 9 | (EmacsMenu-fillWithWidgetValue:): Set submenu title. | ||
| 10 | |||
| 11 | * config.in: Get rid of COCOA_EXPERIMENTAL_CTRL_G | ||
| 12 | |||
| 13 | * s/darwin.h: Same and NO_SOCK_SIGIO as well. | ||
| 14 | |||
| 15 | * nsterm.m (ns_read_socket): Same and don't set handling_signal. | ||
| 16 | |||
| 17 | * keyboard.c (poll_for_input_1, handle_async_input): Set | ||
| 18 | handling_signal under HAVE_NS. | ||
| 19 | |||
| 1 | 2009-02-04 Glenn Morris <rgm@gnu.org> | 20 | 2009-02-04 Glenn Morris <rgm@gnu.org> |
| 2 | 21 | ||
| 3 | * fileio.c (Fwrite_region): Doc fix (mention annotate-functions). | 22 | * fileio.c (Fwrite_region): Doc fix (mention annotate-functions). |
diff --git a/src/keyboard.c b/src/keyboard.c index e5d08961001..8b411fdac8b 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -2182,16 +2182,24 @@ struct atimer *poll_timer; | |||
| 2182 | 2182 | ||
| 2183 | #ifdef POLL_FOR_INPUT | 2183 | #ifdef POLL_FOR_INPUT |
| 2184 | 2184 | ||
| 2185 | /* Poll for input, so what we catch a C-g if it comes in. This | 2185 | /* Poll for input, so that we catch a C-g if it comes in. This |
| 2186 | function is called from x_make_frame_visible, see comment | 2186 | function is called from x_make_frame_visible, see comment |
| 2187 | there. */ | 2187 | there. */ |
| 2188 | 2188 | ||
| 2189 | void | 2189 | void |
| 2190 | poll_for_input_1 () | 2190 | poll_for_input_1 () |
| 2191 | { | 2191 | { |
| 2192 | /* Tell ns_read_socket() it is being called asynchronously so it can avoid | ||
| 2193 | doing anything dangerous. */ | ||
| 2194 | #ifdef HAVE_NS | ||
| 2195 | ++handling_signal; | ||
| 2196 | #endif | ||
| 2192 | if (interrupt_input_blocked == 0 | 2197 | if (interrupt_input_blocked == 0 |
| 2193 | && !waiting_for_input) | 2198 | && !waiting_for_input) |
| 2194 | read_avail_input (0); | 2199 | read_avail_input (0); |
| 2200 | #ifdef HAVE_NS | ||
| 2201 | --handling_signal; | ||
| 2202 | #endif | ||
| 2195 | } | 2203 | } |
| 2196 | 2204 | ||
| 2197 | /* Timer callback function for poll_timer. TIMER is equal to | 2205 | /* Timer callback function for poll_timer. TIMER is equal to |
| @@ -7276,7 +7284,11 @@ handle_async_input () | |||
| 7276 | #ifdef SYNC_INPUT | 7284 | #ifdef SYNC_INPUT |
| 7277 | pending_signals = pending_atimers; | 7285 | pending_signals = pending_atimers; |
| 7278 | #endif | 7286 | #endif |
| 7279 | 7287 | /* Tell ns_read_socket() it is being called asynchronously so it can avoid | |
| 7288 | doing anything dangerous. */ | ||
| 7289 | #ifdef HAVE_NS | ||
| 7290 | ++handling_signal; | ||
| 7291 | #endif | ||
| 7280 | while (1) | 7292 | while (1) |
| 7281 | { | 7293 | { |
| 7282 | int nread; | 7294 | int nread; |
| @@ -7287,6 +7299,9 @@ handle_async_input () | |||
| 7287 | if (nread <= 0) | 7299 | if (nread <= 0) |
| 7288 | break; | 7300 | break; |
| 7289 | } | 7301 | } |
| 7302 | #ifdef HAVE_NS | ||
| 7303 | --handling_signal; | ||
| 7304 | #endif | ||
| 7290 | } | 7305 | } |
| 7291 | 7306 | ||
| 7292 | void | 7307 | void |
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) | |||
| 573 | since key equivalents are handled through emacs. | 573 | since key equivalents are handled through emacs. |
| 574 | On Leopard, even keystroke events generate SystemDefined events, but | 574 | On Leopard, even keystroke events generate SystemDefined events, but |
| 575 | their subtype is 8. */ | 575 | their subtype is 8. */ |
| 576 | if ([event type] != NSSystemDefined || [event subtype] == 8) | 576 | if ([event type] != NSSystemDefined || [event subtype] == 8 |
| 577 | /* Also, don't try this if from an event picked up asynchronously, | ||
| 578 | as lots of lisp evaluation happens in ns_update_menubar. */ | ||
| 579 | || handling_signal != 0) | ||
| 577 | return; | 580 | return; |
| 578 | /*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ | 581 | /*fprintf (stderr, "Updating menu '%s'\n", [[self title] UTF8String]); NSLog (@"%@\n", event); */ |
| 579 | ns_update_menubar (frame, 1, self); | 582 | ns_update_menubar (frame, 1, self); |
| @@ -688,7 +691,7 @@ name_is_separator (name) | |||
| 688 | 691 | ||
| 689 | if (wv->contents) | 692 | if (wv->contents) |
| 690 | { | 693 | { |
| 691 | EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: @"Submenu"]; | 694 | EmacsMenu *submenu = [[EmacsMenu alloc] initWithTitle: [item title]]; |
| 692 | 695 | ||
| 693 | [self setSubmenu: submenu forItem: item]; | 696 | [self setSubmenu: submenu forItem: item]; |
| 694 | [submenu fillWithWidgetValue: wv->contents]; | 697 | [submenu fillWithWidgetValue: wv->contents]; |
| @@ -1485,6 +1488,20 @@ update_frame_tool_bar (FRAME_PTR f) | |||
| 1485 | 1488 | ||
| 1486 | ========================================================================== */ | 1489 | ========================================================================== */ |
| 1487 | 1490 | ||
| 1491 | |||
| 1492 | static Lisp_Object | ||
| 1493 | pop_down_menu (Lisp_Object arg) | ||
| 1494 | { | ||
| 1495 | struct Lisp_Save_Value *p = XSAVE_VALUE (arg); | ||
| 1496 | popup_activated_flag = 0; | ||
| 1497 | BLOCK_INPUT; | ||
| 1498 | [((EmacsDialogPanel *) (p->pointer)) close]; | ||
| 1499 | [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; | ||
| 1500 | UNBLOCK_INPUT; | ||
| 1501 | return Qnil; | ||
| 1502 | } | ||
| 1503 | |||
| 1504 | |||
| 1488 | Lisp_Object | 1505 | Lisp_Object |
| 1489 | ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | 1506 | ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) |
| 1490 | { | 1507 | { |
| @@ -1539,13 +1556,18 @@ ns_popup_dialog (Lisp_Object position, Lisp_Object contents, Lisp_Object header) | |||
| 1539 | p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; | 1556 | p.y = (int)f->top_pos + (FRAME_LINE_HEIGHT (f) * f->text_lines)/2; |
| 1540 | dialog = [[EmacsDialogPanel alloc] initFromContents: contents | 1557 | dialog = [[EmacsDialogPanel alloc] initFromContents: contents |
| 1541 | isQuestion: isQ]; | 1558 | isQuestion: isQ]; |
| 1542 | popup_activated_flag = 1; | 1559 | { |
| 1543 | tem = [dialog runDialogAt: p]; | 1560 | int specpdl_count = SPECPDL_INDEX (); |
| 1544 | popup_activated_flag = 0; | 1561 | record_unwind_protect (pop_down_menu, make_save_value (dialog, 0)); |
| 1562 | popup_activated_flag = 1; | ||
| 1563 | tem = [dialog runDialogAt: p]; | ||
| 1564 | popup_activated_flag = 0; | ||
| 1565 | unbind_to (specpdl_count, Qnil); | ||
| 1566 | } | ||
| 1545 | 1567 | ||
| 1546 | [dialog close]; | 1568 | [dialog close]; |
| 1547 | |||
| 1548 | [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; | 1569 | [[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow]; |
| 1570 | |||
| 1549 | return tem; | 1571 | return tem; |
| 1550 | } | 1572 | } |
| 1551 | 1573 | ||
| @@ -1858,12 +1880,14 @@ void process_dialog (id window, Lisp_Object list) | |||
| 1858 | [self orderFront: NSApp]; | 1880 | [self orderFront: NSApp]; |
| 1859 | 1881 | ||
| 1860 | session = [NSApp beginModalSessionForWindow: self]; | 1882 | session = [NSApp beginModalSessionForWindow: self]; |
| 1861 | while ((ret = [NSApp runModalSession: session]) == NSRunContinuesResponse) | 1883 | while (popup_activated_flag |
| 1884 | && (ret = [NSApp runModalSession: session]) == NSRunContinuesResponse) | ||
| 1862 | { | 1885 | { |
| 1863 | (e = [NSApp nextEventMatchingMask: NSAnyEventMask | 1886 | timer_check (1); // for timers.el, indep of atimers; might not return |
| 1864 | untilDate: [NSDate distantFuture] | 1887 | e = [NSApp nextEventMatchingMask: NSAnyEventMask |
| 1865 | inMode: NSModalPanelRunLoopMode | 1888 | untilDate: [NSDate dateWithTimeIntervalSinceNow: 1] |
| 1866 | dequeue: NO]); | 1889 | inMode: NSModalPanelRunLoopMode |
| 1890 | dequeue: NO]; | ||
| 1867 | /*fprintf (stderr, "ret = %d\te = %p\n", ret, e);*/ | 1891 | /*fprintf (stderr, "ret = %d\te = %p\n", ret, e);*/ |
| 1868 | } | 1892 | } |
| 1869 | [NSApp endModalSession: session]; | 1893 | [NSApp endModalSession: session]; |
| @@ -1878,7 +1902,6 @@ void process_dialog (id window, Lisp_Object list) | |||
| 1878 | @end | 1902 | @end |
| 1879 | 1903 | ||
| 1880 | 1904 | ||
| 1881 | |||
| 1882 | /* ========================================================================== | 1905 | /* ========================================================================== |
| 1883 | 1906 | ||
| 1884 | Lisp definitions | 1907 | Lisp definitions |
diff --git a/src/nsterm.m b/src/nsterm.m index 411ce5b5c43..2ef3a3ec906 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -3132,7 +3132,7 @@ ns_read_socket (struct terminal *terminal, int expected, | |||
| 3132 | int nevents; | 3132 | int nevents; |
| 3133 | static NSDate *lastCheck = nil; | 3133 | static NSDate *lastCheck = nil; |
| 3134 | 3134 | ||
| 3135 | /* NSTRACE (ns_read_socket); */ | 3135 | /* NSTRACE (ns_read_socket); */ |
| 3136 | 3136 | ||
| 3137 | if (interrupt_input_blocked) | 3137 | if (interrupt_input_blocked) |
| 3138 | { | 3138 | { |
| @@ -3147,15 +3147,8 @@ ns_read_socket (struct terminal *terminal, int expected, | |||
| 3147 | #ifdef SYNC_INPUT | 3147 | #ifdef SYNC_INPUT |
| 3148 | pending_signals = pending_atimers; | 3148 | pending_signals = pending_atimers; |
| 3149 | #endif | 3149 | #endif |
| 3150 | BLOCK_INPUT; | ||
| 3151 | |||
| 3152 | #ifdef COCOA_EXPERIMENTAL_CTRL_G | ||
| 3153 | /* causes Feval to abort; should probably set this in calling code when | ||
| 3154 | it IS actually called from signal handler, in which case we need to | ||
| 3155 | defer ns_update_menubar() calls */ | ||
| 3156 | ++handling_signal; | ||
| 3157 | #endif | ||
| 3158 | 3150 | ||
| 3151 | BLOCK_INPUT; | ||
| 3159 | n_emacs_events_pending = 0; | 3152 | n_emacs_events_pending = 0; |
| 3160 | EVENT_INIT (ev); | 3153 | EVENT_INIT (ev); |
| 3161 | emacs_event = &ev; | 3154 | emacs_event = &ev; |
| @@ -3210,10 +3203,6 @@ ns_read_socket (struct terminal *terminal, int expected, | |||
| 3210 | nevents = n_emacs_events_pending; | 3203 | nevents = n_emacs_events_pending; |
| 3211 | n_emacs_events_pending = 0; | 3204 | n_emacs_events_pending = 0; |
| 3212 | emacs_event = q_event_ptr = NULL; | 3205 | emacs_event = q_event_ptr = NULL; |
| 3213 | |||
| 3214 | #ifdef COCOA_EXPERIMENTAL_CTRL_G | ||
| 3215 | --handling_signal; | ||
| 3216 | #endif | ||
| 3217 | UNBLOCK_INPUT; | 3206 | UNBLOCK_INPUT; |
| 3218 | 3207 | ||
| 3219 | return nevents; | 3208 | return nevents; |
| @@ -4164,24 +4153,24 @@ ns_term_shutdown (int sig) | |||
| 4164 | Cmd-Q: | 4153 | Cmd-Q: |
| 4165 | MenuBar | File | Exit: | 4154 | MenuBar | File | Exit: |
| 4166 | ns_term_shutdown: 0 | 4155 | ns_term_shutdown: 0 |
| 4167 | received -terminate: 1 | 4156 | -terminate: 1 |
| 4168 | received -appShouldTerminate: 1 | 4157 | -appShouldTerminate: 1 |
| 4169 | 4158 | ||
| 4170 | Select Quit from App menubar: | 4159 | Select Quit from App menubar: |
| 4171 | received -terminate: 0 | 4160 | received -terminate: 0 |
| 4172 | ns_term_shutdown: 0 | 4161 | ns_term_shutdown: 0 |
| 4173 | received -terminate: 1 | 4162 | -terminate: 1 |
| 4174 | received -appShouldTerminate: 1 | 4163 | -appShouldTerminate: 1 |
| 4175 | 4164 | ||
| 4176 | Select Quit from Dock menu: | 4165 | Select Quit from Dock menu: |
| 4177 | Logout attempt: | 4166 | Logout attempt: |
| 4178 | received -appShouldTerminate: 0 | 4167 | -appShouldTerminate: 0 |
| 4179 | Cancel -> Nothing else | 4168 | Cancel -> Nothing else |
| 4180 | Accept -> | 4169 | Accept -> |
| 4181 | received -terminate: 0 | 4170 | -terminate: 0 |
| 4182 | ns_term_shutdown: 0 | 4171 | ns_term_shutdown: 0 |
| 4183 | received -terminate: 1 | 4172 | -terminate: 1 |
| 4184 | received -appShouldTerminate: 1 | 4173 | -appShouldTerminate: 1 |
| 4185 | */ | 4174 | */ |
| 4186 | 4175 | ||
| 4187 | - (void) terminate: (id)sender | 4176 | - (void) terminate: (id)sender |
| @@ -4212,8 +4201,8 @@ ns_term_shutdown (int sig) | |||
| 4212 | 4201 | ||
| 4213 | /* XXX: This while() loop is needed because if the user switches to another | 4202 | /* XXX: This while() loop is needed because if the user switches to another |
| 4214 | application while the panel is up, it is taken down w/a return value | 4203 | application while the panel is up, it is taken down w/a return value |
| 4215 | of -1000, and the event queue gets messed up. In this case resend | 4204 | of NSRunStoppedResponse, and the event queue gets messed up. |
| 4216 | the appdefined and put up the window again. */ | 4205 | In this case resend the appdefined and put up the window again. */ |
| 4217 | while (1) { | 4206 | while (1) { |
| 4218 | ret = NSRunAlertPanel([[NSProcessInfo processInfo] processName], | 4207 | ret = NSRunAlertPanel([[NSProcessInfo processInfo] processName], |
| 4219 | [NSString stringWithUTF8String:"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?"], | 4208 | [NSString stringWithUTF8String:"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?"], |
| @@ -5112,13 +5101,6 @@ extern void update_window_cursor (struct window *w, int on); | |||
| 5112 | x_set_window_size (emacsframe, 0, cols, rows); | 5101 | x_set_window_size (emacsframe, 0, cols, rows); |
| 5113 | 5102 | ||
| 5114 | ns_send_appdefined (-1); | 5103 | ns_send_appdefined (-1); |
| 5115 | |||
| 5116 | /* The following line causes a crash on GNUstep. Adrian Robert | ||
| 5117 | says he doesn't remember why he added this line, but removing it | ||
| 5118 | doesn't seem to cause problems on OSX, either. */ | ||
| 5119 | #if 0 | ||
| 5120 | [NSApp stopModal]; | ||
| 5121 | #endif | ||
| 5122 | } | 5104 | } |
| 5123 | 5105 | ||
| 5124 | 5106 | ||
diff --git a/src/s/darwin.h b/src/s/darwin.h index 97a514a56b0..da223e9a41c 100644 --- a/src/s/darwin.h +++ b/src/s/darwin.h | |||
| @@ -133,15 +133,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 133 | /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ | 133 | /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ |
| 134 | #define HAVE_SOCKETS | 134 | #define HAVE_SOCKETS |
| 135 | 135 | ||
| 136 | /* This seems to help in Ctrl-G detection under Cocoa, however at the cost | ||
| 137 | of some quirks that may or may not bother a given user. | ||
| 138 | It was earlier commented that "In Carbon, asynchronous I/O (using SIGIO) | ||
| 139 | can't be used for window events because they don't come from sockets, | ||
| 140 | even though it works fine on tty's. Uncertain about situation in Cocoa. */ | ||
| 141 | #ifdef COCOA_EXPERIMENTAL_CTRL_G | ||
| 142 | #define NO_SOCK_SIGIO | ||
| 143 | #endif | ||
| 144 | |||
| 145 | /* Definitions for how to dump. Copied from nextstep.h. */ | 136 | /* Definitions for how to dump. Copied from nextstep.h. */ |
| 146 | 137 | ||
| 147 | #define UNEXEC unexmacosx.o | 138 | #define UNEXEC unexmacosx.o |