diff options
| author | YAMAMOTO Mitsuharu | 2005-03-04 11:11:16 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2005-03-04 11:11:16 +0000 |
| commit | 25c9622b81de91b3ac971fe2fb621707b394e073 (patch) | |
| tree | c3c51f5a08c57ee4b64b528b6955e7a07522554b /src | |
| parent | 04b5475bff56f8c57c6c4fe04d4e9b4555f53d26 (diff) | |
| download | emacs-25c9622b81de91b3ac971fe2fb621707b394e073.tar.gz emacs-25c9622b81de91b3ac971fe2fb621707b394e073.zip | |
[TARGET_API_MAC_CARBON && !MAC_OSX]: Define USE_CARBON_EVENTS to 1.
[__MRC__ && TARGET_API_MAC_CARBON]: Don't declare `qd'.
(x_free_frame_resources): Call remove_window_handler for non-tooltip
windows.
[TARGET_API_MAC_CARBON]: Don't include headers that are included via
Carbon.h.
[TARGET_API_MAC_CARBON] (mac_do_track_dragUPP)
(mac_do_receive_dragUPP): New variables.
(mac_handle_service_event, init_service_handler): Put declarations and
definitions in #ifdef MAC_OSX.
(install_window_handler) [TARGET_API_MAC_CARBON]: Create UPPs for
drag-and-drop handler functions and register them.
(remove_window_handler): New function.
(do_ae_open_documents, mac_do_receive_drag) [!MAC_OSX]: Use
fsspec_to_posix_pathname.
(main): Change #if !TARGET_API_MAC_CARBON to #ifdef MAC_OS8.
(XTread_socket) [!MAC_OSX]: Don't pass keyboard events to TSM.
[MAC_OS8] (make_mac_terminal_frame) [TARGET_API_MAC_CARBON]: Set
default cursors.
(mac_initialize) [USE_CARBON_EVENTS && !MAC_OSX] : Don't call
init_service_handler or init_quit_char_handler.
(mac_initialize) [!MAC_OSX]: Don't call MakeMeTheFrontProcess.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macterm.c | 78 |
1 files changed, 54 insertions, 24 deletions
diff --git a/src/macterm.c b/src/macterm.c index 3e8bbd5033c..a06b8f8da79 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -34,12 +34,12 @@ Boston, MA 02111-1307, USA. */ | |||
| 34 | #include <alloca.h> | 34 | #include <alloca.h> |
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifdef MAC_OSX | 37 | #if TARGET_API_MAC_CARBON |
| 38 | /* USE_CARBON_EVENTS determines if the Carbon Event Manager is used to | 38 | /* USE_CARBON_EVENTS determines if the Carbon Event Manager is used to |
| 39 | obtain events from the event queue. If set to 0, WaitNextEvent is | 39 | obtain events from the event queue. If set to 0, WaitNextEvent is |
| 40 | used instead. */ | 40 | used instead. */ |
| 41 | #define USE_CARBON_EVENTS 1 | 41 | #define USE_CARBON_EVENTS 1 |
| 42 | #else /* not MAC_OSX */ | 42 | #else /* not TARGET_API_MAC_CARBON */ |
| 43 | #include <Quickdraw.h> | 43 | #include <Quickdraw.h> |
| 44 | #include <ToolUtils.h> | 44 | #include <ToolUtils.h> |
| 45 | #include <Sound.h> | 45 | #include <Sound.h> |
| @@ -58,7 +58,7 @@ Boston, MA 02111-1307, USA. */ | |||
| 58 | #if __profile__ | 58 | #if __profile__ |
| 59 | #include <profiler.h> | 59 | #include <profiler.h> |
| 60 | #endif | 60 | #endif |
| 61 | #endif /* not MAC_OSX */ | 61 | #endif /* not TARGET_API_MAC_CARBON */ |
| 62 | 62 | ||
| 63 | #include "systty.h" | 63 | #include "systty.h" |
| 64 | #include "systime.h" | 64 | #include "systime.h" |
| @@ -245,7 +245,7 @@ extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *)); | |||
| 245 | 245 | ||
| 246 | extern int inhibit_window_system; | 246 | extern int inhibit_window_system; |
| 247 | 247 | ||
| 248 | #if __MRC__ | 248 | #if __MRC__ && !TARGET_API_MAC_CARBON |
| 249 | QDGlobals qd; /* QuickDraw global information structure. */ | 249 | QDGlobals qd; /* QuickDraw global information structure. */ |
| 250 | #endif | 250 | #endif |
| 251 | 251 | ||
| @@ -5574,6 +5574,9 @@ x_free_frame_resources (f) | |||
| 5574 | 5574 | ||
| 5575 | BLOCK_INPUT; | 5575 | BLOCK_INPUT; |
| 5576 | 5576 | ||
| 5577 | if (wp != tip_window) | ||
| 5578 | remove_window_handler (wp); | ||
| 5579 | |||
| 5577 | DisposeWindow (wp); | 5580 | DisposeWindow (wp); |
| 5578 | if (wp == tip_window) | 5581 | if (wp == tip_window) |
| 5579 | /* Neither WaitNextEvent nor ReceiveNextEvent receives `window | 5582 | /* Neither WaitNextEvent nor ReceiveNextEvent receives `window |
| @@ -7078,7 +7081,7 @@ x_find_ccl_program (fontp) | |||
| 7078 | 7081 | ||
| 7079 | /* The Mac Event loop code */ | 7082 | /* The Mac Event loop code */ |
| 7080 | 7083 | ||
| 7081 | #ifndef MAC_OSX | 7084 | #if !TARGET_API_MAC_CARBON |
| 7082 | #include <Events.h> | 7085 | #include <Events.h> |
| 7083 | #include <Quickdraw.h> | 7086 | #include <Quickdraw.h> |
| 7084 | #include <Balloons.h> | 7087 | #include <Balloons.h> |
| @@ -7099,7 +7102,7 @@ x_find_ccl_program (fontp) | |||
| 7099 | #if __MWERKS__ | 7102 | #if __MWERKS__ |
| 7100 | #include <unix.h> | 7103 | #include <unix.h> |
| 7101 | #endif | 7104 | #endif |
| 7102 | #endif /* ! MAC_OSX */ | 7105 | #endif /* ! TARGET_API_MAC_CARBON */ |
| 7103 | 7106 | ||
| 7104 | #define M_APPLE 128 | 7107 | #define M_APPLE 128 |
| 7105 | #define I_ABOUT 1 | 7108 | #define I_ABOUT 1 |
| @@ -7200,12 +7203,16 @@ static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); | |||
| 7200 | /* Drag and Drop */ | 7203 | /* Drag and Drop */ |
| 7201 | static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference); | 7204 | static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference); |
| 7202 | static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); | 7205 | static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); |
| 7206 | static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; | ||
| 7207 | static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; | ||
| 7203 | #endif | 7208 | #endif |
| 7204 | 7209 | ||
| 7205 | #if USE_CARBON_EVENTS | 7210 | #if USE_CARBON_EVENTS |
| 7211 | #ifdef MAC_OSX | ||
| 7206 | /* Preliminary Support for the OSX Services Menu */ | 7212 | /* Preliminary Support for the OSX Services Menu */ |
| 7207 | static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*); | 7213 | static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*); |
| 7208 | static void init_service_handler (); | 7214 | static void init_service_handler (); |
| 7215 | #endif | ||
| 7209 | /* Window Event Handler */ | 7216 | /* Window Event Handler */ |
| 7210 | static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, | 7217 | static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, |
| 7211 | EventRef, void *); | 7218 | EventRef, void *); |
| @@ -7844,7 +7851,7 @@ init_required_apple_events () | |||
| 7844 | } | 7851 | } |
| 7845 | 7852 | ||
| 7846 | #if USE_CARBON_EVENTS | 7853 | #if USE_CARBON_EVENTS |
| 7847 | 7854 | #ifdef MAC_OSX | |
| 7848 | void | 7855 | void |
| 7849 | init_service_handler () | 7856 | init_service_handler () |
| 7850 | { | 7857 | { |
| @@ -7940,7 +7947,7 @@ mac_handle_service_event (EventHandlerCallRef callRef, | |||
| 7940 | } | 7947 | } |
| 7941 | return err; | 7948 | return err; |
| 7942 | } | 7949 | } |
| 7943 | 7950 | #endif | |
| 7944 | 7951 | ||
| 7945 | static pascal OSStatus | 7952 | static pascal OSStatus |
| 7946 | mac_handle_window_event (next_handler, event, data) | 7953 | mac_handle_window_event (next_handler, event, data) |
| @@ -8037,14 +8044,30 @@ install_window_handler (window) | |||
| 8037 | NULL, NULL); | 8044 | NULL, NULL); |
| 8038 | #endif | 8045 | #endif |
| 8039 | #if TARGET_API_MAC_CARBON | 8046 | #if TARGET_API_MAC_CARBON |
| 8047 | if (mac_do_track_dragUPP == NULL) | ||
| 8048 | mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag); | ||
| 8049 | if (mac_do_receive_dragUPP == NULL) | ||
| 8050 | mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag); | ||
| 8051 | |||
| 8040 | if (err == noErr) | 8052 | if (err == noErr) |
| 8041 | err = InstallTrackingHandler (mac_do_track_drag, window, NULL); | 8053 | err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL); |
| 8042 | if (err == noErr) | 8054 | if (err == noErr) |
| 8043 | err = InstallReceiveHandler (mac_do_receive_drag, window, NULL); | 8055 | err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL); |
| 8044 | #endif | 8056 | #endif |
| 8045 | return err; | 8057 | return err; |
| 8046 | } | 8058 | } |
| 8047 | 8059 | ||
| 8060 | void | ||
| 8061 | remove_window_handler (window) | ||
| 8062 | WindowPtr window; | ||
| 8063 | { | ||
| 8064 | #if TARGET_API_MAC_CARBON | ||
| 8065 | if (mac_do_track_dragUPP) | ||
| 8066 | RemoveTrackingHandler (mac_do_track_dragUPP, window); | ||
| 8067 | if (mac_do_receive_dragUPP) | ||
| 8068 | RemoveReceiveHandler (mac_do_receive_dragUPP, window); | ||
| 8069 | #endif | ||
| 8070 | } | ||
| 8048 | 8071 | ||
| 8049 | /* Open Application Apple Event */ | 8072 | /* Open Application Apple Event */ |
| 8050 | static pascal OSErr | 8073 | static pascal OSErr |
| @@ -8123,9 +8146,9 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon) | |||
| 8123 | /* AE file list is one based so just use that for indexing here. */ | 8146 | /* AE file list is one based so just use that for indexing here. */ |
| 8124 | for (i = 1; i <= num_files_to_open; i++) | 8147 | for (i = 1; i <= num_files_to_open; i++) |
| 8125 | { | 8148 | { |
| 8149 | char unix_path_name[MAXPATHLEN]; | ||
| 8126 | #ifdef MAC_OSX | 8150 | #ifdef MAC_OSX |
| 8127 | FSRef fref; | 8151 | FSRef fref; |
| 8128 | char unix_path_name[MAXPATHLEN]; | ||
| 8129 | 8152 | ||
| 8130 | err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword, | 8153 | err = AEGetNthPtr (&the_desc, i, typeFSRef, &keyword, |
| 8131 | &actual_type, &fref, sizeof (FSRef), | 8154 | &actual_type, &fref, sizeof (FSRef), |
| @@ -8137,15 +8160,13 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon) | |||
| 8137 | == noErr) | 8160 | == noErr) |
| 8138 | #else | 8161 | #else |
| 8139 | FSSpec fs; | 8162 | FSSpec fs; |
| 8140 | Str255 path_name, unix_path_name; | ||
| 8141 | 8163 | ||
| 8142 | err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type, | 8164 | err = AEGetNthPtr(&the_desc, i, typeFSS, &keyword, &actual_type, |
| 8143 | (Ptr) &fs, sizeof (fs), &actual_size); | 8165 | (Ptr) &fs, sizeof (fs), &actual_size); |
| 8144 | if (err != noErr) continue; | 8166 | if (err != noErr) continue; |
| 8145 | 8167 | ||
| 8146 | if (path_from_vol_dir_name (path_name, 255, fs.vRefNum, fs.parID, | 8168 | if (fsspec_to_posix_pathname (&fs, unix_path_name, |
| 8147 | fs.name) && | 8169 | sizeof (unix_path_name) - 1) == noErr) |
| 8148 | mac_to_posix_pathname (path_name, unix_path_name, 255)) | ||
| 8149 | #endif | 8170 | #endif |
| 8150 | /* x-dnd functions expect undecoded filenames. */ | 8171 | /* x-dnd functions expect undecoded filenames. */ |
| 8151 | drag_and_drop_file_list = | 8172 | drag_and_drop_file_list = |
| @@ -8264,10 +8285,9 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | |||
| 8264 | { | 8285 | { |
| 8265 | #ifdef MAC_OSX | 8286 | #ifdef MAC_OSX |
| 8266 | FSRef fref; | 8287 | FSRef fref; |
| 8267 | char unix_path_name[MAXPATHLEN]; | ||
| 8268 | #else | ||
| 8269 | Str255 path_name, unix_path_name; | ||
| 8270 | #endif | 8288 | #endif |
| 8289 | char unix_path_name[MAXPATHLEN]; | ||
| 8290 | |||
| 8271 | GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); | 8291 | GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); |
| 8272 | #ifdef MAC_OSX | 8292 | #ifdef MAC_OSX |
| 8273 | /* Use Carbon routines, otherwise it converts the file name | 8293 | /* Use Carbon routines, otherwise it converts the file name |
| @@ -8275,9 +8295,8 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | |||
| 8275 | FSpMakeFSRef (&data.fileSpec, &fref); | 8295 | FSpMakeFSRef (&data.fileSpec, &fref); |
| 8276 | if (! FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))); | 8296 | if (! FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))); |
| 8277 | #else | 8297 | #else |
| 8278 | if (path_from_vol_dir_name (path_name, 255, data.fileSpec.vRefNum, | 8298 | if (fsspec_to_posix_pathname (&data.fileSpec, unix_path_name, |
| 8279 | data.fileSpec.parID, data.fileSpec.name) && | 8299 | sizeof (unix_path_name) - 1) == noErr) |
| 8280 | mac_to_posix_pathname (path_name, unix_path_name, 255)) | ||
| 8281 | #endif | 8300 | #endif |
| 8282 | /* x-dnd functions expect undecoded filenames. */ | 8301 | /* x-dnd functions expect undecoded filenames. */ |
| 8283 | drag_and_drop_file_list = | 8302 | drag_and_drop_file_list = |
| @@ -8374,7 +8393,7 @@ profiler_exit_proc () | |||
| 8374 | hints and prompts in the minibuffer after the user stops typing for | 8393 | hints and prompts in the minibuffer after the user stops typing for |
| 8375 | a wait, etc. */ | 8394 | a wait, etc. */ |
| 8376 | 8395 | ||
| 8377 | #if !TARGET_API_MAC_CARBON | 8396 | #ifdef MAC_OS8 |
| 8378 | #undef main | 8397 | #undef main |
| 8379 | int | 8398 | int |
| 8380 | main (void) | 8399 | main (void) |
| @@ -8956,7 +8975,7 @@ XTread_socket (sd, expected, hold_quit) | |||
| 8956 | int keycode = (er.message & keyCodeMask) >> 8; | 8975 | int keycode = (er.message & keyCodeMask) >> 8; |
| 8957 | int xkeysym; | 8976 | int xkeysym; |
| 8958 | 8977 | ||
| 8959 | #if USE_CARBON_EVENTS | 8978 | #if USE_CARBON_EVENTS && defined (MAC_OSX) |
| 8960 | /* When using Carbon Events, we need to pass raw keyboard | 8979 | /* When using Carbon Events, we need to pass raw keyboard |
| 8961 | events to the TSM ourselves. If TSM handles it, it | 8980 | events to the TSM ourselves. If TSM handles it, it |
| 8962 | will pass back noErr, otherwise it will pass back | 8981 | will pass back noErr, otherwise it will pass back |
| @@ -9265,12 +9284,21 @@ make_mac_terminal_frame (struct frame *f) | |||
| 9265 | f->output_data.mac->mouse_pixel = 0xff00ff; | 9284 | f->output_data.mac->mouse_pixel = 0xff00ff; |
| 9266 | f->output_data.mac->cursor_foreground_pixel = 0x0000ff; | 9285 | f->output_data.mac->cursor_foreground_pixel = 0x0000ff; |
| 9267 | 9286 | ||
| 9287 | #if TARGET_API_MAC_CARBON | ||
| 9288 | f->output_data.mac->text_cursor = kThemeIBeamCursor; | ||
| 9289 | f->output_data.mac->nontext_cursor = kThemeArrowCursor; | ||
| 9290 | f->output_data.mac->modeline_cursor = kThemeArrowCursor; | ||
| 9291 | f->output_data.mac->hand_cursor = kThemePointingHandCursor; | ||
| 9292 | f->output_data.mac->hourglass_cursor = kThemeWatchCursor; | ||
| 9293 | f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor; | ||
| 9294 | #else | ||
| 9268 | f->output_data.mac->text_cursor = GetCursor (iBeamCursor); | 9295 | f->output_data.mac->text_cursor = GetCursor (iBeamCursor); |
| 9269 | f->output_data.mac->nontext_cursor = &arrow_cursor; | 9296 | f->output_data.mac->nontext_cursor = &arrow_cursor; |
| 9270 | f->output_data.mac->modeline_cursor = &arrow_cursor; | 9297 | f->output_data.mac->modeline_cursor = &arrow_cursor; |
| 9271 | f->output_data.mac->hand_cursor = &arrow_cursor; | 9298 | f->output_data.mac->hand_cursor = &arrow_cursor; |
| 9272 | f->output_data.mac->hourglass_cursor = GetCursor (watchCursor); | 9299 | f->output_data.mac->hourglass_cursor = GetCursor (watchCursor); |
| 9273 | f->output_data.mac->horizontal_drag_cursor = &arrow_cursor; | 9300 | f->output_data.mac->horizontal_drag_cursor = &arrow_cursor; |
| 9301 | #endif | ||
| 9274 | 9302 | ||
| 9275 | FRAME_FONTSET (f) = -1; | 9303 | FRAME_FONTSET (f) = -1; |
| 9276 | f->output_data.mac->explicit_parent = 0; | 9304 | f->output_data.mac->explicit_parent = 0; |
| @@ -9805,7 +9833,7 @@ mac_initialize () | |||
| 9805 | #if TARGET_API_MAC_CARBON | 9833 | #if TARGET_API_MAC_CARBON |
| 9806 | init_required_apple_events (); | 9834 | init_required_apple_events (); |
| 9807 | 9835 | ||
| 9808 | #if USE_CARBON_EVENTS | 9836 | #if USE_CARBON_EVENTS && defined (MAC_OSX) |
| 9809 | init_service_handler (); | 9837 | init_service_handler (); |
| 9810 | 9838 | ||
| 9811 | init_quit_char_handler (); | 9839 | init_quit_char_handler (); |
| @@ -9813,9 +9841,11 @@ mac_initialize () | |||
| 9813 | 9841 | ||
| 9814 | DisableMenuCommand (NULL, kHICommandQuit); | 9842 | DisableMenuCommand (NULL, kHICommandQuit); |
| 9815 | 9843 | ||
| 9844 | #ifdef MAC_OSX | ||
| 9816 | if (!inhibit_window_system) | 9845 | if (!inhibit_window_system) |
| 9817 | MakeMeTheFrontProcess (); | 9846 | MakeMeTheFrontProcess (); |
| 9818 | #endif | 9847 | #endif |
| 9848 | #endif | ||
| 9819 | UNBLOCK_INPUT; | 9849 | UNBLOCK_INPUT; |
| 9820 | } | 9850 | } |
| 9821 | 9851 | ||