diff options
| author | Andrew Choi | 2002-08-03 22:21:09 +0000 |
|---|---|---|
| committer | Andrew Choi | 2002-08-03 22:21:09 +0000 |
| commit | 742fbed75b4cd5c2c2e7a8d4c0f4add9957e7f9a (patch) | |
| tree | 2d119dccd908ef943fd9343fbaa646808dc3e0e4 /src | |
| parent | 365417014078a0f260fd24d41845aeb274b876c8 (diff) | |
| download | emacs-742fbed75b4cd5c2c2e7a8d4c0f4add9957e7f9a.tar.gz emacs-742fbed75b4cd5c2c2e7a8d4c0f4add9957e7f9a.zip | |
In src:
2002-08-03 Andrew Choi <akochoi@shaw.ca>
* macterm.c (USE_CARBON_EVENTS): New macro.
(macCtrlKey, macShiftKey, macMetaKey, macAltKey): New macros.
(x_iconify_frame): Call CollapseWindow.
(Vmac_reverse_ctrl_meta): New variable.
(Vmac_wheel_button_is_mouse_2): New variable.
(init_mac_drag_n_drop): New function.
(mac_do_receive_drag): New function.
(mac_handle_service_event): New function.
(init_service_handler): New function.
(mac_to_emacs_modifiers): New function.
(mac_event_to_emacs_modifiers): New function.
(mac_get_mouse_btn): New function.
(mac_convert_event_ref): New function.
(XTread_socket) [USE_CARBON_EVENTS]: Call ReceiveNextEvent,
SendEventToEventTarget, mac_event_to_emacs_modifiers, and
mac_get_mouse_btn.
(mac_initialize): Call init_mac_drag_n_drop and
init_service_handler.
* keyboard.c: Define Qmouse_wheel, mouse_wheel_syms, and
lispy_mouse_wheel_names for MAC_OSX as well as for WINDOWS_NT.
(kbd_buffer_get_event): Set used_mouse_menu for MENU_BAR_EVENT and
TOOL_BAR_EVENT for MAC_OS as well.
(make_lispy_event): Handle MOUSE_WHEEL_EVENT for MAC_OSX as well
as for WINDOWS_NT.
(syms_of_keyboard): Initialize Qmouse_wheel for MAC_OSX.
* termhooks.h (event_kind): Define MOUSE_WHEEL_EVENT also for
MAC_OSX.
In lisp:
2002-08-03 Andrew Choi <akochoi@shaw.ca>
* term/mac-win.el: Set keys to enable mouse wheel support.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 32 | ||||
| -rw-r--r-- | src/keyboard.c | 23 | ||||
| -rw-r--r-- | src/macterm.c | 590 | ||||
| -rw-r--r-- | src/termhooks.h | 6 |
4 files changed, 512 insertions, 139 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 9169ddc7fe4..c69c37ce504 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,35 @@ | |||
| 1 | 2002-08-03 Andrew Choi <akochoi@shaw.ca> | ||
| 2 | |||
| 3 | * macterm.c (USE_CARBON_EVENTS): New macro. | ||
| 4 | (macCtrlKey, macShiftKey, macMetaKey, macAltKey): New macros. | ||
| 5 | (x_iconify_frame): Call CollapseWindow. | ||
| 6 | (Vmac_reverse_ctrl_meta): New variable. | ||
| 7 | (Vmac_wheel_button_is_mouse_2): New variable. | ||
| 8 | (init_mac_drag_n_drop): New function. | ||
| 9 | (mac_do_receive_drag): New function. | ||
| 10 | (mac_handle_service_event): New function. | ||
| 11 | (init_service_handler): New function. | ||
| 12 | (mac_to_emacs_modifiers): New function. | ||
| 13 | (mac_event_to_emacs_modifiers): New function. | ||
| 14 | (mac_get_mouse_btn): New function. | ||
| 15 | (mac_convert_event_ref): New function. | ||
| 16 | (XTread_socket) [USE_CARBON_EVENTS]: Call ReceiveNextEvent, | ||
| 17 | SendEventToEventTarget, mac_event_to_emacs_modifiers, and | ||
| 18 | mac_get_mouse_btn. | ||
| 19 | (mac_initialize): Call init_mac_drag_n_drop and | ||
| 20 | init_service_handler. | ||
| 21 | |||
| 22 | * keyboard.c: Define Qmouse_wheel, mouse_wheel_syms, and | ||
| 23 | lispy_mouse_wheel_names for MAC_OSX as well as for WINDOWS_NT. | ||
| 24 | (kbd_buffer_get_event): Set used_mouse_menu for MENU_BAR_EVENT and | ||
| 25 | TOOL_BAR_EVENT for MAC_OS as well. | ||
| 26 | (make_lispy_event): Handle MOUSE_WHEEL_EVENT for MAC_OSX as well | ||
| 27 | as for WINDOWS_NT. | ||
| 28 | (syms_of_keyboard): Initialize Qmouse_wheel for MAC_OSX. | ||
| 29 | |||
| 30 | * termhooks.h (event_kind): Define MOUSE_WHEEL_EVENT also for | ||
| 31 | MAC_OSX. | ||
| 32 | |||
| 1 | 2002-08-03 Gerd Moellmann <gerd.moellmann@t-online.de> | 33 | 2002-08-03 Gerd Moellmann <gerd.moellmann@t-online.de> |
| 2 | 34 | ||
| 3 | * xdisp.c (forward_to_next_line_start): Fix a condition that | 35 | * xdisp.c (forward_to_next_line_start): Fix a condition that |
diff --git a/src/keyboard.c b/src/keyboard.c index ce20d57913d..6c45139d80e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -550,8 +550,10 @@ Lisp_Object Qhelp_echo; | |||
| 550 | /* Symbols to denote kinds of events. */ | 550 | /* Symbols to denote kinds of events. */ |
| 551 | Lisp_Object Qfunction_key; | 551 | Lisp_Object Qfunction_key; |
| 552 | Lisp_Object Qmouse_click; | 552 | Lisp_Object Qmouse_click; |
| 553 | #ifdef WINDOWSNT | 553 | #if defined(WINDOWSNT) || defined(MAC_OSX) |
| 554 | Lisp_Object Qmouse_wheel; | 554 | Lisp_Object Qmouse_wheel; |
| 555 | #endif | ||
| 556 | #ifdef WINDOWSNT | ||
| 555 | Lisp_Object Qlanguage_change; | 557 | Lisp_Object Qlanguage_change; |
| 556 | #endif | 558 | #endif |
| 557 | Lisp_Object Qdrag_n_drop; | 559 | Lisp_Object Qdrag_n_drop; |
| @@ -644,7 +646,7 @@ int flow_control; | |||
| 644 | 646 | ||
| 645 | /* If we support a window system, turn on the code to poll periodically | 647 | /* If we support a window system, turn on the code to poll periodically |
| 646 | to detect C-g. It isn't actually used when doing interrupt input. */ | 648 | to detect C-g. It isn't actually used when doing interrupt input. */ |
| 647 | #ifdef HAVE_WINDOW_SYSTEM | 649 | #if defined(HAVE_WINDOW_SYSTEM) && !defined(USE_ASYNC_EVENTS) |
| 648 | #define POLL_FOR_INPUT | 650 | #define POLL_FOR_INPUT |
| 649 | #endif | 651 | #endif |
| 650 | 652 | ||
| @@ -3881,7 +3883,7 @@ kbd_buffer_get_event (kbp, used_mouse_menu) | |||
| 3881 | { | 3883 | { |
| 3882 | obj = make_lispy_event (event); | 3884 | obj = make_lispy_event (event); |
| 3883 | 3885 | ||
| 3884 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) | 3886 | #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) || defined(MAC_OS) |
| 3885 | /* If this was a menu selection, then set the flag to inhibit | 3887 | /* If this was a menu selection, then set the flag to inhibit |
| 3886 | writing to last_nonmenu_event. Don't do this if the event | 3888 | writing to last_nonmenu_event. Don't do this if the event |
| 3887 | we're returning is (menu-bar), though; that indicates the | 3889 | we're returning is (menu-bar), though; that indicates the |
| @@ -4260,7 +4262,7 @@ timer_check (do_it_now) | |||
| 4260 | static Lisp_Object accent_key_syms; | 4262 | static Lisp_Object accent_key_syms; |
| 4261 | static Lisp_Object func_key_syms; | 4263 | static Lisp_Object func_key_syms; |
| 4262 | static Lisp_Object mouse_syms; | 4264 | static Lisp_Object mouse_syms; |
| 4263 | #ifdef WINDOWSNT | 4265 | #if defined(WINDOWSNT) || defined(MAC_OSX) |
| 4264 | static Lisp_Object mouse_wheel_syms; | 4266 | static Lisp_Object mouse_wheel_syms; |
| 4265 | #endif | 4267 | #endif |
| 4266 | static Lisp_Object drag_n_drop_syms; | 4268 | static Lisp_Object drag_n_drop_syms; |
| @@ -4669,7 +4671,7 @@ static char *iso_lispy_function_keys[] = | |||
| 4669 | 4671 | ||
| 4670 | Lisp_Object Vlispy_mouse_stem; | 4672 | Lisp_Object Vlispy_mouse_stem; |
| 4671 | 4673 | ||
| 4672 | #ifdef WINDOWSNT | 4674 | #if defined(WINDOWSNT) || defined(MAC_OSX) |
| 4673 | /* mouse-wheel events are generated by the wheel on devices such as | 4675 | /* mouse-wheel events are generated by the wheel on devices such as |
| 4674 | the MS Intellimouse. The wheel sits in between the left and right | 4676 | the MS Intellimouse. The wheel sits in between the left and right |
| 4675 | mouse buttons, and is typically used to scroll or zoom the window | 4677 | mouse buttons, and is typically used to scroll or zoom the window |
| @@ -5279,6 +5281,8 @@ make_lispy_event (event) | |||
| 5279 | Qnil)); | 5281 | Qnil)); |
| 5280 | } | 5282 | } |
| 5281 | } | 5283 | } |
| 5284 | #endif /* WINDOWS_NT */ | ||
| 5285 | #if defined(WINDOWS_NT) || defined(MAC_OSX) | ||
| 5282 | case MOUSE_WHEEL_EVENT: | 5286 | case MOUSE_WHEEL_EVENT: |
| 5283 | { | 5287 | { |
| 5284 | int part; | 5288 | int part; |
| @@ -5350,7 +5354,7 @@ make_lispy_event (event) | |||
| 5350 | Qnil)))); | 5354 | Qnil)))); |
| 5351 | } | 5355 | } |
| 5352 | } | 5356 | } |
| 5353 | #endif /* WINDOWSNT */ | 5357 | #endif /* WINDOWSNT || MAC_OSX */ |
| 5354 | 5358 | ||
| 5355 | case DRAG_N_DROP_EVENT: | 5359 | case DRAG_N_DROP_EVENT: |
| 5356 | { | 5360 | { |
| @@ -10433,9 +10437,11 @@ syms_of_keyboard () | |||
| 10433 | staticpro (&Qfunction_key); | 10437 | staticpro (&Qfunction_key); |
| 10434 | Qmouse_click = intern ("mouse-click"); | 10438 | Qmouse_click = intern ("mouse-click"); |
| 10435 | staticpro (&Qmouse_click); | 10439 | staticpro (&Qmouse_click); |
| 10436 | #ifdef WINDOWSNT | 10440 | #if defined(WINDOWSNT) || defined(MAC_OSX) |
| 10437 | Qmouse_wheel = intern ("mouse-wheel"); | 10441 | Qmouse_wheel = intern ("mouse-wheel"); |
| 10438 | staticpro (&Qmouse_wheel); | 10442 | staticpro (&Qmouse_wheel); |
| 10443 | #endif | ||
| 10444 | #ifdef WINDOWSNT | ||
| 10439 | Qlanguage_change = intern ("language-change"); | 10445 | Qlanguage_change = intern ("language-change"); |
| 10440 | staticpro (&Qlanguage_change); | 10446 | staticpro (&Qlanguage_change); |
| 10441 | #endif | 10447 | #endif |
| @@ -10583,10 +10589,9 @@ syms_of_keyboard () | |||
| 10583 | func_key_syms = Qnil; | 10589 | func_key_syms = Qnil; |
| 10584 | staticpro (&func_key_syms); | 10590 | staticpro (&func_key_syms); |
| 10585 | 10591 | ||
| 10586 | #ifdef WINDOWSNT | 10592 | #if defined(WINDOWSNT) || defined(MAC_OSX) |
| 10587 | mouse_wheel_syms = Qnil; | 10593 | mouse_wheel_syms = Qnil; |
| 10588 | staticpro (&mouse_wheel_syms); | 10594 | staticpro (&mouse_wheel_syms); |
| 10589 | |||
| 10590 | drag_n_drop_syms = Qnil; | 10595 | drag_n_drop_syms = Qnil; |
| 10591 | staticpro (&drag_n_drop_syms); | 10596 | staticpro (&drag_n_drop_syms); |
| 10592 | #endif | 10597 | #endif |
diff --git a/src/macterm.c b/src/macterm.c index c471ba4bf35..c00c288001c 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -58,6 +58,10 @@ Boston, MA 02111-1307, USA. */ | |||
| 58 | #define max(a, b) ((a) > (b) ? (a) : (b)) | 58 | #define max(a, b) ((a) > (b) ? (a) : (b)) |
| 59 | #undef init_process | 59 | #undef init_process |
| 60 | #define init_process emacs_init_process | 60 | #define init_process emacs_init_process |
| 61 | /* USE_CARBON_EVENTS determines if the Carbon Event Manager is used to | ||
| 62 | obtain events from the event queue. If set to 0, WaitNextEvent is | ||
| 63 | used instead. */ | ||
| 64 | #define USE_CARBON_EVENTS 1 | ||
| 61 | #else /* not MAC_OSX */ | 65 | #else /* not MAC_OSX */ |
| 62 | #include <Quickdraw.h> | 66 | #include <Quickdraw.h> |
| 63 | #include <ToolUtils.h> | 67 | #include <ToolUtils.h> |
| @@ -106,6 +110,15 @@ Boston, MA 02111-1307, USA. */ | |||
| 106 | 110 | ||
| 107 | #define BETWEEN(X, LOWER, UPPER) ((X) >= (LOWER) && (X) < (UPPER)) | 111 | #define BETWEEN(X, LOWER, UPPER) ((X) >= (LOWER) && (X) < (UPPER)) |
| 108 | 112 | ||
| 113 | /* Set of macros that handle mapping of Mac modifier keys to emacs. */ | ||
| 114 | #define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \ | ||
| 115 | (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey)) | ||
| 116 | #define macShiftKey (shiftKey) | ||
| 117 | #define macMetaKey (NILP (Vmac_reverse_ctrl_meta) ? \ | ||
| 118 | (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \ | ||
| 119 | : controlKey) | ||
| 120 | #define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) | ||
| 121 | |||
| 109 | 122 | ||
| 110 | /* Fringe bitmaps. */ | 123 | /* Fringe bitmaps. */ |
| 111 | 124 | ||
| @@ -10092,108 +10105,21 @@ void | |||
| 10092 | x_iconify_frame (f) | 10105 | x_iconify_frame (f) |
| 10093 | struct frame *f; | 10106 | struct frame *f; |
| 10094 | { | 10107 | { |
| 10095 | #if 0 /* MAC_TODO: really no iconify on Mac */ | ||
| 10096 | int result; | ||
| 10097 | Lisp_Object type; | ||
| 10098 | |||
| 10099 | /* Don't keep the highlight on an invisible frame. */ | 10108 | /* Don't keep the highlight on an invisible frame. */ |
| 10100 | if (FRAME_X_DISPLAY_INFO (f)->x_highlight_frame == f) | 10109 | if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f) |
| 10101 | FRAME_X_DISPLAY_INFO (f)->x_highlight_frame = 0; | 10110 | FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0; |
| 10102 | 10111 | ||
| 10112 | #if 0 | ||
| 10113 | /* Review: Since window is still visible in dock, still allow updates? */ | ||
| 10103 | if (f->async_iconified) | 10114 | if (f->async_iconified) |
| 10104 | return; | 10115 | return; |
| 10116 | #endif | ||
| 10105 | 10117 | ||
| 10106 | BLOCK_INPUT; | 10118 | BLOCK_INPUT; |
| 10107 | 10119 | ||
| 10108 | FRAME_SAMPLE_VISIBILITY (f); | 10120 | CollapseWindow (FRAME_MAC_WINDOW (f), true); |
| 10109 | 10121 | ||
| 10110 | type = x_icon_type (f); | ||
| 10111 | if (!NILP (type)) | ||
| 10112 | x_bitmap_icon (f, type); | ||
| 10113 | |||
| 10114 | #ifdef USE_X_TOOLKIT | ||
| 10115 | |||
| 10116 | if (! FRAME_VISIBLE_P (f)) | ||
| 10117 | { | ||
| 10118 | if (! EQ (Vx_no_window_manager, Qt)) | ||
| 10119 | x_wm_set_window_state (f, IconicState); | ||
| 10120 | /* This was XtPopup, but that did nothing for an iconified frame. */ | ||
| 10121 | XtMapWidget (f->output_data.x->widget); | ||
| 10122 | /* The server won't give us any event to indicate | ||
| 10123 | that an invisible frame was changed to an icon, | ||
| 10124 | so we have to record it here. */ | ||
| 10125 | f->iconified = 1; | ||
| 10126 | f->visible = 1; | ||
| 10127 | f->async_iconified = 1; | ||
| 10128 | f->async_visible = 0; | ||
| 10129 | UNBLOCK_INPUT; | ||
| 10130 | return; | ||
| 10131 | } | ||
| 10132 | |||
| 10133 | result = XIconifyWindow (FRAME_X_DISPLAY (f), | ||
| 10134 | XtWindow (f->output_data.x->widget), | ||
| 10135 | DefaultScreen (FRAME_X_DISPLAY (f))); | ||
| 10136 | UNBLOCK_INPUT; | ||
| 10137 | |||
| 10138 | if (!result) | ||
| 10139 | error ("Can't notify window manager of iconification"); | ||
| 10140 | |||
| 10141 | f->async_iconified = 1; | ||
| 10142 | f->async_visible = 0; | ||
| 10143 | |||
| 10144 | |||
| 10145 | BLOCK_INPUT; | ||
| 10146 | XFlush (FRAME_X_DISPLAY (f)); | ||
| 10147 | UNBLOCK_INPUT; | ||
| 10148 | #else /* not USE_X_TOOLKIT */ | ||
| 10149 | |||
| 10150 | /* Make sure the X server knows where the window should be positioned, | ||
| 10151 | in case the user deiconifies with the window manager. */ | ||
| 10152 | if (! FRAME_VISIBLE_P (f) && !FRAME_ICONIFIED_P (f)) | ||
| 10153 | x_set_offset (f, f->output_data.x->left_pos, f->output_data.x->top_pos, 0); | ||
| 10154 | |||
| 10155 | /* Since we don't know which revision of X we're running, we'll use both | ||
| 10156 | the X11R3 and X11R4 techniques. I don't know if this is a good idea. */ | ||
| 10157 | |||
| 10158 | /* X11R4: send a ClientMessage to the window manager using the | ||
| 10159 | WM_CHANGE_STATE type. */ | ||
| 10160 | { | ||
| 10161 | XEvent message; | ||
| 10162 | |||
| 10163 | message.xclient.window = FRAME_X_WINDOW (f); | ||
| 10164 | message.xclient.type = ClientMessage; | ||
| 10165 | message.xclient.message_type = FRAME_X_DISPLAY_INFO (f)->Xatom_wm_change_state; | ||
| 10166 | message.xclient.format = 32; | ||
| 10167 | message.xclient.data.l[0] = IconicState; | ||
| 10168 | |||
| 10169 | if (! XSendEvent (FRAME_X_DISPLAY (f), | ||
| 10170 | DefaultRootWindow (FRAME_X_DISPLAY (f)), | ||
| 10171 | False, | ||
| 10172 | SubstructureRedirectMask | SubstructureNotifyMask, | ||
| 10173 | &message)) | ||
| 10174 | { | ||
| 10175 | UNBLOCK_INPUT_RESIGNAL; | ||
| 10176 | error ("Can't notify window manager of iconification"); | ||
| 10177 | } | ||
| 10178 | } | ||
| 10179 | |||
| 10180 | /* X11R3: set the initial_state field of the window manager hints to | ||
| 10181 | IconicState. */ | ||
| 10182 | x_wm_set_window_state (f, IconicState); | ||
| 10183 | |||
| 10184 | if (!FRAME_VISIBLE_P (f)) | ||
| 10185 | { | ||
| 10186 | /* If the frame was withdrawn, before, we must map it. */ | ||
| 10187 | XMapRaised (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); | ||
| 10188 | } | ||
| 10189 | |||
| 10190 | f->async_iconified = 1; | ||
| 10191 | f->async_visible = 0; | ||
| 10192 | |||
| 10193 | XFlush (FRAME_X_DISPLAY (f)); | ||
| 10194 | UNBLOCK_INPUT; | 10122 | UNBLOCK_INPUT; |
| 10195 | #endif /* not USE_X_TOOLKIT */ | ||
| 10196 | #endif /* MAC_TODO */ | ||
| 10197 | } | 10123 | } |
| 10198 | 10124 | ||
| 10199 | 10125 | ||
| @@ -11560,9 +11486,18 @@ static long app_sleep_time = WNE_SLEEP_AT_RESUME; | |||
| 11560 | 11486 | ||
| 11561 | Boolean terminate_flag = false; | 11487 | Boolean terminate_flag = false; |
| 11562 | 11488 | ||
| 11563 | /* true if using command key as meta key */ | 11489 | /* True if using command key as meta key. */ |
| 11564 | Lisp_Object Vmac_command_key_is_meta; | 11490 | Lisp_Object Vmac_command_key_is_meta; |
| 11565 | 11491 | ||
| 11492 | /* True if the ctrl and meta keys should be reversed. */ | ||
| 11493 | Lisp_Object Vmac_reverse_ctrl_meta; | ||
| 11494 | |||
| 11495 | #if USE_CARBON_EVENTS | ||
| 11496 | /* True if the mouse wheel button (i.e. button 4) should map to | ||
| 11497 | mouse-2, instead of mouse-3. */ | ||
| 11498 | Lisp_Object Vmac_wheel_button_is_mouse_2; | ||
| 11499 | #endif | ||
| 11500 | |||
| 11566 | /* convert input from Mac keyboard (assumed to be in Mac Roman coding) | 11501 | /* convert input from Mac keyboard (assumed to be in Mac Roman coding) |
| 11567 | to this text encoding */ | 11502 | to this text encoding */ |
| 11568 | int mac_keyboard_text_encoding; | 11503 | int mac_keyboard_text_encoding; |
| @@ -11577,13 +11512,23 @@ Lisp_Object drag_and_drop_file_list; | |||
| 11577 | Point saved_menu_event_location; | 11512 | Point saved_menu_event_location; |
| 11578 | 11513 | ||
| 11579 | /* Apple Events */ | 11514 | /* Apple Events */ |
| 11580 | static void init_required_apple_events(void); | 11515 | static void init_required_apple_events (void); |
| 11581 | static pascal OSErr | 11516 | static pascal OSErr |
| 11582 | do_ae_open_application(const AppleEvent *, AppleEvent *, long); | 11517 | do_ae_open_application (const AppleEvent *, AppleEvent *, long); |
| 11583 | static pascal OSErr | 11518 | static pascal OSErr |
| 11584 | do_ae_print_documents(const AppleEvent *, AppleEvent *, long); | 11519 | do_ae_print_documents (const AppleEvent *, AppleEvent *, long); |
| 11585 | static pascal OSErr do_ae_open_documents(AppleEvent *, AppleEvent *, long); | 11520 | static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long); |
| 11586 | static pascal OSErr do_ae_quit_application(AppleEvent *, AppleEvent *, long); | 11521 | static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long); |
| 11522 | |||
| 11523 | /* Drag and Drop */ | ||
| 11524 | static OSErr init_mac_drag_n_drop (); | ||
| 11525 | static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); | ||
| 11526 | |||
| 11527 | #if USE_CARBON_EVENTS | ||
| 11528 | /* Preliminary Support for the OSX Services Menu */ | ||
| 11529 | static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*); | ||
| 11530 | static void init_service_handler (); | ||
| 11531 | #endif | ||
| 11587 | 11532 | ||
| 11588 | extern void init_emacs_passwd_dir (); | 11533 | extern void init_emacs_passwd_dir (); |
| 11589 | extern int emacs_main (int, char **, char **); | 11534 | extern int emacs_main (int, char **, char **); |
| @@ -11592,6 +11537,104 @@ extern void check_alarm (); | |||
| 11592 | extern void initialize_applescript(); | 11537 | extern void initialize_applescript(); |
| 11593 | extern void terminate_applescript(); | 11538 | extern void terminate_applescript(); |
| 11594 | 11539 | ||
| 11540 | static unsigned int | ||
| 11541 | #if USE_CARBON_EVENTS | ||
| 11542 | mac_to_emacs_modifiers (UInt32 mods) | ||
| 11543 | #else | ||
| 11544 | mac_to_emacs_modifiers (EventModifiers mods) | ||
| 11545 | #endif | ||
| 11546 | { | ||
| 11547 | unsigned int result = 0; | ||
| 11548 | if (mods & macShiftKey) | ||
| 11549 | result |= shift_modifier; | ||
| 11550 | if (mods & macCtrlKey) | ||
| 11551 | result |= ctrl_modifier; | ||
| 11552 | if (mods & macMetaKey) | ||
| 11553 | result |= meta_modifier; | ||
| 11554 | if (NILP (Vmac_command_key_is_meta) && (mods & macAltKey)) | ||
| 11555 | result |= alt_modifier; | ||
| 11556 | return result; | ||
| 11557 | } | ||
| 11558 | |||
| 11559 | #if USE_CARBON_EVENTS | ||
| 11560 | /* Obtains the event modifiers from the event ref and then calls | ||
| 11561 | mac_to_emacs_modifiers. */ | ||
| 11562 | static int | ||
| 11563 | mac_event_to_emacs_modifiers (EventRef eventRef) | ||
| 11564 | { | ||
| 11565 | UInt32 mods = 0; | ||
| 11566 | GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, | ||
| 11567 | sizeof (UInt32), NULL, &mods); | ||
| 11568 | return mac_to_emacs_modifiers (mods); | ||
| 11569 | } | ||
| 11570 | |||
| 11571 | /* Given an event ref, return the code to use for the mouse button | ||
| 11572 | code in the emacs input_event. */ | ||
| 11573 | static int | ||
| 11574 | mac_get_mouse_btn (EventRef ref) | ||
| 11575 | { | ||
| 11576 | EventMouseButton result = kEventMouseButtonPrimary; | ||
| 11577 | GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL, | ||
| 11578 | sizeof (EventMouseButton), NULL, &result); | ||
| 11579 | switch (result) | ||
| 11580 | { | ||
| 11581 | case kEventMouseButtonPrimary: | ||
| 11582 | return 0; | ||
| 11583 | case kEventMouseButtonSecondary: | ||
| 11584 | return NILP (Vmac_wheel_button_is_mouse_2) ? 2 : 1; | ||
| 11585 | case kEventMouseButtonTertiary: | ||
| 11586 | case 4: /* 4 is the number for the mouse wheel button */ | ||
| 11587 | return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2; | ||
| 11588 | default: | ||
| 11589 | return 0; | ||
| 11590 | } | ||
| 11591 | } | ||
| 11592 | |||
| 11593 | /* Normally, ConvertEventRefToEventRecord will correctly handle all | ||
| 11594 | events. However the click of the mouse wheel is not converted to a | ||
| 11595 | mouseDown or mouseUp event. This calls ConvertEventRef, but then | ||
| 11596 | checks to see if it is a mouse up or down carbon event that has not | ||
| 11597 | been converted, and if so, converts it by hand (to be picked up in | ||
| 11598 | the XTread_socket loop). */ | ||
| 11599 | static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec) | ||
| 11600 | { | ||
| 11601 | Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec); | ||
| 11602 | /* Do special case for mouse wheel button. */ | ||
| 11603 | if (!result && GetEventClass (eventRef) == kEventClassMouse) | ||
| 11604 | { | ||
| 11605 | UInt32 kind = GetEventKind (eventRef); | ||
| 11606 | if (kind == kEventMouseDown && !(eventRec->what == mouseDown)) | ||
| 11607 | { | ||
| 11608 | eventRec->what = mouseDown; | ||
| 11609 | result=1; | ||
| 11610 | } | ||
| 11611 | if (kind == kEventMouseUp && !(eventRec->what == mouseUp)) | ||
| 11612 | { | ||
| 11613 | eventRec->what = mouseUp; | ||
| 11614 | result=1; | ||
| 11615 | } | ||
| 11616 | if (result) | ||
| 11617 | { | ||
| 11618 | /* Need where and when. */ | ||
| 11619 | UInt32 mods; | ||
| 11620 | GetEventParameter (eventRef, kEventParamMouseLocation, | ||
| 11621 | typeQDPoint, NULL, sizeof (Point), | ||
| 11622 | NULL, &eventRec->where); | ||
| 11623 | /* Use two step process because new event modifiers are | ||
| 11624 | 32-bit and old are 16-bit. Currently, only loss is | ||
| 11625 | NumLock & Fn. */ | ||
| 11626 | GetEventParameter (eventRef, kEventParamKeyModifiers, | ||
| 11627 | typeUInt32, NULL, sizeof (UInt32), | ||
| 11628 | NULL, &mods); | ||
| 11629 | eventRec->modifiers = mods; | ||
| 11630 | |||
| 11631 | eventRec->when = EventTimeToTicks (GetEventTime (eventRef)); | ||
| 11632 | } | ||
| 11633 | } | ||
| 11634 | return result; | ||
| 11635 | } | ||
| 11636 | |||
| 11637 | #endif | ||
| 11595 | 11638 | ||
| 11596 | static void | 11639 | static void |
| 11597 | do_get_menus (void) | 11640 | do_get_menus (void) |
| @@ -12019,6 +12062,13 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 12019 | SetPort (save_port); | 12062 | SetPort (save_port); |
| 12020 | } | 12063 | } |
| 12021 | 12064 | ||
| 12065 | /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ | ||
| 12066 | static OSErr | ||
| 12067 | init_mac_drag_n_drop () | ||
| 12068 | { | ||
| 12069 | OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL); | ||
| 12070 | return result; | ||
| 12071 | } | ||
| 12022 | 12072 | ||
| 12023 | /* Intialize AppleEvent dispatcher table for the required events. */ | 12073 | /* Intialize AppleEvent dispatcher table for the required events. */ |
| 12024 | void | 12074 | void |
| @@ -12092,6 +12142,102 @@ init_required_apple_events () | |||
| 12092 | abort (); | 12142 | abort (); |
| 12093 | } | 12143 | } |
| 12094 | 12144 | ||
| 12145 | #if USE_CARBON_EVENTS | ||
| 12146 | |||
| 12147 | void init_service_handler() | ||
| 12148 | { | ||
| 12149 | EventTypeSpec specs[] = {{kEventClassService, kEventServiceGetTypes}, | ||
| 12150 | {kEventClassService, kEventServiceCopy}, | ||
| 12151 | {kEventClassService, kEventServicePaste}}; | ||
| 12152 | InstallApplicationEventHandler (NewEventHandlerUPP (mac_handle_service_event), | ||
| 12153 | 3, specs, NULL, NULL); | ||
| 12154 | } | ||
| 12155 | |||
| 12156 | /* | ||
| 12157 | MAC_TODO: Check to see if this is called by AEProcessDesc... | ||
| 12158 | */ | ||
| 12159 | OSStatus mac_handle_service_event (EventHandlerCallRef callRef, | ||
| 12160 | EventRef event, void *data) | ||
| 12161 | { | ||
| 12162 | OSStatus err = noErr; | ||
| 12163 | switch (GetEventKind (event)) | ||
| 12164 | { | ||
| 12165 | case kEventServiceGetTypes: | ||
| 12166 | { | ||
| 12167 | CFMutableArrayRef copyTypes, pasteTypes; | ||
| 12168 | CFStringRef type; | ||
| 12169 | Boolean selection = true; | ||
| 12170 | /* | ||
| 12171 | GetEventParameter(event, kEventParamServicePasteTypes, | ||
| 12172 | typeCFMutableArrayRef, NULL, | ||
| 12173 | sizeof (CFMutableArrayRef), NULL, &pasteTypes); | ||
| 12174 | */ | ||
| 12175 | GetEventParameter(event, kEventParamServiceCopyTypes, | ||
| 12176 | typeCFMutableArrayRef, NULL, | ||
| 12177 | sizeof (CFMutableArrayRef), NULL, ©Types); | ||
| 12178 | type = CreateTypeStringWithOSType (kScrapFlavorTypeText); | ||
| 12179 | if (type) { | ||
| 12180 | CFArrayAppendValue (copyTypes, type); | ||
| 12181 | //CFArrayAppendValue (pasteTypes, type); | ||
| 12182 | CFRelease (type); | ||
| 12183 | } | ||
| 12184 | } | ||
| 12185 | case kEventServiceCopy: | ||
| 12186 | { | ||
| 12187 | ScrapRef currentScrap, specificScrap; | ||
| 12188 | char * buf = ""; | ||
| 12189 | Size byteCount = 0; | ||
| 12190 | |||
| 12191 | GetCurrentScrap (¤tScrap); | ||
| 12192 | |||
| 12193 | err = GetScrapFlavorSize (currentScrap, kScrapFlavorTypeText, &byteCount); | ||
| 12194 | if (err == noErr) | ||
| 12195 | { | ||
| 12196 | void *buffer = xmalloc (byteCount); | ||
| 12197 | if (buffer != NULL) | ||
| 12198 | { | ||
| 12199 | GetEventParameter (event, kEventParamScrapRef, typeScrapRef, NULL, | ||
| 12200 | sizeof (ScrapRef), NULL, &specificScrap); | ||
| 12201 | |||
| 12202 | err = GetScrapFlavorData (currentScrap, kScrapFlavorTypeText, | ||
| 12203 | &byteCount, buffer); | ||
| 12204 | if (err == noErr) | ||
| 12205 | PutScrapFlavor (specificScrap, kScrapFlavorTypeText, | ||
| 12206 | kScrapFlavorMaskNone, byteCount, buffer); | ||
| 12207 | xfree (buffer); | ||
| 12208 | } | ||
| 12209 | } | ||
| 12210 | err = noErr; | ||
| 12211 | } | ||
| 12212 | case kEventServicePaste: | ||
| 12213 | { | ||
| 12214 | /* | ||
| 12215 | // Get the current location | ||
| 12216 | Size byteCount; | ||
| 12217 | ScrapRef specificScrap; | ||
| 12218 | GetEventParameter(event, kEventParamScrapRef, typeScrapRef, NULL, | ||
| 12219 | sizeof(ScrapRef), NULL, &specificScrap); | ||
| 12220 | err = GetScrapFlavorSize(specificScrap, kScrapFlavorTypeText, &byteCount); | ||
| 12221 | if (err == noErr) { | ||
| 12222 | void * buffer = xmalloc(byteCount); | ||
| 12223 | if (buffer != NULL ) { | ||
| 12224 | err = GetScrapFlavorData(specificScrap, kScrapFlavorTypeText, | ||
| 12225 | &byteCount, buffer); | ||
| 12226 | if (err == noErr) { | ||
| 12227 | // Actually place in the buffer | ||
| 12228 | BLOCK_INPUT; | ||
| 12229 | // Get the current "selection" string here | ||
| 12230 | UNBLOCK_INPUT; | ||
| 12231 | } | ||
| 12232 | } | ||
| 12233 | xfree(buffer); | ||
| 12234 | } | ||
| 12235 | */ | ||
| 12236 | } | ||
| 12237 | } | ||
| 12238 | return err; | ||
| 12239 | } | ||
| 12240 | #endif | ||
| 12095 | 12241 | ||
| 12096 | /* Open Application Apple Event */ | 12242 | /* Open Application Apple Event */ |
| 12097 | static pascal OSErr | 12243 | static pascal OSErr |
| @@ -12187,6 +12333,83 @@ descriptor_error_exit: | |||
| 12187 | } | 12333 | } |
| 12188 | 12334 | ||
| 12189 | 12335 | ||
| 12336 | static pascal OSErr mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | ||
| 12337 | DragReference theDrag) | ||
| 12338 | { | ||
| 12339 | short items; | ||
| 12340 | short index; | ||
| 12341 | FlavorFlags theFlags; | ||
| 12342 | Point mouse; | ||
| 12343 | OSErr result; | ||
| 12344 | ItemReference theItem; | ||
| 12345 | HFSFlavor data; | ||
| 12346 | FSRef fref; | ||
| 12347 | Size size = sizeof (HFSFlavor); | ||
| 12348 | |||
| 12349 | drag_and_drop_file_list = Qnil; | ||
| 12350 | GetDragMouse (theDrag, &mouse, 0L); | ||
| 12351 | CountDragItems (theDrag, &items); | ||
| 12352 | for (index = 1; index <= items; index++) | ||
| 12353 | { | ||
| 12354 | /* Only handle file references. */ | ||
| 12355 | GetDragItemReferenceNumber (theDrag, index, &theItem); | ||
| 12356 | result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); | ||
| 12357 | if (result == noErr) | ||
| 12358 | { | ||
| 12359 | #ifdef MAC_OSX | ||
| 12360 | FSRef frref; | ||
| 12361 | #else | ||
| 12362 | Str255 path_name; | ||
| 12363 | #endif | ||
| 12364 | Str255 unix_path_name; | ||
| 12365 | GetFlavorData (theDrag, theItem, flavorTypeHFS, &data, &size, 0L); | ||
| 12366 | #ifdef MAC_OSX | ||
| 12367 | /* Use Carbon routines, otherwise it converts the file name | ||
| 12368 | to /Macintosh HD/..., which is not correct. */ | ||
| 12369 | FSpMakeFSRef (&data.fileSpec, &fref); | ||
| 12370 | if (! FSRefMakePath (&fref, unix_path_name, sizeof (unix_path_name))); | ||
| 12371 | #else | ||
| 12372 | if (path_from_vol_dir_name (path_name, 255, data.fileSpec.vRefNum, | ||
| 12373 | data.fileSpec.parID, data.fileSpec.name) && | ||
| 12374 | mac_to_posix_pathname (path_name, unix_path_name, 255)) | ||
| 12375 | #endif | ||
| 12376 | drag_and_drop_file_list = Fcons (build_string (unix_path_name), | ||
| 12377 | drag_and_drop_file_list); | ||
| 12378 | } | ||
| 12379 | else | ||
| 12380 | return; | ||
| 12381 | } | ||
| 12382 | /* If there are items in the list, construct an event and post it to | ||
| 12383 | the queue like an interrupt using kbd_buffer_store_event. */ | ||
| 12384 | if (!NILP (drag_and_drop_file_list)) | ||
| 12385 | { | ||
| 12386 | struct input_event event; | ||
| 12387 | Lisp_Object frame; | ||
| 12388 | struct frame *f = ((mac_output *) GetWRefCon(window))->mFP; | ||
| 12389 | SetPort (GetWindowPort (window)); | ||
| 12390 | GlobalToLocal (&mouse); | ||
| 12391 | |||
| 12392 | event.kind = DRAG_N_DROP_EVENT; | ||
| 12393 | event.code = 0; | ||
| 12394 | event.modifiers = 0; | ||
| 12395 | event.timestamp = TickCount () * (1000 / 60); | ||
| 12396 | XSETINT (event.x, mouse.h); | ||
| 12397 | XSETINT (event.y, mouse.v); | ||
| 12398 | XSETFRAME (frame, f); | ||
| 12399 | event.frame_or_window = Fcons (frame, drag_and_drop_file_list); | ||
| 12400 | event.arg = Qnil; | ||
| 12401 | /* Post to the interrupt queue */ | ||
| 12402 | kbd_buffer_store_event (&event); | ||
| 12403 | /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */ | ||
| 12404 | { | ||
| 12405 | ProcessSerialNumber psn; | ||
| 12406 | GetCurrentProcess (&psn); | ||
| 12407 | SetFrontProcess (&psn); | ||
| 12408 | } | ||
| 12409 | } | ||
| 12410 | } | ||
| 12411 | |||
| 12412 | |||
| 12190 | /* Print Document Apple Event */ | 12413 | /* Print Document Apple Event */ |
| 12191 | static pascal OSErr | 12414 | static pascal OSErr |
| 12192 | do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon) | 12415 | do_ae_print_documents (const AppleEvent *pAE, AppleEvent *reply, long refcon) |
| @@ -12334,7 +12557,12 @@ keycode_to_xkeysym (int keyCode, int *xKeySym) | |||
| 12334 | int | 12557 | int |
| 12335 | XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | 12558 | XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) |
| 12336 | { | 12559 | { |
| 12337 | int count = 0; | 12560 | int count = 0; |
| 12561 | #if USE_CARBON_EVENTS | ||
| 12562 | OSStatus rneResult; | ||
| 12563 | EventRef eventRef; | ||
| 12564 | EventMouseButton mouseBtn; | ||
| 12565 | #endif | ||
| 12338 | EventRecord er; | 12566 | EventRecord er; |
| 12339 | int the_modifiers; | 12567 | int the_modifiers; |
| 12340 | EventMask event_mask; | 12568 | EventMask event_mask; |
| @@ -12380,7 +12608,52 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12380 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) | 12608 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) |
| 12381 | event_mask -= highLevelEventMask; | 12609 | event_mask -= highLevelEventMask; |
| 12382 | 12610 | ||
| 12611 | #if USE_CARBON_EVENTS | ||
| 12612 | rneResult = ReceiveNextEvent (0, NULL, | ||
| 12613 | expected ? TicksToEventTime(app_sleep_time) : 0, | ||
| 12614 | true, &eventRef); | ||
| 12615 | if (!rneResult) | ||
| 12616 | { | ||
| 12617 | /* Handle new events */ | ||
| 12618 | if (!mac_convert_event_ref (eventRef, &er)) | ||
| 12619 | switch (GetEventClass (eventRef)) | ||
| 12620 | { | ||
| 12621 | case kEventClassMouse: | ||
| 12622 | if (GetEventKind (eventRef) == kEventMouseWheelMoved) | ||
| 12623 | { | ||
| 12624 | SInt32 delta; | ||
| 12625 | Point point; | ||
| 12626 | WindowPtr window_ptr = FrontWindow (); | ||
| 12627 | struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | ||
| 12628 | GetEventParameter(eventRef, kEventParamMouseWheelDelta, | ||
| 12629 | typeSInt32, NULL, sizeof (SInt32), | ||
| 12630 | NULL, &delta); | ||
| 12631 | GetEventParameter(eventRef, kEventParamMouseLocation, | ||
| 12632 | typeQDPoint, NULL, sizeof (Point), | ||
| 12633 | NULL, &point); | ||
| 12634 | bufp->kind = MOUSE_WHEEL_EVENT; | ||
| 12635 | bufp->code = delta; | ||
| 12636 | bufp->modifiers = mac_event_to_emacs_modifiers(eventRef); | ||
| 12637 | SetPort (GetWindowPort (window_ptr)); | ||
| 12638 | GlobalToLocal (&point); | ||
| 12639 | XSETINT (bufp->x, point.h); | ||
| 12640 | XSETINT (bufp->y, point.v); | ||
| 12641 | XSETFRAME (bufp->frame_or_window, mwp->mFP); | ||
| 12642 | bufp->timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); | ||
| 12643 | count++; | ||
| 12644 | } | ||
| 12645 | else | ||
| 12646 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | ||
| 12647 | |||
| 12648 | break; | ||
| 12649 | default: | ||
| 12650 | /* Send the event to the appropriate receiver. */ | ||
| 12651 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | ||
| 12652 | } | ||
| 12653 | else | ||
| 12654 | #else | ||
| 12383 | if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL)) | 12655 | if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL)) |
| 12656 | #endif /* USE_CARBON_EVENTS */ | ||
| 12384 | switch (er.what) | 12657 | switch (er.what) |
| 12385 | { | 12658 | { |
| 12386 | case mouseDown: | 12659 | case mouseDown: |
| @@ -12389,6 +12662,11 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12389 | WindowPtr window_ptr = FrontWindow (); | 12662 | WindowPtr window_ptr = FrontWindow (); |
| 12390 | SInt16 part_code; | 12663 | SInt16 part_code; |
| 12391 | 12664 | ||
| 12665 | #if USE_CARBON_EVENTS | ||
| 12666 | /* This is needed to correctly */ | ||
| 12667 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | ||
| 12668 | #endif | ||
| 12669 | |||
| 12392 | if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | 12670 | if (mouse_tracking_in_progress == mouse_tracking_scroll_bar |
| 12393 | && er.what == mouseUp) | 12671 | && er.what == mouseUp) |
| 12394 | { | 12672 | { |
| @@ -12404,11 +12682,20 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12404 | 12682 | ||
| 12405 | GlobalToLocal (&mouse_loc); | 12683 | GlobalToLocal (&mouse_loc); |
| 12406 | 12684 | ||
| 12685 | #if USE_CARBON_EVENTS | ||
| 12686 | bufp->code = mac_get_mouse_btn (eventRef); | ||
| 12687 | #else | ||
| 12407 | bufp->code = 0; /* only one mouse button */ | 12688 | bufp->code = 0; /* only one mouse button */ |
| 12689 | #endif | ||
| 12408 | bufp->kind = SCROLL_BAR_CLICK_EVENT; | 12690 | bufp->kind = SCROLL_BAR_CLICK_EVENT; |
| 12409 | bufp->frame_or_window = tracked_scroll_bar->window; | 12691 | bufp->frame_or_window = tracked_scroll_bar->window; |
| 12410 | bufp->part = scroll_bar_handle; | 12692 | bufp->part = scroll_bar_handle; |
| 12411 | bufp->modifiers = up_modifier; | 12693 | #if USE_CARBON_EVENTS |
| 12694 | bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); | ||
| 12695 | #else | ||
| 12696 | bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); | ||
| 12697 | #endif | ||
| 12698 | bufp->modifiers |= up_modifier; | ||
| 12412 | bufp->timestamp = er.when * (1000 / 60); | 12699 | bufp->timestamp = er.when * (1000 / 60); |
| 12413 | /* ticks to milliseconds */ | 12700 | /* ticks to milliseconds */ |
| 12414 | 12701 | ||
| @@ -12461,7 +12748,12 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12461 | #else | 12748 | #else |
| 12462 | control_part_code = FindControl (mouse_loc, window_ptr, &ch); | 12749 | control_part_code = FindControl (mouse_loc, window_ptr, &ch); |
| 12463 | #endif | 12750 | #endif |
| 12751 | |||
| 12752 | #if USE_CARBON_EVENTS | ||
| 12753 | bufp->code = mac_get_mouse_btn (eventRef); | ||
| 12754 | #else | ||
| 12464 | bufp->code = 0; /* only one mouse button */ | 12755 | bufp->code = 0; /* only one mouse button */ |
| 12756 | #endif | ||
| 12465 | XSETINT (bufp->x, mouse_loc.h); | 12757 | XSETINT (bufp->x, mouse_loc.h); |
| 12466 | XSETINT (bufp->y, mouse_loc.v); | 12758 | XSETINT (bufp->y, mouse_loc.v); |
| 12467 | bufp->timestamp = er.when * (1000 / 60); | 12759 | bufp->timestamp = er.when * (1000 / 60); |
| @@ -12501,13 +12793,19 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12501 | mouse_tracking_in_progress = mouse_tracking_none; | 12793 | mouse_tracking_in_progress = mouse_tracking_none; |
| 12502 | } | 12794 | } |
| 12503 | 12795 | ||
| 12796 | #if USE_CARBON_EVENTS | ||
| 12797 | bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); | ||
| 12798 | #else | ||
| 12799 | bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); | ||
| 12800 | #endif | ||
| 12801 | |||
| 12504 | switch (er.what) | 12802 | switch (er.what) |
| 12505 | { | 12803 | { |
| 12506 | case mouseDown: | 12804 | case mouseDown: |
| 12507 | bufp->modifiers = down_modifier; | 12805 | bufp->modifiers |= down_modifier; |
| 12508 | break; | 12806 | break; |
| 12509 | case mouseUp: | 12807 | case mouseUp: |
| 12510 | bufp->modifiers = up_modifier; | 12808 | bufp->modifiers |= up_modifier; |
| 12511 | break; | 12809 | break; |
| 12512 | } | 12810 | } |
| 12513 | 12811 | ||
| @@ -12559,6 +12857,9 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12559 | case updateEvt: | 12857 | case updateEvt: |
| 12560 | case osEvt: | 12858 | case osEvt: |
| 12561 | case activateEvt: | 12859 | case activateEvt: |
| 12860 | #if USE_CARBON_EVENTS | ||
| 12861 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | ||
| 12862 | #endif | ||
| 12562 | do_events (&er); | 12863 | do_events (&er); |
| 12563 | break; | 12864 | break; |
| 12564 | 12865 | ||
| @@ -12579,11 +12880,21 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12579 | { | 12880 | { |
| 12580 | bufp->code = 0xff00 | xkeysym; | 12881 | bufp->code = 0xff00 | xkeysym; |
| 12581 | bufp->kind = NON_ASCII_KEYSTROKE_EVENT; | 12882 | bufp->kind = NON_ASCII_KEYSTROKE_EVENT; |
| 12582 | } | 12883 | } |
| 12884 | else if (!NILP (Vmac_reverse_ctrl_meta) && (er.modifiers & controlKey)) | ||
| 12885 | { | ||
| 12886 | /* This is a special case to deal with converting from | ||
| 12887 | a control character to non-control character */ | ||
| 12888 | int new_modifiers = er.modifiers & ~controlKey; | ||
| 12889 | int new_keycode = keycode | new_modifiers; | ||
| 12890 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | ||
| 12891 | unsigned long some_state = 0; | ||
| 12892 | bufp->code = KeyTranslate (kchr_ptr, new_keycode, &some_state) & 0xff; | ||
| 12893 | bufp->kind = ASCII_KEYSTROKE_EVENT; | ||
| 12894 | } | ||
| 12583 | else | 12895 | else |
| 12584 | { | 12896 | { |
| 12585 | if (er.modifiers | 12897 | if (er.modifiers & macMetaKey) |
| 12586 | & (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey)) | ||
| 12587 | { | 12898 | { |
| 12588 | /* This code comes from Keyboard Resource, Appendix | 12899 | /* This code comes from Keyboard Resource, Appendix |
| 12589 | C of IM - Text. This is necessary since shift is | 12900 | C of IM - Text. This is necessary since shift is |
| @@ -12597,6 +12908,16 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12597 | bufp->code = KeyTranslate (kchr_ptr, new_keycode, | 12908 | bufp->code = KeyTranslate (kchr_ptr, new_keycode, |
| 12598 | &some_state) & 0xff; | 12909 | &some_state) & 0xff; |
| 12599 | } | 12910 | } |
| 12911 | #if USE_CARBON_EVENTS | ||
| 12912 | else if (er.modifiers & cmdKey && | ||
| 12913 | (NILP (Vmac_command_key_is_meta))) | ||
| 12914 | { | ||
| 12915 | /* If this is a command key (and we are not overriding it), | ||
| 12916 | send back to the operating system */ | ||
| 12917 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | ||
| 12918 | break; | ||
| 12919 | } | ||
| 12920 | #endif | ||
| 12600 | else | 12921 | else |
| 12601 | bufp->code = er.message & charCodeMask; | 12922 | bufp->code = er.message & charCodeMask; |
| 12602 | bufp->kind = ASCII_KEYSTROKE_EVENT; | 12923 | bufp->kind = ASCII_KEYSTROKE_EVENT; |
| @@ -12654,24 +12975,12 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12654 | } | 12975 | } |
| 12655 | } | 12976 | } |
| 12656 | 12977 | ||
| 12657 | the_modifiers = 0; | 12978 | #if USE_CARBON_EVENTS |
| 12658 | if (er.modifiers & shiftKey) | 12979 | bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); |
| 12659 | the_modifiers |= shift_modifier; | 12980 | #else |
| 12660 | if (er.modifiers & controlKey) | 12981 | bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); |
| 12661 | the_modifiers |= ctrl_modifier; | 12982 | #endif |
| 12662 | /* Use option or command key as meta depending on value of | 12983 | |
| 12663 | mac-command-key-is-meta. */ | ||
| 12664 | if (er.modifiers | ||
| 12665 | & (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey)) | ||
| 12666 | the_modifiers |= meta_modifier; | ||
| 12667 | |||
| 12668 | /* If the Mac option key is meta, then make Emacs recognize | ||
| 12669 | the Mac command key as alt. */ | ||
| 12670 | if (NILP (Vmac_command_key_is_meta) && (er.modifiers & cmdKey)) | ||
| 12671 | the_modifiers |= alt_modifier; | ||
| 12672 | |||
| 12673 | bufp->modifiers = the_modifiers; | ||
| 12674 | |||
| 12675 | { | 12984 | { |
| 12676 | mac_output *mwp | 12985 | mac_output *mwp |
| 12677 | = (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); | 12986 | = (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); |
| @@ -12706,7 +13015,11 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12706 | bufp->code = 0; | 13015 | bufp->code = 0; |
| 12707 | bufp->timestamp = er.when * (1000 / 60); | 13016 | bufp->timestamp = er.when * (1000 / 60); |
| 12708 | /* ticks to milliseconds */ | 13017 | /* ticks to milliseconds */ |
| 12709 | bufp->modifiers = 0; | 13018 | #if USE_CARBON_EVENTS |
| 13019 | bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); | ||
| 13020 | #else | ||
| 13021 | bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); | ||
| 13022 | #endif | ||
| 12710 | 13023 | ||
| 12711 | XSETINT (bufp->x, 0); | 13024 | XSETINT (bufp->x, 0); |
| 12712 | XSETINT (bufp->y, 0); | 13025 | XSETINT (bufp->y, 0); |
| @@ -12732,10 +13045,13 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) | |||
| 12732 | 13045 | ||
| 12733 | count++; | 13046 | count++; |
| 12734 | } | 13047 | } |
| 12735 | |||
| 12736 | default: | 13048 | default: |
| 12737 | break; | 13049 | break; |
| 12738 | } | 13050 | } |
| 13051 | #if USE_CARBON_EVENTS | ||
| 13052 | ReleaseEvent (eventRef); | ||
| 13053 | } | ||
| 13054 | #endif | ||
| 12739 | 13055 | ||
| 12740 | /* If the focus was just given to an autoraising frame, | 13056 | /* If the focus was just given to an autoraising frame, |
| 12741 | raise it now. */ | 13057 | raise it now. */ |
| @@ -12847,7 +13163,6 @@ NewMacWindow (FRAME_PTR fp) | |||
| 12847 | if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) | 13163 | if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) |
| 12848 | abort (); | 13164 | abort (); |
| 12849 | 13165 | ||
| 12850 | |||
| 12851 | SetWRefCon (mwp->mWP, (long) mwp); | 13166 | SetWRefCon (mwp->mWP, (long) mwp); |
| 12852 | /* so that update events can find this mac_output struct */ | 13167 | /* so that update events can find this mac_output struct */ |
| 12853 | mwp->mFP = fp; /* point back to emacs frame */ | 13168 | mwp->mFP = fp; /* point back to emacs frame */ |
| @@ -13183,6 +13498,12 @@ mac_initialize () | |||
| 13183 | #if TARGET_API_MAC_CARBON | 13498 | #if TARGET_API_MAC_CARBON |
| 13184 | init_required_apple_events (); | 13499 | init_required_apple_events (); |
| 13185 | 13500 | ||
| 13501 | init_mac_drag_n_drop (); | ||
| 13502 | |||
| 13503 | #if USE_CARBON_EVENTS | ||
| 13504 | init_service_handler (); | ||
| 13505 | #endif | ||
| 13506 | |||
| 13186 | DisableMenuCommand (NULL, kHICommandQuit); | 13507 | DisableMenuCommand (NULL, kHICommandQuit); |
| 13187 | #endif | 13508 | #endif |
| 13188 | } | 13509 | } |
| @@ -13253,6 +13574,19 @@ to 4.1, set this to nil. */); | |||
| 13253 | Otherwise the option key is used. */); | 13574 | Otherwise the option key is used. */); |
| 13254 | Vmac_command_key_is_meta = Qt; | 13575 | Vmac_command_key_is_meta = Qt; |
| 13255 | 13576 | ||
| 13577 | DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, | ||
| 13578 | doc: /* Non-nil means that the control and meta keys are reversed. This is | ||
| 13579 | useful for non-standard keyboard layouts. */); | ||
| 13580 | Vmac_reverse_ctrl_meta = Qnil; | ||
| 13581 | |||
| 13582 | #if USE_CARBON_EVENTS | ||
| 13583 | DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, | ||
| 13584 | doc: /* Non-nil means that the wheel button will be treated as mouse-2 and | ||
| 13585 | the right click will be mouse-3. | ||
| 13586 | Otherwise, the right click will be mouse-2 and the wheel button mouse-3.*/); | ||
| 13587 | Vmac_wheel_button_is_mouse_2 = Qt; | ||
| 13588 | #endif | ||
| 13589 | |||
| 13256 | DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding, | 13590 | DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding, |
| 13257 | doc: /* One of the Text Encoding Base constant values defined in the | 13591 | doc: /* One of the Text Encoding Base constant values defined in the |
| 13258 | Basic Text Constants section of Inside Macintosh - Text Encoding | 13592 | Basic Text Constants section of Inside Macintosh - Text Encoding |
diff --git a/src/termhooks.h b/src/termhooks.h index 63fa1f0ee3b..a479b5bdc1a 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -242,9 +242,9 @@ enum event_kind | |||
| 242 | the mouse click occurred in. | 242 | the mouse click occurred in. |
| 243 | .timestamp gives a timestamp (in | 243 | .timestamp gives a timestamp (in |
| 244 | milliseconds) for the click. */ | 244 | milliseconds) for the click. */ |
| 245 | #ifdef WINDOWSNT | 245 | #if defined(WINDOWSNT) || defined(MAC_OSX) |
| 246 | MOUSE_WHEEL_EVENT, /* A mouse-wheel event is generated | 246 | MOUSE_WHEEL_EVENT, /* A mouse-wheel event is generated |
| 247 | on WINDOWSNT by a | 247 | on WINDOWSNT or MAC_OSX by a |
| 248 | wheel on a mouse (e.g., MS Intellimouse). | 248 | wheel on a mouse (e.g., MS Intellimouse). |
| 249 | The event contains a delta that corresponds | 249 | The event contains a delta that corresponds |
| 250 | to the amount and direction that the wheel | 250 | to the amount and direction that the wheel |
| @@ -259,6 +259,8 @@ enum event_kind | |||
| 259 | the wheel event occurred in. | 259 | the wheel event occurred in. |
| 260 | .timestamp gives a timestamp (in | 260 | .timestamp gives a timestamp (in |
| 261 | milliseconds) for the wheel event. */ | 261 | milliseconds) for the wheel event. */ |
| 262 | #endif | ||
| 263 | #ifdef WINDOWSNT | ||
| 262 | LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is generated | 264 | LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is generated |
| 263 | on WINDOWSNT when the keyboard layout | 265 | on WINDOWSNT when the keyboard layout |
| 264 | or input language is changed by the | 266 | or input language is changed by the |