diff options
| author | Karoly Lorentey | 2005-12-11 22:42:40 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2005-12-11 22:42:40 +0000 |
| commit | be3d2d66d2dff979604134c5dc5fb506ded4aa54 (patch) | |
| tree | 683fc7324392d0023e995b593a627c294375aba1 /src | |
| parent | 16986fcfcca94e88e620c38775e15f758aa44935 (diff) | |
| parent | ac8fcf0f17ab5d81f3b30db5599337d000ad12d9 (diff) | |
| download | emacs-be3d2d66d2dff979604134c5dc5fb506ded4aa54.tar.gz emacs-be3d2d66d2dff979604134c5dc5fb506ded4aa54.zip | |
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-667
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-669
Update from CVS
* miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-670
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-157
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-158
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-159
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-160
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-161
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-162
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-163
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-164
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-165
Update from CVS: texi/message.texi: Fix default values.
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-166
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-167
Update from CVS
* miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-168
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-448
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 97 | ||||
| -rw-r--r-- | src/Makefile.in | 2 | ||||
| -rw-r--r-- | src/image.c | 10 | ||||
| -rw-r--r-- | src/indent.c | 12 | ||||
| -rw-r--r-- | src/keyboard.c | 22 | ||||
| -rw-r--r-- | src/lread.c | 11 | ||||
| -rw-r--r-- | src/mac.c | 324 | ||||
| -rw-r--r-- | src/macselect.c | 493 | ||||
| -rw-r--r-- | src/macterm.c | 534 | ||||
| -rw-r--r-- | src/macterm.h | 9 | ||||
| -rw-r--r-- | src/termhooks.h | 18 | ||||
| -rw-r--r-- | src/w32fns.c | 8 |
12 files changed, 1036 insertions, 504 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 4fa4093631f..4994e7e8d6a 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,100 @@ | |||
| 1 | 2005-12-11 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * emacs.c (main) [MAC_OS8]: Undo previous change. | ||
| 4 | |||
| 5 | * macselect.c (syms_of_macselect) <mac-apple-event-map>: | ||
| 6 | Initialize to nil. Keymap is now created in lisp/term/mac-win.el. | ||
| 7 | |||
| 8 | 2005-12-10 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 9 | |||
| 10 | * Makefile.in (macselect.o): Depend on keymap.h. | ||
| 11 | |||
| 12 | * emacs.c (main) [MAC_OS8]: Call syms_of_keymap before | ||
| 13 | syms_of_macselect. | ||
| 14 | |||
| 15 | * image.c (init_image) [MAC_OS]: Don't call EnterMovies. | ||
| 16 | [!HAVE_GIF && MAC_OS] (gif_load): Call EnterMovies. | ||
| 17 | |||
| 18 | * keyboard.c (Qmac_apple_event) [MAC_OS]: New variable. | ||
| 19 | (syms_of_keyboard) [MAC_OS]: Initialize it. | ||
| 20 | (make_lispy_event) [MAC_OS]: Build lisp event for MAC_APPLE_EVENT. | ||
| 21 | |||
| 22 | * mac.c (Qundecoded_file_name): New variable. | ||
| 23 | (syms_of_mac): Initialize it. | ||
| 24 | (mac_aelist_to_lisp, mac_aedesc_to_lisp): New functions. | ||
| 25 | [TARGET_API_MAC_CARBON] (create_apple_event_from_event_ref): New | ||
| 26 | function. | ||
| 27 | (Fmac_coerce_ae_data): New defun. | ||
| 28 | (syms_of_mac): Defsubr it. | ||
| 29 | |||
| 30 | * macselect.c: Include keymap.h. | ||
| 31 | (mac_ready_for_apple_events): New variable. | ||
| 32 | (Vmac_apple_event_map, Qmac_apple_event_class) | ||
| 33 | (Qmac_apple_event_id): New variables. | ||
| 34 | (syms_of_macselect): Initialize them. | ||
| 35 | (Qundefined, mac_store_apple_event): Add externs. | ||
| 36 | (struct apple_event_binding): New struct. | ||
| 37 | (find_event_binding_fun, find_event_binding) | ||
| 38 | (mac_find_apple_event_spec, defer_apple_events) | ||
| 39 | (mac_handle_apple_event, init_apple_event_handler) | ||
| 40 | (copy_scrap_flavor_data): New functions. | ||
| 41 | (Fmac_process_deferred_apple_events): New defun. | ||
| 42 | (syms_of_macselect): Defsubr it. | ||
| 43 | (mac_store_services_event): Fix extern. | ||
| 44 | (mac_handle_service_event): Don't allocate Lisp objects during | ||
| 45 | asynchronous input processing. Use mac_store_services_event | ||
| 46 | instead of mac_store_application_menu_event. | ||
| 47 | |||
| 48 | * macterm.c (Qmac_ready_for_drag_n_drop, Qapplication, Qabout) | ||
| 49 | (Qpreferences): Remove variables. | ||
| 50 | (syms_of_macterm) : Don't initialize them. | ||
| 51 | (Qhicommand) [USE_CARBON_EVENTS]: New variable. | ||
| 52 | (syms_of_macterm) [USE_CARBON_EVENTS]: Initialize it. | ||
| 53 | (init_required_apple_events, do_ae_open_application) | ||
| 54 | (do_ae_print_documents, do_ae_open_documents) | ||
| 55 | (do_ae_quit_application): Remove functions and prototypes. | ||
| 56 | (mac_ready_for_apple_events, Qundefined, init_apple_event_handler) | ||
| 57 | (mac_find_apple_event_spec): Add externs. | ||
| 58 | (mac_store_application_menu_event): Remove function. | ||
| 59 | (mac_store_apple_event, mac_make_lispy_event_code): New functions. | ||
| 60 | (mac_handle_command_event): Create Apple event from Carbon event. | ||
| 61 | Use mac_store_apple_event instead of mac_store_application_menu_event. | ||
| 62 | [MAC_OSX] (mac_store_services_event): Likewise. | ||
| 63 | (struct SelectionRange, SelectionRange): Remove struct and typedef. | ||
| 64 | [MAC_OS8] (main): Call init_apple_event_handler instead of | ||
| 65 | init_required_apple_events. | ||
| 66 | (mac_initialize) [MAC_OSX]: Likewise. | ||
| 67 | [!USE_CARBON_EVENTS] (mac_wait_next_event): Use | ||
| 68 | mac_ready_for_apple_events instead of Qmac_ready_for_drag_n_drop. | ||
| 69 | |||
| 70 | * macterm.h (mac_make_lispy_event_code, mac_aedesc_to_lisp): Add | ||
| 71 | externs. | ||
| 72 | (create_apple_event_from_event_ref) [TARGET_API_MAC_CARBON]: Likewise. | ||
| 73 | (Fmac_get_preference): Add EXFUN. | ||
| 74 | |||
| 75 | * termhooks.h (enum event_kind) [MAC_OS]: Add new MAC_APPLE_EVENT | ||
| 76 | event. | ||
| 77 | |||
| 78 | 2005-12-09 Richard M. Stallman <rms@gnu.org> | ||
| 79 | |||
| 80 | * xfns.c (Fx_create_frame): Reinstate previous change. | ||
| 81 | |||
| 82 | 2005-12-09 Eli Zaretskii <eliz@gnu.org> | ||
| 83 | |||
| 84 | * w32fns.c (w32_abort) [__GNUC__]: Add instructions for attaching | ||
| 85 | GDB to the abort dialog. | ||
| 86 | |||
| 87 | 2005-12-09 Kyotaro HORIGUCHI <horiguti@meadowy.org> (tiny change) | ||
| 88 | |||
| 89 | * indent.c (Fvertical_motion): Force move if starting on | ||
| 90 | stretch glyph. | ||
| 91 | |||
| 92 | 2005-12-08 Richard M. Stallman <rms@gnu.org> | ||
| 93 | |||
| 94 | * lread.c (read_escape) <\s>: Don't treat strings specially. | ||
| 95 | |||
| 96 | * xfns.c (Fx_create_frame): Comment out previous change. | ||
| 97 | |||
| 1 | 2005-12-07 L$,1 q(Brentey K,Aa(Broly <lorentey@elte.hu> | 98 | 2005-12-07 L$,1 q(Brentey K,Aa(Broly <lorentey@elte.hu> |
| 2 | 99 | ||
| 3 | * xfns.c (Fx_create_frame): Initialize Vdefault_minibuffer_frame, | 100 | * xfns.c (Fx_create_frame): Initialize Vdefault_minibuffer_frame, |
diff --git a/src/Makefile.in b/src/Makefile.in index 7c9203d11ff..2799b3ff46b 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -1261,7 +1261,7 @@ macterm.o: blockinput.h atimer.h systime.h syssignal.h macterm.h macgui.h \ | |||
| 1261 | frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h termopts.h \ | 1261 | frame.h charset.h ccl.h dispextern.h fontset.h termhooks.h termopts.h \ |
| 1262 | termchar.h gnu.h disptab.h buffer.h window.h keyboard.h $(INTERVAL_SRC) \ | 1262 | termchar.h gnu.h disptab.h buffer.h window.h keyboard.h $(INTERVAL_SRC) \ |
| 1263 | process.h coding.h $(config_h) | 1263 | process.h coding.h $(config_h) |
| 1264 | macselect.o: blockinput.h macterm.h macgui.h frame.h $(config_h) | 1264 | macselect.o: blockinput.h macterm.h macgui.h frame.h keymap.h $(config_h) |
| 1265 | 1265 | ||
| 1266 | ${emacsapp}Contents/Resources/English.lproj: | 1266 | ${emacsapp}Contents/Resources/English.lproj: |
| 1267 | mkdir -p $@ | 1267 | mkdir -p $@ |
diff --git a/src/image.c b/src/image.c index d020b2ac394..8a6d40ae34f 100644 --- a/src/image.c +++ b/src/image.c | |||
| @@ -7778,6 +7778,9 @@ gif_load (f, img) | |||
| 7778 | specified_file = image_spec_value (img->spec, QCfile, NULL); | 7778 | specified_file = image_spec_value (img->spec, QCfile, NULL); |
| 7779 | specified_data = image_spec_value (img->spec, QCdata, NULL); | 7779 | specified_data = image_spec_value (img->spec, QCdata, NULL); |
| 7780 | 7780 | ||
| 7781 | /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ | ||
| 7782 | EnterMovies (); | ||
| 7783 | |||
| 7781 | if (NILP (specified_data)) | 7784 | if (NILP (specified_data)) |
| 7782 | { | 7785 | { |
| 7783 | /* Read from a file */ | 7786 | /* Read from a file */ |
| @@ -8500,14 +8503,9 @@ meaning don't clear the cache. */); | |||
| 8500 | void | 8503 | void |
| 8501 | init_image () | 8504 | init_image () |
| 8502 | { | 8505 | { |
| 8503 | #ifdef MAC_OS | 8506 | #if defined (MAC_OSX) && TARGET_API_MAC_CARBON |
| 8504 | /* Animated gifs use QuickTime Movie Toolbox. So initialize it here. */ | ||
| 8505 | if (!inhibit_window_system) | ||
| 8506 | EnterMovies (); | ||
| 8507 | #ifdef MAC_OSX | ||
| 8508 | init_image_func_pointer (); | 8507 | init_image_func_pointer (); |
| 8509 | #endif | 8508 | #endif |
| 8510 | #endif | ||
| 8511 | } | 8509 | } |
| 8512 | 8510 | ||
| 8513 | /* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 | 8511 | /* arch-tag: 123c2a5e-14a8-4c53-ab95-af47d7db49b9 |
diff --git a/src/indent.c b/src/indent.c index 68544e8059d..6ca15c67345 100644 --- a/src/indent.c +++ b/src/indent.c | |||
| @@ -2076,7 +2076,7 @@ whether or not it is currently displayed in some window. */) | |||
| 2076 | { | 2076 | { |
| 2077 | int it_start; | 2077 | int it_start; |
| 2078 | int oselective; | 2078 | int oselective; |
| 2079 | int start_on_image_p; | 2079 | int start_on_image_or_stretch_p; |
| 2080 | 2080 | ||
| 2081 | SET_TEXT_POS (pt, PT, PT_BYTE); | 2081 | SET_TEXT_POS (pt, PT, PT_BYTE); |
| 2082 | start_display (&it, w, pt); | 2082 | start_display (&it, w, pt); |
| @@ -2088,7 +2088,8 @@ whether or not it is currently displayed in some window. */) | |||
| 2088 | while the end position is really at some X > 0, the same X that | 2088 | while the end position is really at some X > 0, the same X that |
| 2089 | PT had. */ | 2089 | PT had. */ |
| 2090 | it_start = IT_CHARPOS (it); | 2090 | it_start = IT_CHARPOS (it); |
| 2091 | start_on_image_p = (it.method == GET_FROM_IMAGE); | 2091 | start_on_image_or_stretch_p = (it.method == GET_FROM_IMAGE |
| 2092 | || it.method == GET_FROM_STRETCH); | ||
| 2092 | reseat_at_previous_visible_line_start (&it); | 2093 | reseat_at_previous_visible_line_start (&it); |
| 2093 | it.current_x = it.hpos = 0; | 2094 | it.current_x = it.hpos = 0; |
| 2094 | /* Temporarily disable selective display so we don't move too far */ | 2095 | /* Temporarily disable selective display so we don't move too far */ |
| @@ -2099,9 +2100,10 @@ whether or not it is currently displayed in some window. */) | |||
| 2099 | 2100 | ||
| 2100 | /* Move back if we got too far. This may happen if | 2101 | /* Move back if we got too far. This may happen if |
| 2101 | truncate-lines is on and PT is beyond right margin. | 2102 | truncate-lines is on and PT is beyond right margin. |
| 2102 | It may also happen if it_start is on an image -- | 2103 | It may also happen if it_start is on an image or a stretch |
| 2103 | in that case, don't go back. */ | 2104 | glyph -- in that case, don't go back. */ |
| 2104 | if (IT_CHARPOS (it) > it_start && XINT (lines) > 0 && !start_on_image_p) | 2105 | if (IT_CHARPOS (it) > it_start && XINT (lines) > 0 |
| 2106 | && !start_on_image_or_stretch_p) | ||
| 2105 | move_it_by_lines (&it, -1, 0); | 2107 | move_it_by_lines (&it, -1, 0); |
| 2106 | 2108 | ||
| 2107 | it.vpos = 0; | 2109 | it.vpos = 0; |
diff --git a/src/keyboard.c b/src/keyboard.c index 7a918608dd7..51b59432214 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -514,6 +514,9 @@ Lisp_Object Qlanguage_change; | |||
| 514 | #endif | 514 | #endif |
| 515 | Lisp_Object Qdrag_n_drop; | 515 | Lisp_Object Qdrag_n_drop; |
| 516 | Lisp_Object Qsave_session; | 516 | Lisp_Object Qsave_session; |
| 517 | #ifdef MAC_OS | ||
| 518 | Lisp_Object Qmac_apple_event; | ||
| 519 | #endif | ||
| 517 | 520 | ||
| 518 | /* Lisp_Object Qmouse_movement; - also an event header */ | 521 | /* Lisp_Object Qmouse_movement; - also an event header */ |
| 519 | 522 | ||
| @@ -5915,6 +5918,20 @@ make_lispy_event (event) | |||
| 5915 | case SAVE_SESSION_EVENT: | 5918 | case SAVE_SESSION_EVENT: |
| 5916 | return Qsave_session; | 5919 | return Qsave_session; |
| 5917 | 5920 | ||
| 5921 | #ifdef MAC_OS | ||
| 5922 | case MAC_APPLE_EVENT: | ||
| 5923 | { | ||
| 5924 | Lisp_Object spec[2]; | ||
| 5925 | |||
| 5926 | spec[0] = event->x; | ||
| 5927 | spec[1] = event->y; | ||
| 5928 | return Fcons (Qmac_apple_event, | ||
| 5929 | Fcons (Fvector (2, spec), | ||
| 5930 | Fcons (mac_make_lispy_event_code (event->code), | ||
| 5931 | Qnil))); | ||
| 5932 | } | ||
| 5933 | #endif | ||
| 5934 | |||
| 5918 | /* The 'kind' field of the event is something we don't recognize. */ | 5935 | /* The 'kind' field of the event is something we don't recognize. */ |
| 5919 | default: | 5936 | default: |
| 5920 | abort (); | 5937 | abort (); |
| @@ -11074,6 +11091,11 @@ syms_of_keyboard () | |||
| 11074 | Qsave_session = intern ("save-session"); | 11091 | Qsave_session = intern ("save-session"); |
| 11075 | staticpro (&Qsave_session); | 11092 | staticpro (&Qsave_session); |
| 11076 | 11093 | ||
| 11094 | #ifdef MAC_OS | ||
| 11095 | Qmac_apple_event = intern ("mac-apple-event"); | ||
| 11096 | staticpro (&Qmac_apple_event); | ||
| 11097 | #endif | ||
| 11098 | |||
| 11077 | Qusr1_signal = intern ("usr1-signal"); | 11099 | Qusr1_signal = intern ("usr1-signal"); |
| 11078 | staticpro (&Qusr1_signal); | 11100 | staticpro (&Qusr1_signal); |
| 11079 | Qusr2_signal = intern ("usr2-signal"); | 11101 | Qusr2_signal = intern ("usr2-signal"); |
diff --git a/src/lread.c b/src/lread.c index 234fbe6e395..e6f1987a50b 100644 --- a/src/lread.c +++ b/src/lread.c | |||
| @@ -1739,13 +1739,12 @@ read_escape (readcharfun, stringp, byterep) | |||
| 1739 | return c | alt_modifier; | 1739 | return c | alt_modifier; |
| 1740 | 1740 | ||
| 1741 | case 's': | 1741 | case 's': |
| 1742 | if (stringp) | ||
| 1743 | return ' '; | ||
| 1744 | c = READCHAR; | 1742 | c = READCHAR; |
| 1745 | if (c != '-') { | 1743 | if (c != '-') |
| 1746 | UNREAD (c); | 1744 | { |
| 1747 | return ' '; | 1745 | UNREAD (c); |
| 1748 | } | 1746 | return ' '; |
| 1747 | } | ||
| 1749 | c = READCHAR; | 1748 | c = READCHAR; |
| 1750 | if (c == '\\') | 1749 | if (c == '\\') |
| 1751 | c = read_escape (readcharfun, 0, byterep); | 1750 | c = read_escape (readcharfun, 0, byterep); |
| @@ -259,6 +259,216 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen) | |||
| 259 | 259 | ||
| 260 | 260 | ||
| 261 | /*********************************************************************** | 261 | /*********************************************************************** |
| 262 | Conversions on Apple event objects | ||
| 263 | ***********************************************************************/ | ||
| 264 | |||
| 265 | static Lisp_Object Qundecoded_file_name; | ||
| 266 | |||
| 267 | static Lisp_Object | ||
| 268 | mac_aelist_to_lisp (desc_list) | ||
| 269 | AEDescList *desc_list; | ||
| 270 | { | ||
| 271 | OSErr err; | ||
| 272 | long count; | ||
| 273 | Lisp_Object result, elem; | ||
| 274 | DescType desc_type; | ||
| 275 | Size size; | ||
| 276 | AEKeyword keyword; | ||
| 277 | AEDesc desc; | ||
| 278 | |||
| 279 | err = AECountItems (desc_list, &count); | ||
| 280 | if (err != noErr) | ||
| 281 | return Qnil; | ||
| 282 | result = Qnil; | ||
| 283 | while (count > 0) | ||
| 284 | { | ||
| 285 | err = AESizeOfNthItem (desc_list, count, &desc_type, &size); | ||
| 286 | if (err == noErr) | ||
| 287 | switch (desc_type) | ||
| 288 | { | ||
| 289 | case typeAEList: | ||
| 290 | case typeAERecord: | ||
| 291 | case typeAppleEvent: | ||
| 292 | err = AEGetNthDesc (desc_list, count, typeWildCard, | ||
| 293 | &keyword, &desc); | ||
| 294 | if (err != noErr) | ||
| 295 | break; | ||
| 296 | elem = mac_aelist_to_lisp (&desc); | ||
| 297 | AEDisposeDesc (&desc); | ||
| 298 | break; | ||
| 299 | |||
| 300 | default: | ||
| 301 | if (desc_type == typeNull) | ||
| 302 | elem = Qnil; | ||
| 303 | else | ||
| 304 | { | ||
| 305 | elem = make_uninit_string (size); | ||
| 306 | err = AEGetNthPtr (desc_list, count, typeWildCard, &keyword, | ||
| 307 | &desc_type, SDATA (elem), size, &size); | ||
| 308 | } | ||
| 309 | if (err != noErr) | ||
| 310 | break; | ||
| 311 | desc_type = EndianU32_NtoB (desc_type); | ||
| 312 | elem = Fcons (make_unibyte_string ((char *) &desc_type, 4), elem); | ||
| 313 | break; | ||
| 314 | } | ||
| 315 | |||
| 316 | if (err != noErr) | ||
| 317 | elem = Qnil; | ||
| 318 | else if (desc_list->descriptorType != typeAEList) | ||
| 319 | { | ||
| 320 | keyword = EndianU32_NtoB (keyword); | ||
| 321 | elem = Fcons (make_unibyte_string ((char *) &keyword, 4), elem); | ||
| 322 | } | ||
| 323 | |||
| 324 | result = Fcons (elem, result); | ||
| 325 | count--; | ||
| 326 | } | ||
| 327 | |||
| 328 | desc_type = EndianU32_NtoB (desc_list->descriptorType); | ||
| 329 | return Fcons (make_unibyte_string ((char *) &desc_type, 4), result); | ||
| 330 | } | ||
| 331 | |||
| 332 | Lisp_Object | ||
| 333 | mac_aedesc_to_lisp (desc) | ||
| 334 | AEDesc *desc; | ||
| 335 | { | ||
| 336 | OSErr err; | ||
| 337 | DescType desc_type = desc->descriptorType; | ||
| 338 | Lisp_Object result; | ||
| 339 | |||
| 340 | switch (desc_type) | ||
| 341 | { | ||
| 342 | case typeNull: | ||
| 343 | result = Qnil; | ||
| 344 | break; | ||
| 345 | |||
| 346 | case typeAEList: | ||
| 347 | case typeAERecord: | ||
| 348 | case typeAppleEvent: | ||
| 349 | return mac_aelist_to_lisp (desc); | ||
| 350 | #if 0 | ||
| 351 | /* The following one is much simpler, but creates and disposes | ||
| 352 | of Apple event descriptors many times. */ | ||
| 353 | { | ||
| 354 | long count; | ||
| 355 | Lisp_Object elem; | ||
| 356 | AEKeyword keyword; | ||
| 357 | AEDesc desc1; | ||
| 358 | |||
| 359 | err = AECountItems (desc, &count); | ||
| 360 | if (err != noErr) | ||
| 361 | break; | ||
| 362 | result = Qnil; | ||
| 363 | while (count > 0) | ||
| 364 | { | ||
| 365 | err = AEGetNthDesc (desc, count, typeWildCard, &keyword, &desc1); | ||
| 366 | if (err != noErr) | ||
| 367 | break; | ||
| 368 | elem = mac_aedesc_to_lisp (&desc1); | ||
| 369 | AEDisposeDesc (&desc1); | ||
| 370 | if (desc_type != typeAEList) | ||
| 371 | { | ||
| 372 | keyword = EndianU32_NtoB (keyword); | ||
| 373 | elem = Fcons (make_unibyte_string ((char *) &keyword, 4), elem); | ||
| 374 | } | ||
| 375 | result = Fcons (elem, result); | ||
| 376 | count--; | ||
| 377 | } | ||
| 378 | } | ||
| 379 | #endif | ||
| 380 | break; | ||
| 381 | |||
| 382 | default: | ||
| 383 | #if TARGET_API_MAC_CARBON | ||
| 384 | result = make_uninit_string (AEGetDescDataSize (desc)); | ||
| 385 | err = AEGetDescData (desc, SDATA (result), SBYTES (result)); | ||
| 386 | #else | ||
| 387 | result = make_uninit_string (GetHandleSize (desc->dataHandle)); | ||
| 388 | memcpy (SDATA (result), *(desc->dataHandle), SBYTES (result)); | ||
| 389 | #endif | ||
| 390 | break; | ||
| 391 | } | ||
| 392 | |||
| 393 | if (err != noErr) | ||
| 394 | return Qnil; | ||
| 395 | |||
| 396 | desc_type = EndianU32_NtoB (desc_type); | ||
| 397 | return Fcons (make_unibyte_string ((char *) &desc_type, 4), result); | ||
| 398 | } | ||
| 399 | |||
| 400 | #if TARGET_API_MAC_CARBON | ||
| 401 | OSErr | ||
| 402 | create_apple_event_from_event_ref (event, num_params, names, | ||
| 403 | types, sizes, result) | ||
| 404 | EventRef event; | ||
| 405 | UInt32 num_params; | ||
| 406 | EventParamName *names; | ||
| 407 | EventParamType *types; | ||
| 408 | UInt32 *sizes; | ||
| 409 | AppleEvent *result; | ||
| 410 | { | ||
| 411 | OSErr err; | ||
| 412 | static const ProcessSerialNumber psn = {0, kCurrentProcess}; | ||
| 413 | AEAddressDesc address_desc; | ||
| 414 | UInt32 i; | ||
| 415 | CFStringRef string; | ||
| 416 | CFDataRef data; | ||
| 417 | char *buf; | ||
| 418 | |||
| 419 | err = AECreateDesc (typeProcessSerialNumber, &psn, | ||
| 420 | sizeof (ProcessSerialNumber), &address_desc); | ||
| 421 | if (err == noErr) | ||
| 422 | { | ||
| 423 | err = AECreateAppleEvent (0, 0, /* Dummy class and ID. */ | ||
| 424 | &address_desc, /* NULL is not allowed | ||
| 425 | on Mac OS Classic. */ | ||
| 426 | kAutoGenerateReturnID, | ||
| 427 | kAnyTransactionID, result); | ||
| 428 | AEDisposeDesc (&address_desc); | ||
| 429 | } | ||
| 430 | if (err != noErr) | ||
| 431 | return err; | ||
| 432 | |||
| 433 | for (i = 0; i < num_params; i++) | ||
| 434 | switch (types[i]) | ||
| 435 | { | ||
| 436 | #ifdef MAC_OSX | ||
| 437 | case typeCFStringRef: | ||
| 438 | err = GetEventParameter (event, names[i], typeCFStringRef, NULL, | ||
| 439 | sizeof (CFStringRef), NULL, &string); | ||
| 440 | if (err != noErr) | ||
| 441 | break; | ||
| 442 | data = CFStringCreateExternalRepresentation (NULL, string, | ||
| 443 | kCFStringEncodingUTF8, | ||
| 444 | '?'); | ||
| 445 | if (data == NULL) | ||
| 446 | break; | ||
| 447 | /* typeUTF8Text is not available on Mac OS X 10.1. */ | ||
| 448 | AEPutParamPtr (result, names[i], 'utf8', | ||
| 449 | CFDataGetBytePtr (data), CFDataGetLength (data)); | ||
| 450 | CFRelease (data); | ||
| 451 | break; | ||
| 452 | #endif | ||
| 453 | |||
| 454 | default: | ||
| 455 | buf = xmalloc (sizes[i]); | ||
| 456 | if (buf == NULL) | ||
| 457 | break; | ||
| 458 | err = GetEventParameter (event, names[i], types[i], NULL, | ||
| 459 | sizes[i], NULL, buf); | ||
| 460 | if (err == noErr) | ||
| 461 | AEPutParamPtr (result, names[i], types[i], buf, sizes[i]); | ||
| 462 | xfree (buf); | ||
| 463 | break; | ||
| 464 | } | ||
| 465 | |||
| 466 | return noErr; | ||
| 467 | } | ||
| 468 | #endif | ||
| 469 | |||
| 470 | |||
| 471 | /*********************************************************************** | ||
| 262 | Conversion between Lisp and Core Foundation objects | 472 | Conversion between Lisp and Core Foundation objects |
| 263 | ***********************************************************************/ | 473 | ***********************************************************************/ |
| 264 | 474 | ||
| @@ -3887,6 +4097,116 @@ DEFUN ("posix-file-name-to-mac", Fposix_file_name_to_mac, | |||
| 3887 | } | 4097 | } |
| 3888 | 4098 | ||
| 3889 | 4099 | ||
| 4100 | DEFUN ("mac-coerce-ae-data", Fmac_coerce_ae_data, Smac_coerce_ae_data, 3, 3, 0, | ||
| 4101 | doc: /* Coerce Apple event data SRC-DATA of type SRC-TYPE to DST-TYPE. | ||
| 4102 | Each type should be a string of length 4 or the symbol | ||
| 4103 | `undecoded-file-name'. */) | ||
| 4104 | (src_type, src_data, dst_type) | ||
| 4105 | Lisp_Object src_type, src_data, dst_type; | ||
| 4106 | { | ||
| 4107 | OSErr err; | ||
| 4108 | Lisp_Object result = Qnil; | ||
| 4109 | DescType src_desc_type, dst_desc_type; | ||
| 4110 | AEDesc dst_desc; | ||
| 4111 | #ifdef MAC_OSX | ||
| 4112 | FSRef fref; | ||
| 4113 | #else | ||
| 4114 | FSSpec fs; | ||
| 4115 | #endif | ||
| 4116 | |||
| 4117 | CHECK_STRING (src_data); | ||
| 4118 | if (EQ (src_type, Qundecoded_file_name)) | ||
| 4119 | { | ||
| 4120 | #ifdef MAC_OSX | ||
| 4121 | src_desc_type = typeFileURL; | ||
| 4122 | #else | ||
| 4123 | src_desc_type = typeFSS; | ||
| 4124 | #endif | ||
| 4125 | } | ||
| 4126 | else | ||
| 4127 | src_desc_type = mac_get_code_from_arg (src_type, 0); | ||
| 4128 | |||
| 4129 | if (EQ (dst_type, Qundecoded_file_name)) | ||
| 4130 | { | ||
| 4131 | #ifdef MAC_OSX | ||
| 4132 | dst_desc_type = typeFSRef; | ||
| 4133 | #else | ||
| 4134 | dst_desc_type = typeFSS; | ||
| 4135 | #endif | ||
| 4136 | } | ||
| 4137 | else | ||
| 4138 | dst_desc_type = mac_get_code_from_arg (dst_type, 0); | ||
| 4139 | |||
| 4140 | BLOCK_INPUT; | ||
| 4141 | if (EQ (src_type, Qundecoded_file_name)) | ||
| 4142 | { | ||
| 4143 | #ifdef MAC_OSX | ||
| 4144 | CFStringRef str; | ||
| 4145 | CFURLRef url = NULL; | ||
| 4146 | CFDataRef data = NULL; | ||
| 4147 | |||
| 4148 | str = cfstring_create_with_utf8_cstring (SDATA (src_data)); | ||
| 4149 | if (str) | ||
| 4150 | { | ||
| 4151 | url = CFURLCreateWithFileSystemPath (NULL, str, | ||
| 4152 | kCFURLPOSIXPathStyle, false); | ||
| 4153 | CFRelease (str); | ||
| 4154 | } | ||
| 4155 | if (url) | ||
| 4156 | { | ||
| 4157 | data = CFURLCreateData (NULL, url, kCFStringEncodingUTF8, true); | ||
| 4158 | CFRelease (url); | ||
| 4159 | } | ||
| 4160 | if (data) | ||
| 4161 | err = AECoercePtr (src_desc_type, CFDataGetBytePtr (data), | ||
| 4162 | CFDataGetLength (data), | ||
| 4163 | dst_desc_type, &dst_desc); | ||
| 4164 | else | ||
| 4165 | err = memFullErr; | ||
| 4166 | #else | ||
| 4167 | err = posix_pathname_to_fsspec (SDATA (src_data), &fs); | ||
| 4168 | if (err == noErr) | ||
| 4169 | AECoercePtr (src_desc_type, &fs, sizeof (FSSpec), | ||
| 4170 | dst_desc_type, &dst_desc); | ||
| 4171 | #endif | ||
| 4172 | } | ||
| 4173 | else | ||
| 4174 | err = AECoercePtr (src_desc_type, SDATA (src_data), SBYTES (src_data), | ||
| 4175 | dst_desc_type, &dst_desc); | ||
| 4176 | |||
| 4177 | if (err == noErr) | ||
| 4178 | { | ||
| 4179 | if (EQ (dst_type, Qundecoded_file_name)) | ||
| 4180 | { | ||
| 4181 | char file_name[MAXPATHLEN]; | ||
| 4182 | |||
| 4183 | #ifdef MAC_OSX | ||
| 4184 | err = AEGetDescData (&dst_desc, &fref, sizeof (FSRef)); | ||
| 4185 | if (err == noErr) | ||
| 4186 | err = FSRefMakePath (&fref, file_name, sizeof (file_name)); | ||
| 4187 | #else | ||
| 4188 | #if TARGET_API_MAC_CARBON | ||
| 4189 | err = AEGetDescData (&dst_desc, &fs, sizeof (FSSpec)); | ||
| 4190 | #else | ||
| 4191 | memcpy (&fs, *(dst_desc.dataHandle), sizeof (FSSpec)); | ||
| 4192 | #endif | ||
| 4193 | if (err == noErr) | ||
| 4194 | err = fsspec_to_posix_pathname (&fs, file_name, | ||
| 4195 | sizeof (file_name) - 1); | ||
| 4196 | #endif | ||
| 4197 | if (err == noErr) | ||
| 4198 | result = make_unibyte_string (file_name, strlen (file_name)); | ||
| 4199 | } | ||
| 4200 | else | ||
| 4201 | result = Fcdr (mac_aedesc_to_lisp (&dst_desc)); | ||
| 4202 | AEDisposeDesc (&dst_desc); | ||
| 4203 | } | ||
| 4204 | UNBLOCK_INPUT; | ||
| 4205 | |||
| 4206 | return result; | ||
| 4207 | } | ||
| 4208 | |||
| 4209 | |||
| 3890 | #if TARGET_API_MAC_CARBON | 4210 | #if TARGET_API_MAC_CARBON |
| 3891 | static Lisp_Object Qxml, Qmime_charset; | 4211 | static Lisp_Object Qxml, Qmime_charset; |
| 3892 | static Lisp_Object QNFD, QNFKD, QNFC, QNFKC, QHFS_plus_D, QHFS_plus_C; | 4212 | static Lisp_Object QNFD, QNFKD, QNFC, QNFKC, QHFS_plus_D, QHFS_plus_C; |
| @@ -4676,6 +4996,9 @@ init_mac_osx_environment () | |||
| 4676 | void | 4996 | void |
| 4677 | syms_of_mac () | 4997 | syms_of_mac () |
| 4678 | { | 4998 | { |
| 4999 | Qundecoded_file_name = intern ("undecoded-file-name"); | ||
| 5000 | staticpro (&Qundecoded_file_name); | ||
| 5001 | |||
| 4679 | #if TARGET_API_MAC_CARBON | 5002 | #if TARGET_API_MAC_CARBON |
| 4680 | Qstring = intern ("string"); staticpro (&Qstring); | 5003 | Qstring = intern ("string"); staticpro (&Qstring); |
| 4681 | Qnumber = intern ("number"); staticpro (&Qnumber); | 5004 | Qnumber = intern ("number"); staticpro (&Qnumber); |
| @@ -4699,6 +5022,7 @@ syms_of_mac () | |||
| 4699 | QHFS_plus_C = intern ("HFS+C"); staticpro (&QHFS_plus_C); | 5022 | QHFS_plus_C = intern ("HFS+C"); staticpro (&QHFS_plus_C); |
| 4700 | #endif | 5023 | #endif |
| 4701 | 5024 | ||
| 5025 | defsubr (&Smac_coerce_ae_data); | ||
| 4702 | #if TARGET_API_MAC_CARBON | 5026 | #if TARGET_API_MAC_CARBON |
| 4703 | defsubr (&Smac_get_preference); | 5027 | defsubr (&Smac_get_preference); |
| 4704 | defsubr (&Smac_code_convert_string); | 5028 | defsubr (&Smac_code_convert_string); |
diff --git a/src/macselect.c b/src/macselect.c index 63221ba3a90..066892adce0 100644 --- a/src/macselect.c +++ b/src/macselect.c | |||
| @@ -23,6 +23,7 @@ Boston, MA 02110-1301, USA. */ | |||
| 23 | #include "lisp.h" | 23 | #include "lisp.h" |
| 24 | #include "macterm.h" | 24 | #include "macterm.h" |
| 25 | #include "blockinput.h" | 25 | #include "blockinput.h" |
| 26 | #include "keymap.h" | ||
| 26 | 27 | ||
| 27 | #if !TARGET_API_MAC_CARBON | 28 | #if !TARGET_API_MAC_CARBON |
| 28 | #include <Endian.h> | 29 | #include <Endian.h> |
| @@ -908,6 +909,253 @@ and t is the same as `SECONDARY'. */) | |||
| 908 | } | 909 | } |
| 909 | 910 | ||
| 910 | 911 | ||
| 912 | int mac_ready_for_apple_events = 0; | ||
| 913 | static Lisp_Object Vmac_apple_event_map; | ||
| 914 | static Lisp_Object Qmac_apple_event_class, Qmac_apple_event_id; | ||
| 915 | static struct | ||
| 916 | { | ||
| 917 | AppleEvent *buf; | ||
| 918 | int size, count; | ||
| 919 | } deferred_apple_events; | ||
| 920 | extern Lisp_Object Qundefined; | ||
| 921 | extern OSErr mac_store_apple_event P_ ((Lisp_Object, Lisp_Object, | ||
| 922 | const AEDesc *)); | ||
| 923 | |||
| 924 | struct apple_event_binding | ||
| 925 | { | ||
| 926 | UInt32 code; /* Apple event class or ID. */ | ||
| 927 | Lisp_Object key, binding; | ||
| 928 | }; | ||
| 929 | |||
| 930 | static void | ||
| 931 | find_event_binding_fun (key, binding, args, data) | ||
| 932 | Lisp_Object key, binding, args; | ||
| 933 | void *data; | ||
| 934 | { | ||
| 935 | struct apple_event_binding *event_binding = | ||
| 936 | (struct apple_event_binding *)data; | ||
| 937 | Lisp_Object code_string; | ||
| 938 | |||
| 939 | if (!SYMBOLP (key)) | ||
| 940 | return; | ||
| 941 | code_string = Fget (key, args); | ||
| 942 | if (STRINGP (code_string) && SBYTES (code_string) == 4 | ||
| 943 | && (EndianU32_BtoN (*((UInt32 *) SDATA (code_string))) | ||
| 944 | == event_binding->code)) | ||
| 945 | { | ||
| 946 | event_binding->key = key; | ||
| 947 | event_binding->binding = binding; | ||
| 948 | } | ||
| 949 | } | ||
| 950 | |||
| 951 | static void | ||
| 952 | find_event_binding (keymap, event_binding, class_p) | ||
| 953 | Lisp_Object keymap; | ||
| 954 | struct apple_event_binding *event_binding; | ||
| 955 | int class_p; | ||
| 956 | { | ||
| 957 | if (event_binding->code == 0) | ||
| 958 | event_binding->binding = | ||
| 959 | access_keymap (keymap, event_binding->key, 0, 1, 0); | ||
| 960 | else | ||
| 961 | { | ||
| 962 | event_binding->binding = Qnil; | ||
| 963 | map_keymap (keymap, find_event_binding_fun, | ||
| 964 | class_p ? Qmac_apple_event_class : Qmac_apple_event_id, | ||
| 965 | event_binding, 0); | ||
| 966 | } | ||
| 967 | } | ||
| 968 | |||
| 969 | void | ||
| 970 | mac_find_apple_event_spec (class, id, class_key, id_key, binding) | ||
| 971 | AEEventClass class; | ||
| 972 | AEEventID id; | ||
| 973 | Lisp_Object *class_key, *id_key, *binding; | ||
| 974 | { | ||
| 975 | struct apple_event_binding event_binding; | ||
| 976 | Lisp_Object keymap; | ||
| 977 | |||
| 978 | *binding = Qnil; | ||
| 979 | |||
| 980 | keymap = get_keymap (Vmac_apple_event_map, 0, 0); | ||
| 981 | if (NILP (keymap)) | ||
| 982 | return; | ||
| 983 | |||
| 984 | event_binding.code = class; | ||
| 985 | event_binding.key = *class_key; | ||
| 986 | event_binding.binding = Qnil; | ||
| 987 | find_event_binding (keymap, &event_binding, 1); | ||
| 988 | *class_key = event_binding.key; | ||
| 989 | keymap = get_keymap (event_binding.binding, 0, 0); | ||
| 990 | if (NILP (keymap)) | ||
| 991 | return; | ||
| 992 | |||
| 993 | event_binding.code = id; | ||
| 994 | event_binding.key = *id_key; | ||
| 995 | event_binding.binding = Qnil; | ||
| 996 | find_event_binding (keymap, &event_binding, 0); | ||
| 997 | *id_key = event_binding.key; | ||
| 998 | *binding = event_binding.binding; | ||
| 999 | } | ||
| 1000 | |||
| 1001 | static OSErr | ||
| 1002 | defer_apple_events (apple_event, reply) | ||
| 1003 | const AppleEvent *apple_event, *reply; | ||
| 1004 | { | ||
| 1005 | OSErr err; | ||
| 1006 | |||
| 1007 | err = AESuspendTheCurrentEvent (apple_event); | ||
| 1008 | |||
| 1009 | /* Mac OS 10.3 Xcode manual says AESuspendTheCurrentEvent makes | ||
| 1010 | copies of the Apple event and the reply, but Mac OS 10.4 Xcode | ||
| 1011 | manual says it doesn't. Anyway we create copies of them and save | ||
| 1012 | it in `deferred_apple_events'. */ | ||
| 1013 | if (err == noErr) | ||
| 1014 | { | ||
| 1015 | if (deferred_apple_events.buf == NULL) | ||
| 1016 | { | ||
| 1017 | deferred_apple_events.size = 16; | ||
| 1018 | deferred_apple_events.count = 0; | ||
| 1019 | deferred_apple_events.buf = | ||
| 1020 | xmalloc (sizeof (AppleEvent) * deferred_apple_events.size); | ||
| 1021 | if (deferred_apple_events.buf == NULL) | ||
| 1022 | err = memFullErr; | ||
| 1023 | } | ||
| 1024 | else if (deferred_apple_events.count == deferred_apple_events.size) | ||
| 1025 | { | ||
| 1026 | AppleEvent *newbuf; | ||
| 1027 | |||
| 1028 | deferred_apple_events.size *= 2; | ||
| 1029 | newbuf = xrealloc (deferred_apple_events.buf, | ||
| 1030 | sizeof (AppleEvent) * deferred_apple_events.size); | ||
| 1031 | if (newbuf) | ||
| 1032 | deferred_apple_events.buf = newbuf; | ||
| 1033 | else | ||
| 1034 | err = memFullErr; | ||
| 1035 | } | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | if (err == noErr) | ||
| 1039 | { | ||
| 1040 | int count = deferred_apple_events.count; | ||
| 1041 | |||
| 1042 | AEDuplicateDesc (apple_event, deferred_apple_events.buf + count); | ||
| 1043 | AEDuplicateDesc (reply, deferred_apple_events.buf + count + 1); | ||
| 1044 | deferred_apple_events.count += 2; | ||
| 1045 | } | ||
| 1046 | |||
| 1047 | return err; | ||
| 1048 | } | ||
| 1049 | |||
| 1050 | static pascal OSErr | ||
| 1051 | mac_handle_apple_event (apple_event, reply, refcon) | ||
| 1052 | const AppleEvent *apple_event; | ||
| 1053 | AppleEvent *reply; | ||
| 1054 | SInt32 refcon; | ||
| 1055 | { | ||
| 1056 | OSErr err; | ||
| 1057 | AEEventClass event_class; | ||
| 1058 | AEEventID event_id; | ||
| 1059 | Lisp_Object class_key, id_key, binding; | ||
| 1060 | |||
| 1061 | /* We can't handle an Apple event that requests a reply, but this | ||
| 1062 | seems to be too restrictive. */ | ||
| 1063 | #if 0 | ||
| 1064 | if (reply->descriptorType != typeNull) | ||
| 1065 | return errAEEventNotHandled; | ||
| 1066 | #endif | ||
| 1067 | |||
| 1068 | if (!mac_ready_for_apple_events) | ||
| 1069 | { | ||
| 1070 | err = defer_apple_events (apple_event, reply); | ||
| 1071 | if (err != noErr) | ||
| 1072 | return errAEEventNotHandled; | ||
| 1073 | return noErr; | ||
| 1074 | } | ||
| 1075 | |||
| 1076 | err = AEGetAttributePtr (apple_event, keyEventClassAttr, typeType, NULL, | ||
| 1077 | &event_class, sizeof (AEEventClass), NULL); | ||
| 1078 | if (err == noErr) | ||
| 1079 | err = AEGetAttributePtr (apple_event, keyEventIDAttr, typeType, NULL, | ||
| 1080 | &event_id, sizeof (AEEventID), NULL); | ||
| 1081 | if (err == noErr) | ||
| 1082 | { | ||
| 1083 | mac_find_apple_event_spec (event_class, event_id, | ||
| 1084 | &class_key, &id_key, &binding); | ||
| 1085 | if (!NILP (binding) && !EQ (binding, Qundefined)) | ||
| 1086 | { | ||
| 1087 | if (INTEGERP (binding)) | ||
| 1088 | return XINT (binding); | ||
| 1089 | err = mac_store_apple_event (class_key, id_key, apple_event); | ||
| 1090 | if (err == noErr) | ||
| 1091 | return noErr; | ||
| 1092 | } | ||
| 1093 | } | ||
| 1094 | return errAEEventNotHandled; | ||
| 1095 | } | ||
| 1096 | |||
| 1097 | void | ||
| 1098 | init_apple_event_handler () | ||
| 1099 | { | ||
| 1100 | OSErr err; | ||
| 1101 | long result; | ||
| 1102 | |||
| 1103 | /* Make sure we have Apple events before starting. */ | ||
| 1104 | err = Gestalt (gestaltAppleEventsAttr, &result); | ||
| 1105 | if (err != noErr) | ||
| 1106 | abort (); | ||
| 1107 | |||
| 1108 | if (!(result & (1 << gestaltAppleEventsPresent))) | ||
| 1109 | abort (); | ||
| 1110 | |||
| 1111 | err = AEInstallEventHandler (typeWildCard, typeWildCard, | ||
| 1112 | #if TARGET_API_MAC_CARBON | ||
| 1113 | NewAEEventHandlerUPP (mac_handle_apple_event), | ||
| 1114 | #else | ||
| 1115 | NewAEEventHandlerProc (mac_handle_apple_event), | ||
| 1116 | #endif | ||
| 1117 | 0L, false); | ||
| 1118 | if (err != noErr) | ||
| 1119 | abort (); | ||
| 1120 | } | ||
| 1121 | |||
| 1122 | DEFUN ("mac-process-deferred-apple-events", Fmac_process_deferred_apple_events, Smac_process_deferred_apple_events, 0, 0, 0, | ||
| 1123 | doc: /* Process Apple events that are deferred at the startup time. */) | ||
| 1124 | () | ||
| 1125 | { | ||
| 1126 | OSErr err; | ||
| 1127 | Lisp_Object result = Qnil; | ||
| 1128 | long i, count; | ||
| 1129 | AppleEvent apple_event, reply; | ||
| 1130 | AEKeyword keyword; | ||
| 1131 | |||
| 1132 | if (mac_ready_for_apple_events) | ||
| 1133 | return Qnil; | ||
| 1134 | |||
| 1135 | BLOCK_INPUT; | ||
| 1136 | mac_ready_for_apple_events = 1; | ||
| 1137 | if (deferred_apple_events.buf) | ||
| 1138 | { | ||
| 1139 | for (i = 0; i < deferred_apple_events.count; i += 2) | ||
| 1140 | { | ||
| 1141 | AEResumeTheCurrentEvent (deferred_apple_events.buf + i, | ||
| 1142 | deferred_apple_events.buf + i + 1, | ||
| 1143 | ((AEEventHandlerUPP) | ||
| 1144 | kAEUseStandardDispatch), 0); | ||
| 1145 | AEDisposeDesc (deferred_apple_events.buf + i); | ||
| 1146 | AEDisposeDesc (deferred_apple_events.buf + i + 1); | ||
| 1147 | } | ||
| 1148 | xfree (deferred_apple_events.buf); | ||
| 1149 | bzero (&deferred_apple_events, sizeof (deferred_apple_events)); | ||
| 1150 | |||
| 1151 | result = Qt; | ||
| 1152 | } | ||
| 1153 | UNBLOCK_INPUT; | ||
| 1154 | |||
| 1155 | return result; | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | |||
| 911 | #ifdef MAC_OSX | 1159 | #ifdef MAC_OSX |
| 912 | void | 1160 | void |
| 913 | init_service_handler () | 1161 | init_service_handler () |
| @@ -920,7 +1168,56 @@ init_service_handler () | |||
| 920 | GetEventTypeCount (specs), specs, NULL, NULL); | 1168 | GetEventTypeCount (specs), specs, NULL, NULL); |
| 921 | } | 1169 | } |
| 922 | 1170 | ||
| 923 | extern void mac_store_services_event P_ ((EventRef)); | 1171 | extern OSErr mac_store_services_event P_ ((EventRef)); |
| 1172 | |||
| 1173 | static OSStatus | ||
| 1174 | copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type) | ||
| 1175 | ScrapRef from_scrap, to_scrap; | ||
| 1176 | ScrapFlavorType flavor_type; | ||
| 1177 | { | ||
| 1178 | OSStatus err; | ||
| 1179 | Size size, size_allocated; | ||
| 1180 | char *buf = NULL; | ||
| 1181 | |||
| 1182 | err = GetScrapFlavorSize (from_scrap, flavor_type, &size); | ||
| 1183 | if (err == noErr) | ||
| 1184 | buf = xmalloc (size); | ||
| 1185 | while (buf) | ||
| 1186 | { | ||
| 1187 | size_allocated = size; | ||
| 1188 | err = GetScrapFlavorData (from_scrap, flavor_type, &size, buf); | ||
| 1189 | if (err != noErr) | ||
| 1190 | { | ||
| 1191 | xfree (buf); | ||
| 1192 | buf = NULL; | ||
| 1193 | } | ||
| 1194 | else if (size_allocated < size) | ||
| 1195 | { | ||
| 1196 | char *newbuf = xrealloc (buf, size); | ||
| 1197 | |||
| 1198 | if (newbuf) | ||
| 1199 | buf = newbuf; | ||
| 1200 | else | ||
| 1201 | { | ||
| 1202 | xfree (buf); | ||
| 1203 | buf = NULL; | ||
| 1204 | } | ||
| 1205 | } | ||
| 1206 | else | ||
| 1207 | break; | ||
| 1208 | } | ||
| 1209 | if (err == noErr) | ||
| 1210 | if (buf == NULL) | ||
| 1211 | err = memFullErr; | ||
| 1212 | else | ||
| 1213 | { | ||
| 1214 | err = PutScrapFlavor (to_scrap, flavor_type, kScrapFlavorMaskNone, | ||
| 1215 | size, buf); | ||
| 1216 | xfree (buf); | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | return err; | ||
| 1220 | } | ||
| 924 | 1221 | ||
| 925 | static OSStatus | 1222 | static OSStatus |
| 926 | mac_handle_service_event (call_ref, event, data) | 1223 | mac_handle_service_event (call_ref, event, data) |
| @@ -929,7 +1226,12 @@ mac_handle_service_event (call_ref, event, data) | |||
| 929 | void *data; | 1226 | void *data; |
| 930 | { | 1227 | { |
| 931 | OSStatus err = noErr; | 1228 | OSStatus err = noErr; |
| 932 | ScrapRef cur_scrap; | 1229 | ScrapRef cur_scrap, specific_scrap; |
| 1230 | UInt32 event_kind = GetEventKind (event); | ||
| 1231 | CFMutableArrayRef copy_types, paste_types; | ||
| 1232 | CFStringRef type; | ||
| 1233 | Lisp_Object rest; | ||
| 1234 | ScrapFlavorType flavor_type; | ||
| 933 | 1235 | ||
| 934 | /* Check if Vmac_services_selection is a valid selection that has a | 1236 | /* Check if Vmac_services_selection is a valid selection that has a |
| 935 | corresponding scrap. */ | 1237 | corresponding scrap. */ |
| @@ -940,86 +1242,103 @@ mac_handle_service_event (call_ref, event, data) | |||
| 940 | if (!(err == noErr && cur_scrap)) | 1242 | if (!(err == noErr && cur_scrap)) |
| 941 | return eventNotHandledErr; | 1243 | return eventNotHandledErr; |
| 942 | 1244 | ||
| 943 | switch (GetEventKind (event)) | 1245 | switch (event_kind) |
| 944 | { | 1246 | { |
| 945 | case kEventServiceGetTypes: | 1247 | case kEventServiceGetTypes: |
| 946 | { | 1248 | /* Set paste types. */ |
| 947 | CFMutableArrayRef copy_types, paste_types; | 1249 | err = GetEventParameter (event, kEventParamServicePasteTypes, |
| 948 | CFStringRef type; | 1250 | typeCFMutableArrayRef, NULL, |
| 949 | Lisp_Object rest; | 1251 | sizeof (CFMutableArrayRef), NULL, |
| 950 | ScrapFlavorType flavor_type; | 1252 | &paste_types); |
| 951 | 1253 | if (err != noErr) | |
| 952 | /* Set paste types. */ | 1254 | break; |
| 953 | err = GetEventParameter (event, kEventParamServicePasteTypes, | 1255 | |
| 954 | typeCFMutableArrayRef, NULL, | 1256 | for (rest = Vselection_converter_alist; CONSP (rest); |
| 955 | sizeof (CFMutableArrayRef), NULL, | 1257 | rest = XCDR (rest)) |
| 956 | &paste_types); | 1258 | if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest))) |
| 957 | if (err == noErr) | 1259 | && (flavor_type = |
| 958 | for (rest = Vselection_converter_alist; CONSP (rest); | 1260 | get_flavor_type_from_symbol (XCAR (XCAR (rest))))) |
| 959 | rest = XCDR (rest)) | 1261 | { |
| 960 | if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest))) | 1262 | type = CreateTypeStringWithOSType (flavor_type); |
| 961 | && (flavor_type = | 1263 | if (type) |
| 962 | get_flavor_type_from_symbol (XCAR (XCAR (rest))))) | ||
| 963 | { | 1264 | { |
| 964 | type = CreateTypeStringWithOSType (flavor_type); | 1265 | CFArrayAppendValue (paste_types, type); |
| 965 | if (type) | 1266 | CFRelease (type); |
| 966 | { | ||
| 967 | CFArrayAppendValue (paste_types, type); | ||
| 968 | CFRelease (type); | ||
| 969 | } | ||
| 970 | } | 1267 | } |
| 1268 | } | ||
| 971 | 1269 | ||
| 972 | /* Set copy types. */ | 1270 | /* Set copy types. */ |
| 973 | err = GetEventParameter (event, kEventParamServiceCopyTypes, | 1271 | err = GetEventParameter (event, kEventParamServiceCopyTypes, |
| 974 | typeCFMutableArrayRef, NULL, | 1272 | typeCFMutableArrayRef, NULL, |
| 975 | sizeof (CFMutableArrayRef), NULL, | 1273 | sizeof (CFMutableArrayRef), NULL, |
| 976 | ©_types); | 1274 | ©_types); |
| 977 | if (err == noErr | 1275 | if (err != noErr) |
| 978 | && !NILP (Fx_selection_owner_p (Vmac_services_selection))) | 1276 | break; |
| 979 | for (rest = get_scrap_target_type_list (cur_scrap); | 1277 | |
| 980 | CONSP (rest) && SYMBOLP (XCAR (rest)); rest = XCDR (rest)) | 1278 | if (NILP (Fx_selection_owner_p (Vmac_services_selection))) |
| 981 | { | 1279 | break; |
| 982 | flavor_type = get_flavor_type_from_symbol (XCAR (rest)); | 1280 | else |
| 983 | if (flavor_type) | 1281 | goto copy_all_flavors; |
| 984 | { | ||
| 985 | type = CreateTypeStringWithOSType (flavor_type); | ||
| 986 | if (type) | ||
| 987 | { | ||
| 988 | CFArrayAppendValue (copy_types, type); | ||
| 989 | CFRelease (type); | ||
| 990 | } | ||
| 991 | } | ||
| 992 | } | ||
| 993 | } | ||
| 994 | break; | ||
| 995 | 1282 | ||
| 996 | case kEventServiceCopy: | 1283 | case kEventServiceCopy: |
| 997 | { | 1284 | err = GetEventParameter (event, kEventParamScrapRef, |
| 998 | ScrapRef specific_scrap; | 1285 | typeScrapRef, NULL, |
| 999 | Lisp_Object rest, data; | 1286 | sizeof (ScrapRef), NULL, &specific_scrap); |
| 1000 | 1287 | if (err != noErr | |
| 1001 | err = GetEventParameter (event, kEventParamScrapRef, | 1288 | || NILP (Fx_selection_owner_p (Vmac_services_selection))) |
| 1002 | typeScrapRef, NULL, | 1289 | { |
| 1003 | sizeof (ScrapRef), NULL, &specific_scrap); | ||
| 1004 | if (err == noErr | ||
| 1005 | && !NILP (Fx_selection_owner_p (Vmac_services_selection))) | ||
| 1006 | for (rest = get_scrap_target_type_list (cur_scrap); | ||
| 1007 | CONSP (rest) && SYMBOLP (XCAR (rest)); rest = XCDR (rest)) | ||
| 1008 | { | ||
| 1009 | data = get_scrap_string (cur_scrap, XCAR (rest)); | ||
| 1010 | if (STRINGP (data)) | ||
| 1011 | err = put_scrap_string (specific_scrap, XCAR (rest), data); | ||
| 1012 | } | ||
| 1013 | else | ||
| 1014 | err = eventNotHandledErr; | 1290 | err = eventNotHandledErr; |
| 1291 | break; | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | copy_all_flavors: | ||
| 1295 | { | ||
| 1296 | UInt32 count, i; | ||
| 1297 | ScrapFlavorInfo *flavor_info = NULL; | ||
| 1298 | ScrapFlavorFlags flags; | ||
| 1299 | |||
| 1300 | err = GetScrapFlavorCount (cur_scrap, &count); | ||
| 1301 | if (err == noErr) | ||
| 1302 | flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count); | ||
| 1303 | if (flavor_info) | ||
| 1304 | { | ||
| 1305 | err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info); | ||
| 1306 | if (err != noErr) | ||
| 1307 | { | ||
| 1308 | xfree (flavor_info); | ||
| 1309 | flavor_info = NULL; | ||
| 1310 | } | ||
| 1311 | } | ||
| 1312 | if (flavor_info == NULL) | ||
| 1313 | break; | ||
| 1314 | |||
| 1315 | for (i = 0; i < count; i++) | ||
| 1316 | { | ||
| 1317 | flavor_type = flavor_info[i].flavorType; | ||
| 1318 | err = GetScrapFlavorFlags (cur_scrap, flavor_type, &flags); | ||
| 1319 | if (err == noErr && !(flags & kScrapFlavorMaskSenderOnly)) | ||
| 1320 | { | ||
| 1321 | if (event_kind == kEventServiceCopy) | ||
| 1322 | err = copy_scrap_flavor_data (cur_scrap, specific_scrap, | ||
| 1323 | flavor_type); | ||
| 1324 | else /* event_kind == kEventServiceGetTypes */ | ||
| 1325 | { | ||
| 1326 | type = CreateTypeStringWithOSType (flavor_type); | ||
| 1327 | if (type) | ||
| 1328 | { | ||
| 1329 | CFArrayAppendValue (copy_types, type); | ||
| 1330 | CFRelease (type); | ||
| 1331 | } | ||
| 1332 | } | ||
| 1333 | } | ||
| 1334 | } | ||
| 1335 | xfree (flavor_info); | ||
| 1015 | } | 1336 | } |
| 1016 | break; | 1337 | break; |
| 1017 | 1338 | ||
| 1018 | case kEventServicePaste: | 1339 | case kEventServicePaste: |
| 1019 | case kEventServicePerform: | 1340 | case kEventServicePerform: |
| 1020 | { | 1341 | { |
| 1021 | ScrapRef specific_scrap; | ||
| 1022 | Lisp_Object rest, data; | ||
| 1023 | int data_exists_p = 0; | 1342 | int data_exists_p = 0; |
| 1024 | 1343 | ||
| 1025 | err = GetEventParameter (event, kEventParamScrapRef, typeScrapRef, | 1344 | err = GetEventParameter (event, kEventParamScrapRef, typeScrapRef, |
| @@ -1033,25 +1352,24 @@ mac_handle_service_event (call_ref, event, data) | |||
| 1033 | { | 1352 | { |
| 1034 | if (! (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest))))) | 1353 | if (! (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest))))) |
| 1035 | continue; | 1354 | continue; |
| 1036 | data = get_scrap_string (specific_scrap, XCAR (XCAR (rest))); | 1355 | flavor_type = get_flavor_type_from_symbol (XCAR (XCAR (rest))); |
| 1037 | if (STRINGP (data)) | 1356 | if (flavor_type == 0) |
| 1038 | { | 1357 | continue; |
| 1039 | err = put_scrap_string (cur_scrap, XCAR (XCAR (rest)), | 1358 | err = copy_scrap_flavor_data (specific_scrap, cur_scrap, |
| 1040 | data); | 1359 | flavor_type); |
| 1041 | if (err != noErr) | 1360 | if (err == noErr) |
| 1042 | break; | 1361 | data_exists_p = 1; |
| 1043 | data_exists_p = 1; | ||
| 1044 | } | ||
| 1045 | } | 1362 | } |
| 1046 | if (err == noErr) | 1363 | if (!data_exists_p) |
| 1047 | if (data_exists_p) | 1364 | err = eventNotHandledErr; |
| 1048 | mac_store_application_menu_event (event); | 1365 | else |
| 1049 | else | 1366 | err = mac_store_services_event (event); |
| 1050 | err = eventNotHandledErr; | ||
| 1051 | } | 1367 | } |
| 1052 | break; | 1368 | break; |
| 1053 | } | 1369 | } |
| 1054 | 1370 | ||
| 1371 | if (err != noErr) | ||
| 1372 | err = eventNotHandledErr; | ||
| 1055 | return err; | 1373 | return err; |
| 1056 | } | 1374 | } |
| 1057 | #endif | 1375 | #endif |
| @@ -1065,6 +1383,7 @@ syms_of_macselect () | |||
| 1065 | defsubr (&Sx_disown_selection_internal); | 1383 | defsubr (&Sx_disown_selection_internal); |
| 1066 | defsubr (&Sx_selection_owner_p); | 1384 | defsubr (&Sx_selection_owner_p); |
| 1067 | defsubr (&Sx_selection_exists_p); | 1385 | defsubr (&Sx_selection_exists_p); |
| 1386 | defsubr (&Smac_process_deferred_apple_events); | ||
| 1068 | 1387 | ||
| 1069 | Vselection_alist = Qnil; | 1388 | Vselection_alist = Qnil; |
| 1070 | staticpro (&Vselection_alist); | 1389 | staticpro (&Vselection_alist); |
| @@ -1106,6 +1425,10 @@ next communication only. After the communication, this variable is | |||
| 1106 | set to nil. */); | 1425 | set to nil. */); |
| 1107 | Vnext_selection_coding_system = Qnil; | 1426 | Vnext_selection_coding_system = Qnil; |
| 1108 | 1427 | ||
| 1428 | DEFVAR_LISP ("mac-apple-event-map", &Vmac_apple_event_map, | ||
| 1429 | doc: /* Keymap for Apple events handled by Emacs. */); | ||
| 1430 | Vmac_apple_event_map = Qnil; | ||
| 1431 | |||
| 1109 | #ifdef MAC_OSX | 1432 | #ifdef MAC_OSX |
| 1110 | DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, | 1433 | DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, |
| 1111 | doc: /* Selection name for communication via Services menu. */); | 1434 | doc: /* Selection name for communication via Services menu. */); |
| @@ -1125,6 +1448,12 @@ set to nil. */); | |||
| 1125 | 1448 | ||
| 1126 | Qmac_ostype = intern ("mac-ostype"); | 1449 | Qmac_ostype = intern ("mac-ostype"); |
| 1127 | staticpro (&Qmac_ostype); | 1450 | staticpro (&Qmac_ostype); |
| 1451 | |||
| 1452 | Qmac_apple_event_class = intern ("mac-apple-event-class"); | ||
| 1453 | staticpro (&Qmac_apple_event_class); | ||
| 1454 | |||
| 1455 | Qmac_apple_event_id = intern ("mac-apple-event-id"); | ||
| 1456 | staticpro (&Qmac_apple_event_id); | ||
| 1128 | } | 1457 | } |
| 1129 | 1458 | ||
| 1130 | /* arch-tag: f3c91ad8-99e0-4bd6-9eef-251b2f848732 | 1459 | /* arch-tag: f3c91ad8-99e0-4bd6-9eef-251b2f848732 |
diff --git a/src/macterm.c b/src/macterm.c index 2976a84e190..ae2942c4cf9 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -622,7 +622,7 @@ atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout) | |||
| 622 | ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)}; | 622 | ByteCount sizes[] = {sizeof (ATSLineLayoutOptions)}; |
| 623 | static ATSLineLayoutOptions line_layout = | 623 | static ATSLineLayoutOptions line_layout = |
| 624 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 | 624 | #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 |
| 625 | kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics | 625 | kATSLineDisableAllLayoutOperations | kATSLineUseDeviceMetrics |
| 626 | #else | 626 | #else |
| 627 | kATSLineIsDisplayOnly | kATSLineFractDisable | 627 | kATSLineIsDisplayOnly | kATSLineFractDisable |
| 628 | #endif | 628 | #endif |
| @@ -8127,20 +8127,18 @@ Lisp_Object Vmac_pass_control_to_system; | |||
| 8127 | Carbon/Apple event handlers. */ | 8127 | Carbon/Apple event handlers. */ |
| 8128 | static struct input_event *read_socket_inev = NULL; | 8128 | static struct input_event *read_socket_inev = NULL; |
| 8129 | 8129 | ||
| 8130 | /* Set in term/mac-win.el to indicate that event loop can now generate | ||
| 8131 | drag and drop events. */ | ||
| 8132 | Lisp_Object Qmac_ready_for_drag_n_drop; | ||
| 8133 | |||
| 8134 | Point saved_menu_event_location; | 8130 | Point saved_menu_event_location; |
| 8135 | 8131 | ||
| 8136 | /* Apple Events */ | 8132 | /* Apple Events */ |
| 8137 | static void init_required_apple_events (void); | 8133 | #if USE_CARBON_EVENTS |
| 8138 | static pascal OSErr | 8134 | static Lisp_Object Qhicommand; |
| 8139 | do_ae_open_application (const AppleEvent *, AppleEvent *, long); | 8135 | #endif |
| 8140 | static pascal OSErr | 8136 | extern int mac_ready_for_apple_events; |
| 8141 | do_ae_print_documents (const AppleEvent *, AppleEvent *, long); | 8137 | extern Lisp_Object Qundefined; |
| 8142 | static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); | 8138 | extern void init_apple_event_handler P_ ((void)); |
| 8143 | static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); | 8139 | extern void mac_find_apple_event_spec P_ ((AEEventClass, AEEventID, |
| 8140 | Lisp_Object *, Lisp_Object *, | ||
| 8141 | Lisp_Object *)); | ||
| 8144 | 8142 | ||
| 8145 | #if TARGET_API_MAC_CARBON | 8143 | #if TARGET_API_MAC_CARBON |
| 8146 | /* Drag and Drop */ | 8144 | /* Drag and Drop */ |
| @@ -8150,11 +8148,10 @@ static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; | |||
| 8150 | static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; | 8148 | static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; |
| 8151 | #endif | 8149 | #endif |
| 8152 | 8150 | ||
| 8153 | static Lisp_Object Qapplication, Qabout; | ||
| 8154 | #if USE_CARBON_EVENTS | 8151 | #if USE_CARBON_EVENTS |
| 8155 | #ifdef MAC_OSX | 8152 | #ifdef MAC_OSX |
| 8156 | extern void init_service_handler (); | 8153 | extern void init_service_handler (); |
| 8157 | static Lisp_Object Qpreferences, Qservices, Qpaste, Qperform; | 8154 | static Lisp_Object Qservices, Qpaste, Qperform; |
| 8158 | #endif | 8155 | #endif |
| 8159 | /* Window Event Handler */ | 8156 | /* Window Event Handler */ |
| 8160 | static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, | 8157 | static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, |
| @@ -8699,179 +8696,49 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 8699 | x_real_positions (f, &f->left_pos, &f->top_pos); | 8696 | x_real_positions (f, &f->left_pos, &f->top_pos); |
| 8700 | } | 8697 | } |
| 8701 | 8698 | ||
| 8702 | /* Intialize AppleEvent dispatcher table for the required events. */ | 8699 | OSErr |
| 8703 | void | 8700 | mac_store_apple_event (class, id, desc) |
| 8704 | init_required_apple_events () | 8701 | Lisp_Object class, id; |
| 8705 | { | 8702 | const AEDesc *desc; |
| 8706 | OSErr err; | ||
| 8707 | long result; | ||
| 8708 | |||
| 8709 | /* Make sure we have apple events before starting. */ | ||
| 8710 | err = Gestalt (gestaltAppleEventsAttr, &result); | ||
| 8711 | if (err != noErr) | ||
| 8712 | abort (); | ||
| 8713 | |||
| 8714 | if (!(result & (1 << gestaltAppleEventsPresent))) | ||
| 8715 | abort (); | ||
| 8716 | |||
| 8717 | #if TARGET_API_MAC_CARBON | ||
| 8718 | err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, | ||
| 8719 | NewAEEventHandlerUPP | ||
| 8720 | ((AEEventHandlerProcPtr) do_ae_open_application), | ||
| 8721 | 0L, false); | ||
| 8722 | #else | ||
| 8723 | err = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, | ||
| 8724 | NewAEEventHandlerProc | ||
| 8725 | ((AEEventHandlerProcPtr) do_ae_open_application), | ||
| 8726 | 0L, false); | ||
| 8727 | #endif | ||
| 8728 | if (err != noErr) | ||
| 8729 | abort (); | ||
| 8730 | |||
| 8731 | #if TARGET_API_MAC_CARBON | ||
| 8732 | err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, | ||
| 8733 | NewAEEventHandlerUPP | ||
| 8734 | ((AEEventHandlerProcPtr) do_ae_open_documents), | ||
| 8735 | 0L, false); | ||
| 8736 | #else | ||
| 8737 | err = AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, | ||
| 8738 | NewAEEventHandlerProc | ||
| 8739 | ((AEEventHandlerProcPtr) do_ae_open_documents), | ||
| 8740 | 0L, false); | ||
| 8741 | #endif | ||
| 8742 | if (err != noErr) | ||
| 8743 | abort (); | ||
| 8744 | |||
| 8745 | #if TARGET_API_MAC_CARBON | ||
| 8746 | err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, | ||
| 8747 | NewAEEventHandlerUPP | ||
| 8748 | ((AEEventHandlerProcPtr) do_ae_print_documents), | ||
| 8749 | 0L, false); | ||
| 8750 | #else | ||
| 8751 | err = AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, | ||
| 8752 | NewAEEventHandlerProc | ||
| 8753 | ((AEEventHandlerProcPtr) do_ae_print_documents), | ||
| 8754 | 0L, false); | ||
| 8755 | #endif | ||
| 8756 | if (err != noErr) | ||
| 8757 | abort (); | ||
| 8758 | |||
| 8759 | #if TARGET_API_MAC_CARBON | ||
| 8760 | err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, | ||
| 8761 | NewAEEventHandlerUPP | ||
| 8762 | ((AEEventHandlerProcPtr) do_ae_quit_application), | ||
| 8763 | 0L, false); | ||
| 8764 | #else | ||
| 8765 | err = AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, | ||
| 8766 | NewAEEventHandlerProc | ||
| 8767 | ((AEEventHandlerProcPtr) do_ae_quit_application), | ||
| 8768 | 0L, false); | ||
| 8769 | #endif | ||
| 8770 | if (err != noErr) | ||
| 8771 | abort (); | ||
| 8772 | } | ||
| 8773 | |||
| 8774 | void | ||
| 8775 | mac_store_application_menu_event (event) | ||
| 8776 | #if USE_CARBON_EVENTS | ||
| 8777 | EventRef event; | ||
| 8778 | #else | ||
| 8779 | UInt32 event; | ||
| 8780 | #endif | ||
| 8781 | { | 8703 | { |
| 8704 | OSErr err = noErr; | ||
| 8782 | struct input_event buf; | 8705 | struct input_event buf; |
| 8783 | Lisp_Object frame, entry; | 8706 | AEDesc *desc_copy; |
| 8784 | |||
| 8785 | EVENT_INIT (buf); | ||
| 8786 | |||
| 8787 | XSETFRAME (frame, mac_focus_frame (&one_mac_display_info)); | ||
| 8788 | buf.kind = MENU_BAR_EVENT; | ||
| 8789 | buf.frame_or_window = frame; | ||
| 8790 | buf.arg = frame; | ||
| 8791 | kbd_buffer_store_event (&buf); | ||
| 8792 | |||
| 8793 | buf.arg = Qapplication; | ||
| 8794 | kbd_buffer_store_event (&buf); | ||
| 8795 | 8707 | ||
| 8796 | #if USE_CARBON_EVENTS | 8708 | desc_copy = xmalloc (sizeof (AEDesc)); |
| 8797 | switch (GetEventClass (event)) | 8709 | if (desc_copy == NULL) |
| 8710 | err = memFullErr; | ||
| 8711 | else | ||
| 8712 | err = AEDuplicateDesc (desc, desc_copy); | ||
| 8713 | if (err == noErr) | ||
| 8798 | { | 8714 | { |
| 8799 | #ifdef MAC_OSX | 8715 | EVENT_INIT (buf); |
| 8800 | case kEventClassService: | ||
| 8801 | buf.arg = Qservices; | ||
| 8802 | kbd_buffer_store_event (&buf); | ||
| 8803 | switch (GetEventKind (event)) | ||
| 8804 | { | ||
| 8805 | case kEventServicePaste: | ||
| 8806 | entry = Qpaste; | ||
| 8807 | break; | ||
| 8808 | 8716 | ||
| 8809 | case kEventServicePerform: | 8717 | buf.kind = MAC_APPLE_EVENT; |
| 8810 | { | 8718 | buf.x = class; |
| 8811 | OSErr err; | 8719 | buf.y = id; |
| 8812 | CFStringRef message; | 8720 | buf.code = (int)desc_copy; |
| 8813 | 8721 | XSETFRAME (buf.frame_or_window, | |
| 8814 | err = GetEventParameter (event, kEventParamServiceMessageName, | 8722 | mac_focus_frame (&one_mac_display_info)); |
| 8815 | typeCFStringRef, NULL, | 8723 | buf.arg = Qnil; |
| 8816 | sizeof (CFStringRef), NULL, &message); | 8724 | kbd_buffer_store_event (&buf); |
| 8817 | buf.arg = Qperform; | 8725 | } |
| 8818 | kbd_buffer_store_event (&buf); | ||
| 8819 | if (err == noErr && message) | ||
| 8820 | entry = intern (SDATA (cfstring_to_lisp (message))); | ||
| 8821 | else | ||
| 8822 | entry = Qnil; | ||
| 8823 | } | ||
| 8824 | break; | ||
| 8825 | 8726 | ||
| 8826 | default: | 8727 | return err; |
| 8827 | abort (); | 8728 | } |
| 8828 | } | ||
| 8829 | break; | ||
| 8830 | #endif /* MAC_OSX */ | ||
| 8831 | case kEventClassCommand: | ||
| 8832 | { | ||
| 8833 | HICommand command; | ||
| 8834 | 8729 | ||
| 8835 | GetEventParameter(event, kEventParamDirectObject, typeHICommand, | 8730 | Lisp_Object |
| 8836 | NULL, sizeof (HICommand), NULL, &command); | 8731 | mac_make_lispy_event_code (code) |
| 8837 | switch (command.commandID) | 8732 | int code; |
| 8838 | { | 8733 | { |
| 8839 | case kHICommandAbout: | 8734 | AEDesc *desc = (AEDesc *)code; |
| 8840 | entry = Qabout; | 8735 | Lisp_Object obj; |
| 8841 | break; | ||
| 8842 | #ifdef MAC_OSX | ||
| 8843 | case kHICommandPreferences: | ||
| 8844 | entry = Qpreferences; | ||
| 8845 | break; | ||
| 8846 | #endif /* MAC_OSX */ | ||
| 8847 | case kHICommandQuit: | ||
| 8848 | entry = Qquit; | ||
| 8849 | break; | ||
| 8850 | default: | ||
| 8851 | abort (); | ||
| 8852 | } | ||
| 8853 | } | ||
| 8854 | break; | ||
| 8855 | 8736 | ||
| 8856 | default: | 8737 | obj = mac_aedesc_to_lisp (desc); |
| 8857 | abort (); | 8738 | AEDisposeDesc (desc); |
| 8858 | } | 8739 | xfree (desc); |
| 8859 | #else /* USE_CARBON_EVENTS */ | ||
| 8860 | switch (event) | ||
| 8861 | { | ||
| 8862 | case kHICommandAbout: | ||
| 8863 | entry = Qabout; | ||
| 8864 | break; | ||
| 8865 | case kHICommandQuit: | ||
| 8866 | entry = Qquit; | ||
| 8867 | break; | ||
| 8868 | default: | ||
| 8869 | abort (); | ||
| 8870 | } | ||
| 8871 | #endif | ||
| 8872 | 8740 | ||
| 8873 | buf.arg = entry; | 8741 | return obj; |
| 8874 | kbd_buffer_store_event (&buf); | ||
| 8875 | } | 8742 | } |
| 8876 | 8743 | ||
| 8877 | #if USE_CARBON_EVENTS | 8744 | #if USE_CARBON_EVENTS |
| @@ -8881,28 +8748,49 @@ mac_handle_command_event (next_handler, event, data) | |||
| 8881 | EventRef event; | 8748 | EventRef event; |
| 8882 | void *data; | 8749 | void *data; |
| 8883 | { | 8750 | { |
| 8751 | OSStatus result; | ||
| 8752 | OSErr err; | ||
| 8884 | HICommand command; | 8753 | HICommand command; |
| 8885 | OSErr result; | 8754 | Lisp_Object class_key, id_key, binding; |
| 8886 | 8755 | ||
| 8887 | GetEventParameter(event, kEventParamDirectObject, typeHICommand, NULL, | 8756 | result = CallNextEventHandler (next_handler, event); |
| 8888 | sizeof (HICommand), NULL, &command); | 8757 | if (result != eventNotHandledErr) |
| 8758 | return result; | ||
| 8889 | 8759 | ||
| 8890 | switch (command.commandID) | 8760 | GetEventParameter (event, kEventParamDirectObject, typeHICommand, NULL, |
| 8891 | { | 8761 | sizeof (HICommand), NULL, &command); |
| 8892 | case kHICommandAbout: | ||
| 8893 | #ifdef MAC_OSX | ||
| 8894 | case kHICommandPreferences: | ||
| 8895 | #endif /* MAC_OSX */ | ||
| 8896 | result = CallNextEventHandler (next_handler, event); | ||
| 8897 | if (result != eventNotHandledErr) | ||
| 8898 | return result; | ||
| 8899 | 8762 | ||
| 8900 | mac_store_application_menu_event (event); | 8763 | if (command.commandID == 0) |
| 8901 | return noErr; | 8764 | return eventNotHandledErr; |
| 8902 | 8765 | ||
| 8903 | default: | 8766 | /* A HICommand event is mapped to an Apple event whose event class |
| 8904 | break; | 8767 | symbol is `hicommand' and event ID is its command ID. */ |
| 8905 | } | 8768 | class_key = Qhicommand; |
| 8769 | mac_find_apple_event_spec (0, command.commandID, | ||
| 8770 | &class_key, &id_key, &binding); | ||
| 8771 | if (!NILP (binding) && !EQ (binding, Qundefined)) | ||
| 8772 | if (INTEGERP (binding)) | ||
| 8773 | return XINT (binding); | ||
| 8774 | else | ||
| 8775 | { | ||
| 8776 | AppleEvent apple_event; | ||
| 8777 | UInt32 modifiers; | ||
| 8778 | static EventParamName names[] = {kEventParamDirectObject, | ||
| 8779 | kEventParamKeyModifiers}; | ||
| 8780 | static EventParamType types[] = {typeHICommand, | ||
| 8781 | typeUInt32}; | ||
| 8782 | static UInt32 sizes[] = {sizeof (HICommand), | ||
| 8783 | sizeof (UInt32)}; | ||
| 8784 | err = create_apple_event_from_event_ref (event, 2, names, types, | ||
| 8785 | sizes, &apple_event); | ||
| 8786 | if (err == noErr) | ||
| 8787 | { | ||
| 8788 | err = mac_store_apple_event (class_key, id_key, &apple_event); | ||
| 8789 | AEDisposeDesc (&apple_event); | ||
| 8790 | } | ||
| 8791 | if (err == noErr) | ||
| 8792 | return noErr; | ||
| 8793 | } | ||
| 8906 | 8794 | ||
| 8907 | return eventNotHandledErr; | 8795 | return eventNotHandledErr; |
| 8908 | } | 8796 | } |
| @@ -9064,6 +8952,52 @@ mac_handle_mouse_event (next_handler, event, data) | |||
| 9064 | 8952 | ||
| 9065 | return eventNotHandledErr; | 8953 | return eventNotHandledErr; |
| 9066 | } | 8954 | } |
| 8955 | |||
| 8956 | #ifdef MAC_OSX | ||
| 8957 | OSErr | ||
| 8958 | mac_store_services_event (event) | ||
| 8959 | EventRef event; | ||
| 8960 | { | ||
| 8961 | OSErr err; | ||
| 8962 | AppleEvent apple_event; | ||
| 8963 | Lisp_Object id_key; | ||
| 8964 | |||
| 8965 | switch (GetEventKind (event)) | ||
| 8966 | { | ||
| 8967 | case kEventServicePaste: | ||
| 8968 | id_key = Qpaste; | ||
| 8969 | err = create_apple_event_from_event_ref (event, 0, NULL, | ||
| 8970 | NULL, NULL, &apple_event); | ||
| 8971 | break; | ||
| 8972 | |||
| 8973 | case kEventServicePerform: | ||
| 8974 | { | ||
| 8975 | static EventParamName names[] = {kEventParamServiceMessageName, | ||
| 8976 | kEventParamServiceUserData}; | ||
| 8977 | static EventParamType types[] = {typeCFStringRef, | ||
| 8978 | typeCFStringRef}; | ||
| 8979 | static UInt32 sizes[] = {sizeof (CFStringRef), | ||
| 8980 | sizeof (CFStringRef)}; | ||
| 8981 | |||
| 8982 | id_key = Qperform; | ||
| 8983 | err = create_apple_event_from_event_ref (event, 2, names, types, | ||
| 8984 | sizes, &apple_event); | ||
| 8985 | } | ||
| 8986 | break; | ||
| 8987 | |||
| 8988 | default: | ||
| 8989 | abort (); | ||
| 8990 | } | ||
| 8991 | |||
| 8992 | if (err == noErr) | ||
| 8993 | { | ||
| 8994 | err = mac_store_apple_event (Qservices, id_key, &apple_event); | ||
| 8995 | AEDisposeDesc (&apple_event); | ||
| 8996 | } | ||
| 8997 | |||
| 8998 | return err; | ||
| 8999 | } | ||
| 9000 | #endif /* MAC_OSX */ | ||
| 9067 | #endif /* USE_CARBON_EVENTS */ | 9001 | #endif /* USE_CARBON_EVENTS */ |
| 9068 | 9002 | ||
| 9069 | 9003 | ||
| @@ -9122,159 +9056,6 @@ remove_window_handler (window) | |||
| 9122 | #endif | 9056 | #endif |
| 9123 | } | 9057 | } |
| 9124 | 9058 | ||
| 9125 | /* Open Application Apple Event */ | ||
| 9126 | static pascal OSErr | ||
| 9127 | do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon) | ||
| 9128 | { | ||
| 9129 | return noErr; | ||
| 9130 | } | ||
| 9131 | |||
| 9132 | |||
| 9133 | /* Called when we receive an AppleEvent with an ID of | ||
| 9134 | "kAEOpenDocuments". This routine gets the direct parameter, | ||
| 9135 | extracts the FSSpecs in it, and puts their names on a list. */ | ||
| 9136 | #pragma options align=mac68k | ||
| 9137 | typedef struct SelectionRange { | ||
| 9138 | short unused1; // 0 (not used) | ||
| 9139 | short lineNum; // line to select (<0 to specify range) | ||
| 9140 | long startRange; // start of selection range (if line < 0) | ||
| 9141 | long endRange; // end of selection range (if line < 0) | ||
| 9142 | long unused2; // 0 (not used) | ||
| 9143 | long theDate; // modification date/time | ||
| 9144 | } SelectionRange; | ||
| 9145 | #pragma options align=reset | ||
| 9146 | |||
| 9147 | static pascal OSErr | ||
| 9148 | do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon) | ||
| 9149 | { | ||
| 9150 | OSErr err, err2; | ||
| 9151 | AEDesc the_desc; | ||
| 9152 | AEKeyword keyword; | ||
| 9153 | DescType actual_type; | ||
| 9154 | Size actual_size; | ||
| 9155 | SelectionRange position; | ||
| 9156 | Lisp_Object file_list = Qnil; | ||
| 9157 | |||
| 9158 | xassert (read_socket_inev); | ||
| 9159 | |||
| 9160 | err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc); | ||
| 9161 | if (err != noErr) | ||
| 9162 | goto descriptor_error_exit; | ||
| 9163 | |||
| 9164 | err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size); | ||
| 9165 | if (err == noErr) | ||
| 9166 | file_list = Fcons (list3 (make_number (position.lineNum + 1), | ||
| 9167 | make_number (position.startRange + 1), | ||
| 9168 | make_number (position.endRange + 1)), | ||
| 9169 | file_list); | ||
| 9170 | |||
| 9171 | /* Check to see that we got all of the required parameters from the | ||
| 9172 | event descriptor. For an 'odoc' event this should just be the | ||
| 9173 | file list. */ | ||
| 9174 | err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard, | ||
| 9175 | &actual_type, (Ptr) &keyword, | ||
| 9176 | sizeof (keyword), &actual_size); | ||
| 9177 | /* No error means that we found some unused parameters. | ||
| 9178 | errAEDescNotFound means that there are no more parameters. If we | ||
| 9179 | get an error code other than that, flag it. */ | ||
| 9180 | if ((err == noErr) || (err != errAEDescNotFound)) | ||
| 9181 | { | ||
| 9182 | err = errAEEventNotHandled; | ||
| 9183 | goto error_exit; | ||
| 9184 | } | ||
| 9185 | err = noErr; | ||
| 9186 | |||
| 9187 | /* Got all the parameters we need. Now, go through the direct | ||
| 9188 | object list and parse it up. */ | ||
| 9189 | { | ||
| 9190 | long num_files_to_open; | ||
| 9191 | |||
| 9192 | err = AECountItems (&the_desc, &num_files_to_open); | ||
| 9193 | if (err == noErr) | ||
| 9194 | { | ||
| 9195 | int i; | ||
| 9196 | |||
| 9197 | /* AE file list is one based so just use that for indexing here. */ | ||
| 9198 | for (i = 1; i <= num_files_to_open; i++) | ||
| 9199 | { | ||
| 9200 | char unix_path_name[MAXPATHLEN]; | ||
| 9201 | #ifdef MAC_OSX | ||
| 9202 | FSRef fref; | ||
| 9203 | |||
| 9204 | err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword, | ||
| 9205 | &actual_type, &fref, sizeof (FSRef), | ||
| 9206 | &actual_size); | ||
| 9207 | if (err != noErr || actual_type != typeFSRef) | ||
| 9208 | continue; | ||
| 9209 | |||
| 9210 | if (FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name)) | ||
| 9211 | == noErr) | ||
| 9212 | #else | ||
| 9213 | FSSpec fs; | ||
| 9214 | |||
| 9215 | err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type, | ||
| 9216 | (Ptr) &fs, sizeof (fs), &actual_size); | ||
| 9217 | if (err != noErr) continue; | ||
| 9218 | |||
| 9219 | if (fsspec_to_posix_pathname (&fs, unix_path_name, | ||
| 9220 | sizeof (unix_path_name) - 1) == noErr) | ||
| 9221 | #endif | ||
| 9222 | /* x-dnd functions expect undecoded filenames. */ | ||
| 9223 | file_list = Fcons (make_unibyte_string (unix_path_name, | ||
| 9224 | strlen (unix_path_name)), | ||
| 9225 | file_list); | ||
| 9226 | } | ||
| 9227 | } | ||
| 9228 | |||
| 9229 | /* Build a DRAG_N_DROP_EVENT type event as is done in | ||
| 9230 | constuct_drag_n_drop in w32term.c. */ | ||
| 9231 | if (!NILP (file_list)) | ||
| 9232 | { | ||
| 9233 | struct frame *f = mac_focus_frame (&one_mac_display_info); | ||
| 9234 | WindowPtr wp; | ||
| 9235 | Lisp_Object frame; | ||
| 9236 | |||
| 9237 | read_socket_inev->kind = DRAG_N_DROP_EVENT; | ||
| 9238 | read_socket_inev->code = 0; | ||
| 9239 | read_socket_inev->modifiers = 0; | ||
| 9240 | |||
| 9241 | XSETINT (read_socket_inev->x, 0); | ||
| 9242 | XSETINT (read_socket_inev->y, 0); | ||
| 9243 | |||
| 9244 | XSETFRAME (frame, f); | ||
| 9245 | read_socket_inev->frame_or_window = Fcons (frame, file_list); | ||
| 9246 | |||
| 9247 | #if 0 | ||
| 9248 | /* Regardless of whether Emacs was suspended or in the | ||
| 9249 | foreground, ask it to redraw its entire screen. Otherwise | ||
| 9250 | parts of the screen can be left in an inconsistent | ||
| 9251 | state. */ | ||
| 9252 | wp = FRAME_MAC_WINDOW (f); | ||
| 9253 | if (wp) | ||
| 9254 | #if TARGET_API_MAC_CARBON | ||
| 9255 | { | ||
| 9256 | Rect r; | ||
| 9257 | |||
| 9258 | GetWindowPortBounds (wp, &r); | ||
| 9259 | InvalWindowRect (wp, &r); | ||
| 9260 | } | ||
| 9261 | #else /* not TARGET_API_MAC_CARBON */ | ||
| 9262 | InvalRect (&(wp->portRect)); | ||
| 9263 | #endif /* not TARGET_API_MAC_CARBON */ | ||
| 9264 | #endif | ||
| 9265 | } | ||
| 9266 | } | ||
| 9267 | |||
| 9268 | error_exit: | ||
| 9269 | /* Nuke the coerced file list in any case */ | ||
| 9270 | err2 = AEDisposeDesc(&the_desc); | ||
| 9271 | |||
| 9272 | descriptor_error_exit: | ||
| 9273 | /* InvalRect(&(gFrontMacWindowP->mWP->portRect)); */ | ||
| 9274 | return err; | ||
| 9275 | } | ||
| 9276 | |||
| 9277 | |||
| 9278 | #if TARGET_API_MAC_CARBON | 9059 | #if TARGET_API_MAC_CARBON |
| 9279 | static pascal OSErr | 9060 | static pascal OSErr |
| 9280 | mac_do_track_drag (DragTrackingMessage message, WindowPtr window, | 9061 | mac_do_track_drag (DragTrackingMessage message, WindowPtr window, |
| @@ -9429,44 +9210,6 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | |||
| 9429 | #endif | 9210 | #endif |
| 9430 | 9211 | ||
| 9431 | 9212 | ||
| 9432 | /* Print Document Apple Event */ | ||
| 9433 | static pascal OSErr | ||
| 9434 | do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon) | ||
| 9435 | { | ||
| 9436 | return errAEEventNotHandled; | ||
| 9437 | } | ||
| 9438 | |||
| 9439 | |||
| 9440 | static pascal OSErr | ||
| 9441 | do_ae_quit_application (AppleEvent* message, AppleEvent *reply, long refcon) | ||
| 9442 | { | ||
| 9443 | #if USE_CARBON_EVENTS | ||
| 9444 | OSErr err; | ||
| 9445 | EventRef event = NULL; | ||
| 9446 | static const HICommand quit_command = {kEventAttributeNone, kHICommandQuit}; | ||
| 9447 | |||
| 9448 | err = CreateEvent (NULL, kEventClassCommand, kEventCommandProcess, 0, | ||
| 9449 | kEventAttributeUserEvent, &event); | ||
| 9450 | if (err == noErr) | ||
| 9451 | err = SetEventParameter (event, kEventParamDirectObject, typeHICommand, | ||
| 9452 | sizeof (HICommand), &quit_command); | ||
| 9453 | if (err == noErr) | ||
| 9454 | mac_store_application_menu_event (event); | ||
| 9455 | if (event) | ||
| 9456 | ReleaseEvent (event); | ||
| 9457 | |||
| 9458 | if (err == noErr) | ||
| 9459 | return noErr; | ||
| 9460 | else | ||
| 9461 | return errAEEventNotHandled; | ||
| 9462 | #else | ||
| 9463 | mac_store_application_menu_event (kHICommandQuit); | ||
| 9464 | |||
| 9465 | return noErr; | ||
| 9466 | #endif | ||
| 9467 | } | ||
| 9468 | |||
| 9469 | |||
| 9470 | #if __profile__ | 9213 | #if __profile__ |
| 9471 | void | 9214 | void |
| 9472 | profiler_exit_proc () | 9215 | profiler_exit_proc () |
| @@ -9520,7 +9263,7 @@ main (void) | |||
| 9520 | 9263 | ||
| 9521 | initialize_applescript (); | 9264 | initialize_applescript (); |
| 9522 | 9265 | ||
| 9523 | init_required_apple_events (); | 9266 | init_apple_event_handler (); |
| 9524 | 9267 | ||
| 9525 | { | 9268 | { |
| 9526 | char **argv; | 9269 | char **argv; |
| @@ -9724,7 +9467,7 @@ mac_wait_next_event (er, sleep_time, dequeue) | |||
| 9724 | mouse_region = NewRgn (); | 9467 | mouse_region = NewRgn (); |
| 9725 | 9468 | ||
| 9726 | event_mask = everyEvent; | 9469 | event_mask = everyEvent; |
| 9727 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) | 9470 | if (!mac_ready_for_apple_events) |
| 9728 | event_mask -= highLevelEventMask; | 9471 | event_mask -= highLevelEventMask; |
| 9729 | 9472 | ||
| 9730 | current_tick = TickCount (); | 9473 | current_tick = TickCount (); |
| @@ -10892,7 +10635,6 @@ mac_initialize () | |||
| 10892 | BLOCK_INPUT; | 10635 | BLOCK_INPUT; |
| 10893 | 10636 | ||
| 10894 | #if TARGET_API_MAC_CARBON | 10637 | #if TARGET_API_MAC_CARBON |
| 10895 | init_required_apple_events (); | ||
| 10896 | 10638 | ||
| 10897 | #if USE_CARBON_EVENTS | 10639 | #if USE_CARBON_EVENTS |
| 10898 | #ifdef MAC_OSX | 10640 | #ifdef MAC_OSX |
| @@ -10907,6 +10649,8 @@ mac_initialize () | |||
| 10907 | #endif /* USE_CARBON_EVENTS */ | 10649 | #endif /* USE_CARBON_EVENTS */ |
| 10908 | 10650 | ||
| 10909 | #ifdef MAC_OSX | 10651 | #ifdef MAC_OSX |
| 10652 | init_apple_event_handler (); | ||
| 10653 | |||
| 10910 | if (!inhibit_window_system) | 10654 | if (!inhibit_window_system) |
| 10911 | MakeMeTheFrontProcess (); | 10655 | MakeMeTheFrontProcess (); |
| 10912 | #endif | 10656 | #endif |
| @@ -10937,15 +10681,14 @@ syms_of_macterm () | |||
| 10937 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); | 10681 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); |
| 10938 | Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); | 10682 | Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); |
| 10939 | 10683 | ||
| 10940 | Qapplication = intern ("application"); staticpro (&Qapplication); | 10684 | #if USE_CARBON_EVENTS |
| 10941 | Qabout = intern ("about"); staticpro (&Qabout); | 10685 | Qhicommand = intern ("hicommand"); staticpro (&Qhicommand); |
| 10942 | 10686 | #ifdef MAC_OSX | |
| 10943 | #if USE_CARBON_EVENTS && defined (MAC_OSX) | ||
| 10944 | Qpreferences = intern ("preferences"); staticpro (&Qpreferences); | ||
| 10945 | Qservices = intern ("services"); staticpro (&Qservices); | 10687 | Qservices = intern ("services"); staticpro (&Qservices); |
| 10946 | Qpaste = intern ("paste"); staticpro (&Qpaste); | 10688 | Qpaste = intern ("paste"); staticpro (&Qpaste); |
| 10947 | Qperform = intern ("perform"); staticpro (&Qperform); | 10689 | Qperform = intern ("perform"); staticpro (&Qperform); |
| 10948 | #endif | 10690 | #endif |
| 10691 | #endif | ||
| 10949 | 10692 | ||
| 10950 | #ifdef MAC_OSX | 10693 | #ifdef MAC_OSX |
| 10951 | Fprovide (intern ("mac-carbon"), Qnil); | 10694 | Fprovide (intern ("mac-carbon"), Qnil); |
| @@ -10954,9 +10697,6 @@ syms_of_macterm () | |||
| 10954 | staticpro (&Qreverse); | 10697 | staticpro (&Qreverse); |
| 10955 | Qreverse = intern ("reverse"); | 10698 | Qreverse = intern ("reverse"); |
| 10956 | 10699 | ||
| 10957 | staticpro (&Qmac_ready_for_drag_n_drop); | ||
| 10958 | Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); | ||
| 10959 | |||
| 10960 | staticpro (&x_display_name_list); | 10700 | staticpro (&x_display_name_list); |
| 10961 | x_display_name_list = Qnil; | 10701 | x_display_name_list = Qnil; |
| 10962 | 10702 | ||
diff --git a/src/macterm.h b/src/macterm.h index 214037c3346..916a461f67e 100644 --- a/src/macterm.h +++ b/src/macterm.h | |||
| @@ -79,7 +79,7 @@ struct mac_display_info | |||
| 79 | /* Number of planes on this screen. */ | 79 | /* Number of planes on this screen. */ |
| 80 | int n_planes; | 80 | int n_planes; |
| 81 | 81 | ||
| 82 | /* Whether the screen supports color */ | 82 | /* Whether the screen supports color */ |
| 83 | int color_p; | 83 | int color_p; |
| 84 | 84 | ||
| 85 | /* Dimensions of this screen. */ | 85 | /* Dimensions of this screen. */ |
| @@ -564,6 +564,7 @@ extern void mac_clear_area P_ ((struct frame *, int, int, | |||
| 564 | extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); | 564 | extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); |
| 565 | extern OSErr install_window_handler P_ ((WindowPtr)); | 565 | extern OSErr install_window_handler P_ ((WindowPtr)); |
| 566 | extern void remove_window_handler P_ ((WindowPtr)); | 566 | extern void remove_window_handler P_ ((WindowPtr)); |
| 567 | extern Lisp_Object mac_make_lispy_event_code P_ ((int)); | ||
| 567 | 568 | ||
| 568 | #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 | 569 | #define FONT_TYPE_FOR_UNIBYTE(font, ch) 0 |
| 569 | #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 | 570 | #define FONT_TYPE_FOR_MULTIBYTE(font, ch) 0 |
| @@ -577,7 +578,12 @@ extern void x_clear_frame_selections P_ ((struct frame *)); | |||
| 577 | extern OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); | 578 | extern OSErr posix_pathname_to_fsspec P_ ((const char *, FSSpec *)); |
| 578 | extern OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); | 579 | extern OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int)); |
| 579 | extern void mac_clear_font_name_table P_ ((void)); | 580 | extern void mac_clear_font_name_table P_ ((void)); |
| 581 | extern Lisp_Object mac_aedesc_to_lisp P_ ((AEDesc *)); | ||
| 580 | #if TARGET_API_MAC_CARBON | 582 | #if TARGET_API_MAC_CARBON |
| 583 | extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32, | ||
| 584 | EventParamName *, | ||
| 585 | EventParamType *, | ||
| 586 | UInt32 *, AppleEvent *)); | ||
| 581 | extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); | 587 | extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); |
| 582 | extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object)); | 588 | extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object)); |
| 583 | extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef)); | 589 | extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef)); |
| @@ -592,6 +598,7 @@ extern Lisp_Object cfproperty_list_to_lisp P_ ((CFPropertyListRef, int, int)); | |||
| 592 | extern void xrm_merge_string_database P_ ((XrmDatabase, char *)); | 598 | extern void xrm_merge_string_database P_ ((XrmDatabase, char *)); |
| 593 | extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, char *, char *)); | 599 | extern Lisp_Object xrm_get_resource P_ ((XrmDatabase, char *, char *)); |
| 594 | extern XrmDatabase xrm_get_preference_database P_ ((char *)); | 600 | extern XrmDatabase xrm_get_preference_database P_ ((char *)); |
| 601 | EXFUN (Fmac_get_preference, 4); | ||
| 595 | 602 | ||
| 596 | /* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79 | 603 | /* arch-tag: 6b4ca125-5bef-476d-8ee8-31ed808b7e79 |
| 597 | (do not change this comment) */ | 604 | (do not change this comment) */ |
diff --git a/src/termhooks.h b/src/termhooks.h index 3fea7c366fb..cb68c9e2c27 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -129,7 +129,7 @@ enum event_kind | |||
| 129 | by MS-Windows scroll bar controls. */ | 129 | by MS-Windows scroll bar controls. */ |
| 130 | #endif | 130 | #endif |
| 131 | SELECTION_REQUEST_EVENT, /* Another X client wants a selection from us. | 131 | SELECTION_REQUEST_EVENT, /* Another X client wants a selection from us. |
| 132 | See `struct selection_event'. */ | 132 | See `struct selection_input_event'. */ |
| 133 | SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */ | 133 | SELECTION_CLEAR_EVENT, /* Another X client cleared our selection. */ |
| 134 | BUFFER_SWITCH_EVENT, /* A process filter has switched buffers. */ | 134 | BUFFER_SWITCH_EVENT, /* A process filter has switched buffers. */ |
| 135 | DELETE_WINDOW_EVENT, /* An X client said "delete this window". */ | 135 | DELETE_WINDOW_EVENT, /* An X client said "delete this window". */ |
| @@ -177,12 +177,22 @@ enum event_kind | |||
| 177 | 177 | ||
| 178 | /* Queued from XTread_socket when session manager sends | 178 | /* Queued from XTread_socket when session manager sends |
| 179 | save yourself before shutdown. */ | 179 | save yourself before shutdown. */ |
| 180 | SAVE_SESSION_EVENT | 180 | SAVE_SESSION_EVENT, |
| 181 | |||
| 182 | #ifdef MAC_OS | ||
| 183 | /* Generated when an Apple event, a HICommand event, or a Services | ||
| 184 | menu event is received and the corresponding handler is | ||
| 185 | registered. Members `x' and `y' are for the event class and ID | ||
| 186 | symbols, respectively. Member `code' points to the Apple event | ||
| 187 | descriptor. Parameters for Non-Apple events are converted to | ||
| 188 | those in Apple events. */ | ||
| 189 | MAC_APPLE_EVENT | ||
| 190 | #endif | ||
| 181 | }; | 191 | }; |
| 182 | 192 | ||
| 183 | /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT | 193 | /* If a struct input_event has a kind which is SELECTION_REQUEST_EVENT |
| 184 | or SELECTION_CLEAR_EVENT, then its contents are really described | 194 | or SELECTION_CLEAR_EVENT, then its contents are really described |
| 185 | by `struct selection_event'; see xterm.h. */ | 195 | by `struct selection_input_event'; see xterm.h. */ |
| 186 | 196 | ||
| 187 | /* The keyboard input buffer is an array of these structures. Each one | 197 | /* The keyboard input buffer is an array of these structures. Each one |
| 188 | represents some sort of input event - a keystroke, a mouse click, or | 198 | represents some sort of input event - a keystroke, a mouse click, or |
| @@ -208,7 +218,7 @@ struct input_event | |||
| 208 | unsigned long timestamp; | 218 | unsigned long timestamp; |
| 209 | 219 | ||
| 210 | /* This is padding just to put the frame_or_window field | 220 | /* This is padding just to put the frame_or_window field |
| 211 | past the size of struct selection_event. */ | 221 | past the size of struct selection_input_event. */ |
| 212 | int *padding[2]; | 222 | int *padding[2]; |
| 213 | 223 | ||
| 214 | /* This field is copied into a vector while the event is in the queue, | 224 | /* This field is copied into a vector while the event is in the queue, |
diff --git a/src/w32fns.c b/src/w32fns.c index 6fc6c860808..d1e4e49bb03 100644 --- a/src/w32fns.c +++ b/src/w32fns.c | |||
| @@ -8939,8 +8939,12 @@ w32_abort() | |||
| 8939 | button = MessageBox (NULL, | 8939 | button = MessageBox (NULL, |
| 8940 | "A fatal error has occurred!\n\n" | 8940 | "A fatal error has occurred!\n\n" |
| 8941 | "Would you like to attach a debugger?\n\n" | 8941 | "Would you like to attach a debugger?\n\n" |
| 8942 | "Select YES to debug, NO to abort Emacs", | 8942 | "Select YES to debug, NO to abort Emacs" |
| 8943 | "Emacs Abort Dialog", | 8943 | #if __GNUC__ |
| 8944 | "\n\n(type \"gdb -p <emacs-PID>\" and\n" | ||
| 8945 | "\"continue\" inside GDB before clicking YES.)" | ||
| 8946 | #endif | ||
| 8947 | , "Emacs Abort Dialog", | ||
| 8944 | MB_ICONEXCLAMATION | MB_TASKMODAL | 8948 | MB_ICONEXCLAMATION | MB_TASKMODAL |
| 8945 | | MB_SETFOREGROUND | MB_YESNO); | 8949 | | MB_SETFOREGROUND | MB_YESNO); |
| 8946 | switch (button) | 8950 | switch (button) |