Mercurial > emacs
comparison src/macmenu.c @ 82289:26e674df63d5
(quit_dialog_event_loop) [TARGET_API_MAC_CARBON]:
New variable.
[TARGET_API_MAC_CARBON] (mac_handle_dialog_event): Set it if dialog
event loop should be quit.
[TARGET_API_MAC_CARBON] (create_and_show_dialog) [!MAC_OSX]:
Quit dialog event loop if quit_dialog_event_loop is set.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Mon, 06 Aug 2007 08:25:30 +0000 |
parents | b98604865ea0 |
children | 5b644ae74c91 424b655804ca |
comparison
equal
deleted
inserted
replaced
82288:d2b18c3b227c | 82289:26e674df63d5 |
---|---|
2329 ((id) - DIALOG_BUTTON_COMMAND_ID_OFFSET) | 2329 ((id) - DIALOG_BUTTON_COMMAND_ID_OFFSET) |
2330 #define DIALOG_BUTTON_MAKE_COMMAND_ID(value) \ | 2330 #define DIALOG_BUTTON_MAKE_COMMAND_ID(value) \ |
2331 ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET) | 2331 ((value) + DIALOG_BUTTON_COMMAND_ID_OFFSET) |
2332 | 2332 |
2333 extern EMACS_TIME timer_check P_ ((int)); | 2333 extern EMACS_TIME timer_check P_ ((int)); |
2334 static int quit_dialog_event_loop; | |
2334 | 2335 |
2335 static pascal OSStatus | 2336 static pascal OSStatus |
2336 mac_handle_dialog_event (next_handler, event, data) | 2337 mac_handle_dialog_event (next_handler, event, data) |
2337 EventHandlerCallRef next_handler; | 2338 EventHandlerCallRef next_handler; |
2338 EventRef event; | 2339 EventRef event; |
2339 void *data; | 2340 void *data; |
2340 { | 2341 { |
2341 OSStatus err, result = eventNotHandledErr; | 2342 OSStatus err, result = eventNotHandledErr; |
2342 WindowRef window = (WindowRef) data; | 2343 WindowRef window = (WindowRef) data; |
2343 int quit_event_loop_p = 0; | |
2344 | 2344 |
2345 switch (GetEventClass (event)) | 2345 switch (GetEventClass (event)) |
2346 { | 2346 { |
2347 case kEventClassCommand: | 2347 case kEventClassCommand: |
2348 { | 2348 { |
2353 NULL, &command); | 2353 NULL, &command); |
2354 if (err == noErr) | 2354 if (err == noErr) |
2355 if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID)) | 2355 if (DIALOG_BUTTON_COMMAND_ID_P (command.commandID)) |
2356 { | 2356 { |
2357 SetWRefCon (window, command.commandID); | 2357 SetWRefCon (window, command.commandID); |
2358 quit_event_loop_p = 1; | 2358 quit_dialog_event_loop = 1; |
2359 break; | 2359 break; |
2360 } | 2360 } |
2361 | 2361 |
2362 result = CallNextEventHandler (next_handler, event); | 2362 result = CallNextEventHandler (next_handler, event); |
2363 } | 2363 } |
2377 NULL, &char_code); | 2377 NULL, &char_code); |
2378 if (err == noErr) | 2378 if (err == noErr) |
2379 switch (char_code) | 2379 switch (char_code) |
2380 { | 2380 { |
2381 case kEscapeCharCode: | 2381 case kEscapeCharCode: |
2382 quit_event_loop_p = 1; | 2382 quit_dialog_event_loop = 1; |
2383 break; | 2383 break; |
2384 | 2384 |
2385 default: | 2385 default: |
2386 { | 2386 { |
2387 UInt32 modifiers, key_code; | 2387 UInt32 modifiers, key_code; |
2393 err = GetEventParameter (event, kEventParamKeyCode, | 2393 err = GetEventParameter (event, kEventParamKeyCode, |
2394 typeUInt32, NULL, sizeof (UInt32), | 2394 typeUInt32, NULL, sizeof (UInt32), |
2395 NULL, &key_code); | 2395 NULL, &key_code); |
2396 if (err == noErr) | 2396 if (err == noErr) |
2397 if (mac_quit_char_key_p (modifiers, key_code)) | 2397 if (mac_quit_char_key_p (modifiers, key_code)) |
2398 quit_event_loop_p = 1; | 2398 quit_dialog_event_loop = 1; |
2399 } | 2399 } |
2400 break; | 2400 break; |
2401 } | 2401 } |
2402 } | 2402 } |
2403 break; | 2403 break; |
2404 | 2404 |
2405 default: | 2405 default: |
2406 abort (); | 2406 abort (); |
2407 } | 2407 } |
2408 | 2408 |
2409 if (quit_event_loop_p) | 2409 if (quit_dialog_event_loop) |
2410 { | 2410 { |
2411 err = QuitEventLoop (GetCurrentEventLoop ()); | 2411 err = QuitEventLoop (GetCurrentEventLoop ()); |
2412 if (err == noErr) | 2412 if (err == noErr) |
2413 result = noErr; | 2413 result = noErr; |
2414 } | 2414 } |
2731 } | 2731 } |
2732 if (err == noErr) | 2732 if (err == noErr) |
2733 { | 2733 { |
2734 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget (); | 2734 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget (); |
2735 | 2735 |
2736 quit_dialog_event_loop = 0; | |
2736 while (1) | 2737 while (1) |
2737 { | 2738 { |
2738 EMACS_TIME next_time = timer_check (1); | 2739 EMACS_TIME next_time = timer_check (1); |
2739 long secs = EMACS_SECS (next_time); | 2740 long secs = EMACS_SECS (next_time); |
2740 long usecs = EMACS_USECS (next_time); | 2741 long usecs = EMACS_USECS (next_time); |
2756 if (err == noErr) | 2757 if (err == noErr) |
2757 { | 2758 { |
2758 SendEventToEventTarget (event, toolbox_dispatcher); | 2759 SendEventToEventTarget (event, toolbox_dispatcher); |
2759 ReleaseEvent (event); | 2760 ReleaseEvent (event); |
2760 } | 2761 } |
2762 #ifdef MAC_OSX | |
2761 else if (err != eventLoopTimedOutErr) | 2763 else if (err != eventLoopTimedOutErr) |
2762 { | 2764 { |
2763 if (err == eventLoopQuitErr) | 2765 if (err == eventLoopQuitErr) |
2764 err = noErr; | 2766 err = noErr; |
2765 break; | 2767 break; |
2766 } | 2768 } |
2769 #else | |
2770 /* The return value of ReceiveNextEvent seems to be | |
2771 unreliable. Use our own global variable instead. */ | |
2772 if (quit_dialog_event_loop) | |
2773 { | |
2774 err = noErr; | |
2775 break; | |
2776 } | |
2777 #endif | |
2767 } | 2778 } |
2768 } | 2779 } |
2769 if (err == noErr) | 2780 if (err == noErr) |
2770 { | 2781 { |
2771 UInt32 command_id = GetWRefCon (window); | 2782 UInt32 command_id = GetWRefCon (window); |