aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Tamm2004-02-15 17:16:18 +0000
committerSteven Tamm2004-02-15 17:16:18 +0000
commitdd4497dc1725ae27810b6bf368731eed110ccbc8 (patch)
tree56c9495e083623142e76d80240f92a569d1ca19f /src
parentbd2311318862b58d894bf84fa364d36b0b79041e (diff)
downloademacs-dd4497dc1725ae27810b6bf368731eed110ccbc8.tar.gz
emacs-dd4497dc1725ae27810b6bf368731eed110ccbc8.zip
(Vmac_emulate_three_button_mouse): New variable for
controlling emulation of a three button mouse with option and command keys. (Qreverse, mac_get_enumlated_btn): Handle the emulation (mac_event_to_emacs_modifiers, XTread_socket): Ditto
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/macterm.c53
2 files changed, 58 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 727dc366bec..44d64dbb964 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,11 @@
12004-02-15 Steven Tamm <steventamm@mac.com>
2
3 * macterm.c (Vmac_emulate_three_button_mouse): New variable for
4 controlling emulation of a three button mouse with option and
5 command keys.
6 (Qreverse, mac_get_enumlated_btn): Handle the emulation
7 (mac_event_to_emacs_modifiers, XTread_socket): Ditto
8
12004-02-15 Kim F. Storm <storm@cua.dk> 92004-02-15 Kim F. Storm <storm@cua.dk>
2 10
3 * fringe.c (init_fringe_bitmap) [MAC_OS, WORDS_BIG_ENDIAN]: 11 * fringe.c (init_fringe_bitmap) [MAC_OS, WORDS_BIG_ENDIAN]:
diff --git a/src/macterm.c b/src/macterm.c
index 3c1b33fa6dd..f6e5414c299 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -6463,12 +6463,19 @@ static long app_sleep_time = WNE_SLEEP_AT_RESUME;
6463 6463
6464Boolean terminate_flag = false; 6464Boolean terminate_flag = false;
6465 6465
6466/* Contains the string "reverse", which is a constant for mouse button emu.*/
6467Lisp_Object Qreverse;
6468
6466/* True if using command key as meta key. */ 6469/* True if using command key as meta key. */
6467Lisp_Object Vmac_command_key_is_meta; 6470Lisp_Object Vmac_command_key_is_meta;
6468 6471
6469/* True if the ctrl and meta keys should be reversed. */ 6472/* True if the ctrl and meta keys should be reversed. */
6470Lisp_Object Vmac_reverse_ctrl_meta; 6473Lisp_Object Vmac_reverse_ctrl_meta;
6471 6474
6475/* True if the option and command modifiers should be used to emulate
6476 a three button mouse */
6477Lisp_Object Vmac_emulate_three_button_mouse;
6478
6472#if USE_CARBON_EVENTS 6479#if USE_CARBON_EVENTS
6473/* True if the mouse wheel button (i.e. button 4) should map to 6480/* True if the mouse wheel button (i.e. button 4) should map to
6474 mouse-2, instead of mouse-3. */ 6481 mouse-2, instead of mouse-3. */
@@ -6541,6 +6548,20 @@ mac_to_emacs_modifiers (EventModifiers mods)
6541 return result; 6548 return result;
6542} 6549}
6543 6550
6551static int
6552mac_get_emulated_btn ( UInt32 modifiers )
6553{
6554 int result = 0;
6555 if (Vmac_emulate_three_button_mouse != Qnil) {
6556 int cmdIs3 = (Vmac_emulate_three_button_mouse != Qreverse);
6557 if (modifiers & controlKey)
6558 result = cmdIs3 ? 2 : 1;
6559 else if (modifiers & optionKey)
6560 result = cmdIs3 ? 1 : 2;
6561 }
6562 return result;
6563}
6564
6544#if USE_CARBON_EVENTS 6565#if USE_CARBON_EVENTS
6545/* Obtains the event modifiers from the event ref and then calls 6566/* Obtains the event modifiers from the event ref and then calls
6546 mac_to_emacs_modifiers. */ 6567 mac_to_emacs_modifiers. */
@@ -6550,6 +6571,11 @@ mac_event_to_emacs_modifiers (EventRef eventRef)
6550 UInt32 mods = 0; 6571 UInt32 mods = 0;
6551 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, 6572 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
6552 sizeof (UInt32), NULL, &mods); 6573 sizeof (UInt32), NULL, &mods);
6574 if (Vmac_emulate_three_button_mouse != Qnil &&
6575 GetEventClass(eventRef) == kEventClassMouse)
6576 {
6577 mods &= ~(optionKey & cmdKey);
6578 }
6553 return mac_to_emacs_modifiers (mods); 6579 return mac_to_emacs_modifiers (mods);
6554} 6580}
6555 6581
@@ -6564,7 +6590,14 @@ mac_get_mouse_btn (EventRef ref)
6564 switch (result) 6590 switch (result)
6565 { 6591 {
6566 case kEventMouseButtonPrimary: 6592 case kEventMouseButtonPrimary:
6567 return 0; 6593 if (Vmac_emulate_three_button_mouse == Qnil)
6594 return 0;
6595 else {
6596 UInt32 mods = 0;
6597 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
6598 sizeof (UInt32), NULL, &mods);
6599 return mac_get_emulated_btn(mods);
6600 }
6568 case kEventMouseButtonSecondary: 6601 case kEventMouseButtonSecondary:
6569 return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2; 6602 return NILP (Vmac_wheel_button_is_mouse_2) ? 1 : 2;
6570 case kEventMouseButtonTertiary: 6603 case kEventMouseButtonTertiary:
@@ -7700,7 +7733,7 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
7700#if USE_CARBON_EVENTS 7733#if USE_CARBON_EVENTS
7701 bufp->code = mac_get_mouse_btn (eventRef); 7734 bufp->code = mac_get_mouse_btn (eventRef);
7702#else 7735#else
7703 bufp->code = 0; /* only one mouse button */ 7736 bufp_.code = mac_get_emulate_btn (er.modifiers);
7704#endif 7737#endif
7705 bufp->kind = SCROLL_BAR_CLICK_EVENT; 7738 bufp->kind = SCROLL_BAR_CLICK_EVENT;
7706 bufp->frame_or_window = tracked_scroll_bar->window; 7739 bufp->frame_or_window = tracked_scroll_bar->window;
@@ -7768,7 +7801,7 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
7768#if USE_CARBON_EVENTS 7801#if USE_CARBON_EVENTS
7769 bufp->code = mac_get_mouse_btn (eventRef); 7802 bufp->code = mac_get_mouse_btn (eventRef);
7770#else 7803#else
7771 bufp->code = 0; /* only one mouse button */ 7804 bufp_.code = mac_get_emulate_btn (er.modifiers);
7772#endif 7805#endif
7773 XSETINT (bufp->x, mouse_loc.h); 7806 XSETINT (bufp->x, mouse_loc.h);
7774 XSETINT (bufp->y, mouse_loc.v); 7807 XSETINT (bufp->y, mouse_loc.v);
@@ -8645,6 +8678,9 @@ syms_of_macterm ()
8645 8678
8646 Fprovide (intern ("mac-carbon"), Qnil); 8679 Fprovide (intern ("mac-carbon"), Qnil);
8647 8680
8681 staticpro (&Qreverse);
8682 Qreverse = intern ("reverse");
8683
8648 staticpro (&x_display_name_list); 8684 staticpro (&x_display_name_list);
8649 x_display_name_list = Qnil; 8685 x_display_name_list = Qnil;
8650 8686
@@ -8689,6 +8725,17 @@ Otherwise the option key is used. */);
8689 useful for non-standard keyboard layouts. */); 8725 useful for non-standard keyboard layouts. */);
8690 Vmac_reverse_ctrl_meta = Qnil; 8726 Vmac_reverse_ctrl_meta = Qnil;
8691 8727
8728 DEFVAR_LISP ("mac-emulate-three-button-mouse",
8729 &Vmac_emulate_three_button_mouse,
8730 doc: /* t means that when the option-key is held down while pressing the
8731 mouse button, the click will register as mouse-2 and while the
8732 command-key is held down, the click will register as mouse-3.
8733 'reverse means that the the option-key will register for mouse-3
8734 and the command-key will register for mouse-2. nil means that
8735 not emulation should be done and the modifiers should be placed
8736 on the mouse-1 event. */);
8737 Vmac_emulate_three_button_mouse = Qnil;
8738
8692#if USE_CARBON_EVENTS 8739#if USE_CARBON_EVENTS
8693 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, 8740 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2,
8694 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and 8741 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and