Mercurial > emacs
comparison src/macterm.c @ 46860:8b7ade57211d
2002-08-11 Andrew Choi <akochoi@shaw.ca>
* macterm.c (XTmouse_position): Check wp with is_emacs_window.
(Vmac_pass_command_to_system): New variable.
(Vmac_pass_control_to_system): New variable.
(do_mouse_moved): Check wp with is_emacs_window.
(XTread_socket): Check window_ptr with is_emacs_window. Call
FrontNonFloatingWindow instead of FrontWindow. Send keydown
events back to Mac Toolbox for processing, depending on values of
Vmac_pass_command_to_system and Vmac_pass_control_to_system.
(syms_of_macterm): DEFVAR_LISP Vmac_pass_command_to_system and
Vmac_pass_control_to_system.
author | Andrew Choi <akochoi@shaw.ca> |
---|---|
date | Mon, 12 Aug 2002 04:33:59 +0000 |
parents | eba75fedd593 |
children | 085ca259e580 |
comparison
equal
deleted
inserted
replaced
46859:a26dd8891732 | 46860:8b7ade57211d |
---|---|
473 static void x_produce_stretch_glyph P_ ((struct it *)); | 473 static void x_produce_stretch_glyph P_ ((struct it *)); |
474 | 474 |
475 static void activate_scroll_bars (FRAME_PTR); | 475 static void activate_scroll_bars (FRAME_PTR); |
476 static void deactivate_scroll_bars (FRAME_PTR); | 476 static void deactivate_scroll_bars (FRAME_PTR); |
477 | 477 |
478 static int is_emacs_window (WindowPtr); | |
479 | |
478 extern int image_ascent (struct image *, struct face *); | 480 extern int image_ascent (struct image *, struct face *); |
479 void x_set_offset (struct frame *, int, int, int); | 481 void x_set_offset (struct frame *, int, int, int); |
480 int x_bitmap_icon (struct frame *, Lisp_Object); | 482 int x_bitmap_icon (struct frame *, Lisp_Object); |
481 void x_make_frame_visible (struct frame *); | 483 void x_make_frame_visible (struct frame *); |
482 | 484 |
8249 unsigned long *time; | 8251 unsigned long *time; |
8250 { | 8252 { |
8251 Point mouse_pos; | 8253 Point mouse_pos; |
8252 int ignore1, ignore2; | 8254 int ignore1, ignore2; |
8253 WindowPtr wp = FrontWindow (); | 8255 WindowPtr wp = FrontWindow (); |
8254 struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; | 8256 struct frame *f; |
8255 Lisp_Object frame, tail; | 8257 Lisp_Object frame, tail; |
8258 | |
8259 if (is_emacs_window(wp)) | |
8260 f = ((mac_output *) GetWRefCon (wp))->mFP; | |
8256 | 8261 |
8257 BLOCK_INPUT; | 8262 BLOCK_INPUT; |
8258 | 8263 |
8259 if (! NILP (last_mouse_scroll_bar) && insist == 0) | 8264 if (! NILP (last_mouse_scroll_bar) && insist == 0) |
8260 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); | 8265 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); |
11495 | 11500 |
11496 #if USE_CARBON_EVENTS | 11501 #if USE_CARBON_EVENTS |
11497 /* True if the mouse wheel button (i.e. button 4) should map to | 11502 /* True if the mouse wheel button (i.e. button 4) should map to |
11498 mouse-2, instead of mouse-3. */ | 11503 mouse-2, instead of mouse-3. */ |
11499 Lisp_Object Vmac_wheel_button_is_mouse_2; | 11504 Lisp_Object Vmac_wheel_button_is_mouse_2; |
11505 | |
11506 /* If Non-nil, the Mac "Command" key is passed on to the Mac Toolbox | |
11507 for processing before Emacs sees it. */ | |
11508 Lisp_Object Vmac_pass_command_to_system; | |
11509 | |
11510 /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox | |
11511 for processing before Emacs sees it. */ | |
11512 Lisp_Object Vmac_pass_control_to_system; | |
11500 #endif | 11513 #endif |
11501 | 11514 |
11502 /* convert input from Mac keyboard (assumed to be in Mac Roman coding) | 11515 /* convert input from Mac keyboard (assumed to be in Mac Roman coding) |
11503 to this text encoding */ | 11516 to this text encoding */ |
11504 int mac_keyboard_text_encoding; | 11517 int mac_keyboard_text_encoding; |
11838 | 11851 |
11839 static void | 11852 static void |
11840 do_mouse_moved (Point mouse_pos) | 11853 do_mouse_moved (Point mouse_pos) |
11841 { | 11854 { |
11842 WindowPtr wp = FrontWindow (); | 11855 WindowPtr wp = FrontWindow (); |
11843 struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; | 11856 struct frame *f; |
11844 | 11857 |
11858 if (is_emacs_window (wp)) | |
11859 { | |
11860 f = ((mac_output *) GetWRefCon (wp))->mFP; | |
11861 | |
11845 #if TARGET_API_MAC_CARBON | 11862 #if TARGET_API_MAC_CARBON |
11846 SetPort (GetWindowPort (wp)); | 11863 SetPort (GetWindowPort (wp)); |
11847 #else | 11864 #else |
11848 SetPort (wp); | 11865 SetPort (wp); |
11849 #endif | 11866 #endif |
11850 | 11867 |
11851 GlobalToLocal (&mouse_pos); | 11868 GlobalToLocal (&mouse_pos); |
11852 | 11869 |
11853 note_mouse_movement (f, &mouse_pos); | 11870 note_mouse_movement (f, &mouse_pos); |
11871 } | |
11854 } | 11872 } |
11855 | 11873 |
11856 | 11874 |
11857 static void | 11875 static void |
11858 do_os_event (EventRecord *erp) | 11876 do_os_event (EventRecord *erp) |
12624 case kEventClassMouse: | 12642 case kEventClassMouse: |
12625 if (GetEventKind (eventRef) == kEventMouseWheelMoved) | 12643 if (GetEventKind (eventRef) == kEventMouseWheelMoved) |
12626 { | 12644 { |
12627 SInt32 delta; | 12645 SInt32 delta; |
12628 Point point; | 12646 Point point; |
12629 WindowPtr window_ptr = FrontWindow (); | 12647 WindowPtr window_ptr = FrontNonFloatingWindow (); |
12630 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | 12648 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); |
12631 GetEventParameter(eventRef, kEventParamMouseWheelDelta, | 12649 GetEventParameter(eventRef, kEventParamMouseWheelDelta, |
12632 typeSInt32, NULL, sizeof (SInt32), | 12650 typeSInt32, NULL, sizeof (SInt32), |
12633 NULL, &delta); | 12651 NULL, &delta); |
12634 GetEventParameter(eventRef, kEventParamMouseLocation, | 12652 GetEventParameter(eventRef, kEventParamMouseLocation, |
12664 { | 12682 { |
12665 WindowPtr window_ptr = FrontWindow (); | 12683 WindowPtr window_ptr = FrontWindow (); |
12666 SInt16 part_code; | 12684 SInt16 part_code; |
12667 | 12685 |
12668 #if USE_CARBON_EVENTS | 12686 #if USE_CARBON_EVENTS |
12669 /* This is needed to correctly */ | 12687 /* This is needed to send mouse events like aqua window buttons |
12670 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | 12688 to the correct handler. */ |
12689 if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) { | |
12690 break; | |
12691 } | |
12692 | |
12693 if (!is_emacs_window(window_ptr)) | |
12694 break; | |
12671 #endif | 12695 #endif |
12672 | 12696 |
12673 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | 12697 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar |
12674 && er.what == mouseUp) | 12698 && er.what == mouseUp) |
12675 { | 12699 { |
12859 | 12883 |
12860 case updateEvt: | 12884 case updateEvt: |
12861 case osEvt: | 12885 case osEvt: |
12862 case activateEvt: | 12886 case activateEvt: |
12863 #if USE_CARBON_EVENTS | 12887 #if USE_CARBON_EVENTS |
12864 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | 12888 if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) |
12865 #endif | 12889 #endif |
12866 do_events (&er); | 12890 do_events (&er); |
12867 break; | 12891 break; |
12868 | 12892 |
12869 case keyDown: | 12893 case keyDown: |
12870 case autoKey: | 12894 case autoKey: |
12871 { | 12895 { |
12872 int keycode = (er.message & keyCodeMask) >> 8; | 12896 int keycode = (er.message & keyCodeMask) >> 8; |
12873 int xkeysym; | 12897 int xkeysym; |
12874 | 12898 |
12899 #if USE_CARBON_EVENTS | |
12900 /* When using Carbon Events, we need to pass raw keyboard events | |
12901 to the TSM ourselves. If TSM handles it, it will pass back | |
12902 noErr, otherwise it will pass back "eventNotHandledErr" and | |
12903 we can process it normally. */ | |
12904 if ((!NILP (Vmac_pass_command_to_system) | |
12905 || !(er.modifiers & cmdKey)) | |
12906 && (!NILP (Vmac_pass_control_to_system) | |
12907 || !(er.modifiers & controlKey))) | |
12908 { | |
12909 OSStatus err; | |
12910 err = SendEventToEventTarget (eventRef, | |
12911 GetEventDispatcherTarget ()); | |
12912 if (err != eventNotHandledErr) | |
12913 break; | |
12914 } | |
12915 #endif | |
12916 | |
12875 if (!IsValidWindowPtr (FrontNonFloatingWindow ())) | 12917 if (!IsValidWindowPtr (FrontNonFloatingWindow ())) |
12876 { | 12918 { |
12877 SysBeep (1); | 12919 SysBeep (1); |
12878 UNBLOCK_INPUT; | 12920 UNBLOCK_INPUT; |
12879 return 0; | 12921 return 0; |
13009 | 13051 |
13010 /* Build a DRAG_N_DROP_EVENT type event as is done in | 13052 /* Build a DRAG_N_DROP_EVENT type event as is done in |
13011 constuct_drag_n_drop in w32term.c. */ | 13053 constuct_drag_n_drop in w32term.c. */ |
13012 if (!NILP (drag_and_drop_file_list)) | 13054 if (!NILP (drag_and_drop_file_list)) |
13013 { | 13055 { |
13014 struct frame *f; | 13056 struct frame *f = NULL; |
13015 WindowPtr wp; | 13057 WindowPtr wp; |
13016 Lisp_Object frame; | 13058 Lisp_Object frame; |
13017 | 13059 |
13018 wp = FrontWindow (); | 13060 wp = FrontNonFloatingWindow (); |
13019 if (!wp) | 13061 if (wp && is_emacs_window(wp)) |
13020 f = NULL; | 13062 f = ((mac_output *) GetWRefCon (wp))->mFP; |
13021 else | 13063 |
13022 f = ((mac_output *) GetWRefCon (wp))->mFP; | |
13023 | |
13024 bufp->kind = DRAG_N_DROP_EVENT; | 13064 bufp->kind = DRAG_N_DROP_EVENT; |
13025 bufp->code = 0; | 13065 bufp->code = 0; |
13026 bufp->timestamp = er.when * (1000 / 60); | 13066 bufp->timestamp = er.when * (1000 / 60); |
13027 /* ticks to milliseconds */ | 13067 /* ticks to milliseconds */ |
13028 #if USE_CARBON_EVENTS | 13068 #if USE_CARBON_EVENTS |
13608 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, | 13648 DEFVAR_LISP ("mac-wheel-button-is-mouse-2", &Vmac_wheel_button_is_mouse_2, |
13609 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and | 13649 doc: /* Non-nil means that the wheel button will be treated as mouse-2 and |
13610 the right click will be mouse-3. | 13650 the right click will be mouse-3. |
13611 Otherwise, the right click will be mouse-2 and the wheel button mouse-3.*/); | 13651 Otherwise, the right click will be mouse-2 and the wheel button mouse-3.*/); |
13612 Vmac_wheel_button_is_mouse_2 = Qt; | 13652 Vmac_wheel_button_is_mouse_2 = Qt; |
13653 | |
13654 DEFVAR_LISP ("mac-pass-command-to-system", &Vmac_pass_command_to_system, | |
13655 doc: /* If non-nil, the Mac \"Command\" key is passed on to the Mac | |
13656 Toolbox for processing before Emacs sees it. */); | |
13657 Vmac_pass_command_to_system = Qt; | |
13658 | |
13659 DEFVAR_LISP ("mac-pass-control-to-system", &Vmac_pass_control_to_system, | |
13660 doc: /* If non-nil, the Mac \"Control\" key is passed on to the Mac | |
13661 Toolbox for processing before Emacs sees it. */); | |
13662 Vmac_pass_control_to_system = Qt; | |
13613 #endif | 13663 #endif |
13614 | 13664 |
13615 DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding, | 13665 DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding, |
13616 doc: /* One of the Text Encoding Base constant values defined in the | 13666 doc: /* One of the Text Encoding Base constant values defined in the |
13617 Basic Text Constants section of Inside Macintosh - Text Encoding | 13667 Basic Text Constants section of Inside Macintosh - Text Encoding |