diff options
| author | Karoly Lorentey | 2004-05-31 13:48:26 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-05-31 13:48:26 +0000 |
| commit | 190a56d6e02f134591a9d8861b8c4aa55bbec79b (patch) | |
| tree | d1ea16845ca26efed987116be6e6b4fc6fc60000 /src | |
| parent | a596810c6c3c3c2fd450717f5083a5ff5207d243 (diff) | |
| parent | 64df673db44e48ae6e2f57849f42961a78103075 (diff) | |
| download | emacs-190a56d6e02f134591a9d8861b8c4aa55bbec79b.tar.gz emacs-190a56d6e02f134591a9d8861b8c4aa55bbec79b.zip | |
Merged in changes from CVS trunk.
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-354
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-355
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-356
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-183
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 89 | ||||
| -rw-r--r-- | src/alloc.c | 22 | ||||
| -rw-r--r-- | src/lisp.h | 2 | ||||
| -rw-r--r-- | src/macfns.c | 391 | ||||
| -rw-r--r-- | src/macgui.h | 15 | ||||
| -rw-r--r-- | src/macmenu.c | 18 | ||||
| -rw-r--r-- | src/macterm.c | 1327 | ||||
| -rw-r--r-- | src/undo.c | 22 | ||||
| -rw-r--r-- | src/xdisp.c | 6 |
9 files changed, 1053 insertions, 839 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index df10f95e500..4be50d1108d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,92 @@ | |||
| 1 | 2004-05-29 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * macfns.c: Don't include ccl.h. | ||
| 4 | [MAC_OSX]: Don't include QuickTime/QuickTime.h. | ||
| 5 | [!MAC_OSX]: Don't include alloca.h, Windows.h, Gestalt.h, or | ||
| 6 | TextUtils.h. | ||
| 7 | (Fx_create_frame): Sync with xfns.c. Initialize cursor | ||
| 8 | descriptors. | ||
| 9 | (Fx_display_mm_height, Fx_display_mm_width): Calculate length from | ||
| 10 | display height/width. | ||
| 11 | (compute_tip_xy, Vx_max_tooltip_size): Declare. | ||
| 12 | (unwind_create_tip_frame, compute_tip_xy): New functions. | ||
| 13 | (x_create_tip_frame, Fx_show_tip, Fx_hide_tip): Sync with xfns.c. | ||
| 14 | (syms_of_macfns): Initialize Qcancel_timer, Vx_max_tooltip_size, | ||
| 15 | and last_show_tip_args. | ||
| 16 | |||
| 17 | * macgui.h [!MAC_OSX]: Include Gestalt.h. | ||
| 18 | (Cursor, No_Cursor): New defines. | ||
| 19 | [!TARGET_API_MAC_CARBON] (SetPortWindowPort): New compatibility | ||
| 20 | macro. | ||
| 21 | [!TARGET_API_MAC_CARBON] (arrow_cursor): Declare. | ||
| 22 | |||
| 23 | * macmenu.c (mac_menu_show, mac_dialog): Use SetPortWindowPort. | ||
| 24 | |||
| 25 | * macterm.c: Don't include Gestalt.h. | ||
| 26 | (enum mouse_tracking_type, mouse_tracking_in_progress): Remove. | ||
| 27 | (XDrawLine, XClearArea, XClearWindow, mac_draw_bitmap) | ||
| 28 | (mac_set_clip_rectangle, mac_reset_clipping, XCreatePixmap) | ||
| 29 | (XFillRectangle, mac_draw_rectangle, mac_draw_string_common) | ||
| 30 | (mac_copy_area, mac_copy_area_with_mask, x_update_end) | ||
| 31 | (construct_mouse_click, XTmouse_position) | ||
| 32 | (x_scroll_bar_report_motion, x_calc_absolute_position) | ||
| 33 | (do_mouse_moved, do_zoom_window, mac_do_receive_drag) | ||
| 34 | (XTread_socket, make_mac_frame): Use SetPortWindowPort. | ||
| 35 | (note_mouse_movement): Clear the mouse face and reset the pointer | ||
| 36 | shape when the pointer goes outside the frame without grabbing. | ||
| 37 | (mac_front_window): New function. | ||
| 38 | (mac_window_to_frame): New macro. | ||
| 39 | (XTmouse_position, x_scroll_bar_report_motion, do_window_update) | ||
| 40 | (do_window_activate, do_window_deactivate, do_app_resume) | ||
| 41 | (do_app_suspend, do_mouse_moved, do_menu_choice, do_grow_window) | ||
| 42 | (do_zoom_window, mac_do_receive_drag, XTread_socket) | ||
| 43 | (mac_check_for_quit_char): Use mac_front_window and/or | ||
| 44 | mac_window_to_frame. | ||
| 45 | (x_scroll_bar_handle_click): Set `(PORTION . WHOLE)' part in a | ||
| 46 | scroll-bar click event. | ||
| 47 | (mac_define_frame_cursor): Change the pointer shape. | ||
| 48 | (x_free_frame_resources): Reset tip_window to NULL when it is | ||
| 49 | disposed. | ||
| 50 | [!TARGET_API_MAC_CARBON] (arrow_cursor): New variable. | ||
| 51 | [!TARGET_API_MAC_CARBON] (do_init_managers): Initialize | ||
| 52 | arrow_cursor. | ||
| 53 | (do_window_update): Don't do anything if the updated window is the | ||
| 54 | tooltip window. | ||
| 55 | (do_mouse_moved): Handle mouse movement events here (previously in | ||
| 56 | XTread_socket). Clear the mouse face if | ||
| 57 | dpyinfo->mouse_face_hidden is set. | ||
| 58 | (do_os_event, do_events): Remove (now in XTread_socket). | ||
| 59 | (XTread_socket): Immediately return if interrupt_input_blocked. | ||
| 60 | Loop until all the events in the queue are processed. Rearrange | ||
| 61 | codes for mouse grabbing. Add tooltip support. Include the | ||
| 62 | contents of do_os_event and do_events. Remove mouse movement | ||
| 63 | handling (now in do_mouse_moved). Add the case where | ||
| 64 | Vmouse_highlight has an integer value. | ||
| 65 | (NewMacWindow): Remove. | ||
| 66 | (make_mac_frame): Do what NewMacWindow previously did. Don't do | ||
| 67 | excess initializations. | ||
| 68 | (make_mac_terminal_frame): Previous initializations in | ||
| 69 | make_mac_frame are moved here. | ||
| 70 | (mac_initialize_display_info): Initialize | ||
| 71 | dpyinfo->mouse_face_overlay and dpyinfo->mouse_face_hidden. | ||
| 72 | |||
| 73 | * xdisp.c [MAC_OS] (No_Cursor): Remove variable. | ||
| 74 | (define_frame_cursor1): Don't treat HAVE_CARBON as a special case. | ||
| 75 | |||
| 76 | 2004-05-29 Richard M. Stallman <rms@gnu.org> | ||
| 77 | |||
| 78 | * lisp.h (truncate_undo_list): Update decl. | ||
| 79 | |||
| 80 | * alloc.c (undo_outer_limit): New variable. | ||
| 81 | (syms_of_alloc): Defvar it. | ||
| 82 | (Fgarbage_collect): Pass undo_outer_limit to truncate_undo_list. | ||
| 83 | |||
| 84 | * undo.c (truncate_undo_list): New arg LIMITSIZE. | ||
| 85 | |||
| 86 | * alloc.c (lisp_align_malloc): Check for base == 0 | ||
| 87 | regardless of HAVE_POSIX_MEMALIGN. | ||
| 88 | Clean up HAVE_POSIX_MEMALIGN handling of `err'. | ||
| 89 | |||
| 1 | 2004-05-28 Stefan Monnier <monnier@iro.umontreal.ca> | 90 | 2004-05-28 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 91 | ||
| 3 | * alloc.c: Undo Kim's recent changes and fix the same bug differently. | 92 | * alloc.c: Undo Kim's recent changes and fix the same bug differently. |
diff --git a/src/alloc.c b/src/alloc.c index adedb414aad..3a3628f40fd 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -155,6 +155,7 @@ int malloc_sbrk_unused; | |||
| 155 | 155 | ||
| 156 | EMACS_INT undo_limit; | 156 | EMACS_INT undo_limit; |
| 157 | EMACS_INT undo_strong_limit; | 157 | EMACS_INT undo_strong_limit; |
| 158 | EMACS_INT undo_outer_limit; | ||
| 158 | 159 | ||
| 159 | /* Number of live and free conses etc. */ | 160 | /* Number of live and free conses etc. */ |
| 160 | 161 | ||
| @@ -755,17 +756,20 @@ lisp_align_malloc (nbytes, type) | |||
| 755 | #ifdef HAVE_POSIX_MEMALIGN | 756 | #ifdef HAVE_POSIX_MEMALIGN |
| 756 | { | 757 | { |
| 757 | int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); | 758 | int err = posix_memalign (&base, BLOCK_ALIGN, ABLOCKS_BYTES); |
| 758 | abase = err ? (base = NULL) : base; | 759 | if (err) |
| 760 | base = NULL; | ||
| 761 | abase = base; | ||
| 759 | } | 762 | } |
| 760 | #else | 763 | #else |
| 761 | base = malloc (ABLOCKS_BYTES); | 764 | base = malloc (ABLOCKS_BYTES); |
| 762 | abase = ALIGN (base, BLOCK_ALIGN); | 765 | abase = ALIGN (base, BLOCK_ALIGN); |
| 766 | #endif | ||
| 767 | |||
| 763 | if (base == 0) | 768 | if (base == 0) |
| 764 | { | 769 | { |
| 765 | UNBLOCK_INPUT; | 770 | UNBLOCK_INPUT; |
| 766 | memory_full (); | 771 | memory_full (); |
| 767 | } | 772 | } |
| 768 | #endif | ||
| 769 | 773 | ||
| 770 | aligned = (base == abase); | 774 | aligned = (base == abase); |
| 771 | if (!aligned) | 775 | if (!aligned) |
| @@ -4381,7 +4385,7 @@ returns nil, because real GC can't be done. */) | |||
| 4381 | if (! EQ (nextb->undo_list, Qt)) | 4385 | if (! EQ (nextb->undo_list, Qt)) |
| 4382 | nextb->undo_list | 4386 | nextb->undo_list |
| 4383 | = truncate_undo_list (nextb->undo_list, undo_limit, | 4387 | = truncate_undo_list (nextb->undo_list, undo_limit, |
| 4384 | undo_strong_limit); | 4388 | undo_strong_limit, undo_outer_limit); |
| 4385 | 4389 | ||
| 4386 | /* Shrink buffer gaps, but skip indirect and dead buffers. */ | 4390 | /* Shrink buffer gaps, but skip indirect and dead buffers. */ |
| 4387 | if (nextb->base_buffer == 0 && !NILP (nextb->name)) | 4391 | if (nextb->base_buffer == 0 && !NILP (nextb->name)) |
| @@ -5668,12 +5672,20 @@ which includes both saved text and other data. */); | |||
| 5668 | 5672 | ||
| 5669 | DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, | 5673 | DEFVAR_INT ("undo-strong-limit", &undo_strong_limit, |
| 5670 | doc: /* Don't keep more than this much size of undo information. | 5674 | doc: /* Don't keep more than this much size of undo information. |
| 5671 | A command which pushes past this size is itself forgotten. | 5675 | A previous command which pushes the undo list past this size |
| 5672 | This limit is applied when garbage collection happens. | 5676 | is entirely forgotten when GC happens. |
| 5673 | The size is counted as the number of bytes occupied, | 5677 | The size is counted as the number of bytes occupied, |
| 5674 | which includes both saved text and other data. */); | 5678 | which includes both saved text and other data. */); |
| 5675 | undo_strong_limit = 30000; | 5679 | undo_strong_limit = 30000; |
| 5676 | 5680 | ||
| 5681 | DEFVAR_INT ("undo-outer-limit", &undo_outer_limit, | ||
| 5682 | doc: /* Don't keep more than this much size of undo information. | ||
| 5683 | If the current command has produced more than this much undo information, | ||
| 5684 | GC discards it. This is a last-ditch limit to prevent memory overflow. | ||
| 5685 | The size is counted as the number of bytes occupied, | ||
| 5686 | which includes both saved text and other data. */); | ||
| 5687 | undo_outer_limit = 300000; | ||
| 5688 | |||
| 5677 | DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, | 5689 | DEFVAR_BOOL ("garbage-collection-messages", &garbage_collection_messages, |
| 5678 | doc: /* Non-nil means display messages at start and end of garbage collection. */); | 5690 | doc: /* Non-nil means display messages at start and end of garbage collection. */); |
| 5679 | garbage_collection_messages = 0; | 5691 | garbage_collection_messages = 0; |
diff --git a/src/lisp.h b/src/lisp.h index ca060cb4c2f..fdf76399e5d 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3009,7 +3009,7 @@ extern void syms_of_macros P_ ((void)); | |||
| 3009 | /* defined in undo.c */ | 3009 | /* defined in undo.c */ |
| 3010 | extern Lisp_Object Qinhibit_read_only; | 3010 | extern Lisp_Object Qinhibit_read_only; |
| 3011 | EXFUN (Fundo_boundary, 0); | 3011 | EXFUN (Fundo_boundary, 0); |
| 3012 | extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int)); | 3012 | extern Lisp_Object truncate_undo_list P_ ((Lisp_Object, int, int, int)); |
| 3013 | extern void record_marker_adjustment P_ ((Lisp_Object, int)); | 3013 | extern void record_marker_adjustment P_ ((Lisp_Object, int)); |
| 3014 | extern void record_insert P_ ((int, int)); | 3014 | extern void record_insert P_ ((int, int)); |
| 3015 | extern void record_delete P_ ((int, Lisp_Object)); | 3015 | extern void record_delete P_ ((int, Lisp_Object)); |
diff --git a/src/macfns.c b/src/macfns.c index 625ca29336c..4147325c288 100644 --- a/src/macfns.c +++ b/src/macfns.c | |||
| @@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */ | |||
| 42 | #include "epaths.h" | 42 | #include "epaths.h" |
| 43 | #include "termhooks.h" | 43 | #include "termhooks.h" |
| 44 | #include "coding.h" | 44 | #include "coding.h" |
| 45 | #include "ccl.h" | ||
| 46 | #include "systime.h" | 45 | #include "systime.h" |
| 47 | 46 | ||
| 48 | /* #include "bitmaps/gray.xbm" */ | 47 | /* #include "bitmaps/gray.xbm" */ |
| @@ -59,17 +58,6 @@ static unsigned char gray_bits[] = { | |||
| 59 | 58 | ||
| 60 | #include <stdlib.h> | 59 | #include <stdlib.h> |
| 61 | #include <string.h> | 60 | #include <string.h> |
| 62 | #ifndef MAC_OSX | ||
| 63 | #include <alloca.h> | ||
| 64 | #endif | ||
| 65 | |||
| 66 | #ifdef MAC_OSX | ||
| 67 | #include <QuickTime/QuickTime.h> | ||
| 68 | #else /* not MAC_OSX */ | ||
| 69 | #include <Windows.h> | ||
| 70 | #include <Gestalt.h> | ||
| 71 | #include <TextUtils.h> | ||
| 72 | #endif /* not MAC_OSX */ | ||
| 73 | 61 | ||
| 74 | /*extern void free_frame_menubar (); | 62 | /*extern void free_frame_menubar (); |
| 75 | extern double atof (); | 63 | extern double atof (); |
| @@ -2580,8 +2568,6 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 2580 | f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); | 2568 | f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); |
| 2581 | bzero (f->output_data.mac, sizeof (struct mac_output)); | 2569 | bzero (f->output_data.mac, sizeof (struct mac_output)); |
| 2582 | FRAME_FONTSET (f) = -1; | 2570 | FRAME_FONTSET (f) = -1; |
| 2583 | f->output_data.mac->scroll_bar_foreground_pixel = -1; | ||
| 2584 | f->output_data.mac->scroll_bar_background_pixel = -1; | ||
| 2585 | record_unwind_protect (unwind_create_frame, frame); | 2571 | record_unwind_protect (unwind_create_frame, frame); |
| 2586 | 2572 | ||
| 2587 | f->icon_name | 2573 | f->icon_name |
| @@ -2717,25 +2703,32 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 2717 | 2703 | ||
| 2718 | f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; | 2704 | f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; |
| 2719 | 2705 | ||
| 2720 | /* MAC_TODO: specify 1 below when toolbars are implemented. */ | 2706 | #if TARGET_API_MAC_CARBON |
| 2721 | window_prompting = x_figure_window_size (f, parms, 0); | 2707 | f->output_data.mac->text_cursor = kThemeIBeamCursor; |
| 2708 | f->output_data.mac->nontext_cursor = kThemeArrowCursor; | ||
| 2709 | f->output_data.mac->modeline_cursor = kThemeArrowCursor; | ||
| 2710 | f->output_data.mac->hand_cursor = kThemePointingHandCursor; | ||
| 2711 | f->output_data.mac->hourglass_cursor = kThemeWatchCursor; | ||
| 2712 | f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor; | ||
| 2713 | #else | ||
| 2714 | f->output_data.mac->text_cursor = GetCursor (iBeamCursor); | ||
| 2715 | f->output_data.mac->nontext_cursor = &arrow_cursor; | ||
| 2716 | f->output_data.mac->modeline_cursor = &arrow_cursor; | ||
| 2717 | f->output_data.mac->hand_cursor = &arrow_cursor; | ||
| 2718 | f->output_data.mac->hourglass_cursor = GetCursor (watchCursor); | ||
| 2719 | f->output_data.mac->horizontal_drag_cursor = &arrow_cursor; | ||
| 2720 | #endif | ||
| 2721 | |||
| 2722 | /* Compute the size of the window. */ | ||
| 2723 | window_prompting = x_figure_window_size (f, parms, 1); | ||
| 2722 | 2724 | ||
| 2723 | tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); | 2725 | tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); |
| 2724 | f->no_split = minibuffer_only || EQ (tem, Qt); | 2726 | f->no_split = minibuffer_only || EQ (tem, Qt); |
| 2725 | 2727 | ||
| 2726 | /* Create the window. Add the tool-bar height to the initial frame | ||
| 2727 | height so that the user gets a text display area of the size he | ||
| 2728 | specified with -g or via the registry. Later changes of the | ||
| 2729 | tool-bar height don't change the frame size. This is done so that | ||
| 2730 | users can create tall Emacs frames without having to guess how | ||
| 2731 | tall the tool-bar will get. */ | ||
| 2732 | FRAME_LINES (f) += FRAME_TOOL_BAR_LINES (f); | ||
| 2733 | |||
| 2734 | /* mac_window (f, window_prompting, minibuffer_only); */ | 2728 | /* mac_window (f, window_prompting, minibuffer_only); */ |
| 2735 | make_mac_frame (f); | 2729 | make_mac_frame (f); |
| 2736 | 2730 | ||
| 2737 | x_icon (f, parms); | 2731 | x_icon (f, parms); |
| 2738 | |||
| 2739 | x_make_gc (f); | 2732 | x_make_gc (f); |
| 2740 | 2733 | ||
| 2741 | /* Now consider the frame official. */ | 2734 | /* Now consider the frame official. */ |
| @@ -2754,7 +2747,8 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 2754 | x_default_parameter (f, parms, Qcursor_type, Qbox, | 2747 | x_default_parameter (f, parms, Qcursor_type, Qbox, |
| 2755 | "cursorType", "CursorType", RES_TYPE_SYMBOL); | 2748 | "cursorType", "CursorType", RES_TYPE_SYMBOL); |
| 2756 | x_default_parameter (f, parms, Qscroll_bar_width, Qnil, | 2749 | x_default_parameter (f, parms, Qscroll_bar_width, Qnil, |
| 2757 | "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); | 2750 | "scrollBarWidth", "ScrollBarWidth", |
| 2751 | RES_TYPE_NUMBER); | ||
| 2758 | 2752 | ||
| 2759 | /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. | 2753 | /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. |
| 2760 | Change will not be effected unless different from the current | 2754 | Change will not be effected unless different from the current |
| @@ -2762,13 +2756,10 @@ This function is an internal primitive--use `make-frame' instead. */) | |||
| 2762 | width = FRAME_COLS (f); | 2756 | width = FRAME_COLS (f); |
| 2763 | height = FRAME_LINES (f); | 2757 | height = FRAME_LINES (f); |
| 2764 | 2758 | ||
| 2765 | FRAME_LINES (f) = 0; | ||
| 2766 | SET_FRAME_COLS (f, 0); | 2759 | SET_FRAME_COLS (f, 0); |
| 2760 | FRAME_LINES (f) = 0; | ||
| 2767 | change_frame_size (f, height, width, 1, 0, 0); | 2761 | change_frame_size (f, height, width, 1, 0, 0); |
| 2768 | 2762 | ||
| 2769 | /* Set up faces after all frame parameters are known. */ | ||
| 2770 | call1 (Qface_set_after_frame_default, frame); | ||
| 2771 | |||
| 2772 | #if 0 /* MAC_TODO: when we have window manager hints */ | 2763 | #if 0 /* MAC_TODO: when we have window manager hints */ |
| 2773 | /* Tell the server what size and position, etc, we want, and how | 2764 | /* Tell the server what size and position, etc, we want, and how |
| 2774 | badly we want them. This should be done after we have the menu | 2765 | badly we want them. This should be done after we have the menu |
| @@ -3025,11 +3016,8 @@ If omitted or nil, that stands for the selected frame's display. */) | |||
| 3025 | /* MAC_TODO: this is an approximation, and only of the main display */ | 3016 | /* MAC_TODO: this is an approximation, and only of the main display */ |
| 3026 | 3017 | ||
| 3027 | struct mac_display_info *dpyinfo = check_x_display_info (display); | 3018 | struct mac_display_info *dpyinfo = check_x_display_info (display); |
| 3028 | short h, v; | ||
| 3029 | 3019 | ||
| 3030 | ScreenRes (&h, &v); | 3020 | return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy)); |
| 3031 | |||
| 3032 | return make_number ((int) (v / 72.0 * 25.4)); | ||
| 3033 | } | 3021 | } |
| 3034 | 3022 | ||
| 3035 | DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, | 3023 | DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, |
| @@ -3043,11 +3031,8 @@ If omitted or nil, that stands for the selected frame's display. */) | |||
| 3043 | /* MAC_TODO: this is an approximation, and only of the main display */ | 3031 | /* MAC_TODO: this is an approximation, and only of the main display */ |
| 3044 | 3032 | ||
| 3045 | struct mac_display_info *dpyinfo = check_x_display_info (display); | 3033 | struct mac_display_info *dpyinfo = check_x_display_info (display); |
| 3046 | short h, v; | ||
| 3047 | |||
| 3048 | ScreenRes (&h, &v); | ||
| 3049 | 3034 | ||
| 3050 | return make_number ((int) (h / 72.0 * 25.4)); | 3035 | return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx)); |
| 3051 | } | 3036 | } |
| 3052 | 3037 | ||
| 3053 | DEFUN ("x-display-backing-store", Fx_display_backing_store, | 3038 | DEFUN ("x-display-backing-store", Fx_display_backing_store, |
| @@ -3595,9 +3580,11 @@ hide_hourglass () | |||
| 3595 | ***********************************************************************/ | 3580 | ***********************************************************************/ |
| 3596 | 3581 | ||
| 3597 | static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *, | 3582 | static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *, |
| 3598 | Lisp_Object)); | 3583 | Lisp_Object, Lisp_Object)); |
| 3584 | static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object, | ||
| 3585 | Lisp_Object, int, int, int *, int *)); | ||
| 3599 | 3586 | ||
| 3600 | /* The frame of a currently visible tooltip, or null. */ | 3587 | /* The frame of a currently visible tooltip. */ |
| 3601 | 3588 | ||
| 3602 | Lisp_Object tip_frame; | 3589 | Lisp_Object tip_frame; |
| 3603 | 3590 | ||
| @@ -3612,15 +3599,42 @@ Window tip_window; | |||
| 3612 | 3599 | ||
| 3613 | Lisp_Object last_show_tip_args; | 3600 | Lisp_Object last_show_tip_args; |
| 3614 | 3601 | ||
| 3602 | /* Maximum size for tooltips; a cons (COLUMNS . ROWS). */ | ||
| 3603 | |||
| 3604 | Lisp_Object Vx_max_tooltip_size; | ||
| 3605 | |||
| 3606 | |||
| 3607 | static Lisp_Object | ||
| 3608 | unwind_create_tip_frame (frame) | ||
| 3609 | Lisp_Object frame; | ||
| 3610 | { | ||
| 3611 | Lisp_Object deleted; | ||
| 3612 | |||
| 3613 | deleted = unwind_create_frame (frame); | ||
| 3614 | if (EQ (deleted, Qt)) | ||
| 3615 | { | ||
| 3616 | tip_window = NULL; | ||
| 3617 | tip_frame = Qnil; | ||
| 3618 | } | ||
| 3619 | |||
| 3620 | return deleted; | ||
| 3621 | } | ||
| 3622 | |||
| 3623 | |||
| 3615 | /* Create a frame for a tooltip on the display described by DPYINFO. | 3624 | /* Create a frame for a tooltip on the display described by DPYINFO. |
| 3616 | PARMS is a list of frame parameters. Value is the frame. */ | 3625 | PARMS is a list of frame parameters. TEXT is the string to |
| 3626 | display in the tip frame. Value is the frame. | ||
| 3627 | |||
| 3628 | Note that functions called here, esp. x_default_parameter can | ||
| 3629 | signal errors, for instance when a specified color name is | ||
| 3630 | undefined. We have to make sure that we're in a consistent state | ||
| 3631 | when this happens. */ | ||
| 3617 | 3632 | ||
| 3618 | static Lisp_Object | 3633 | static Lisp_Object |
| 3619 | x_create_tip_frame (dpyinfo, parms) | 3634 | x_create_tip_frame (dpyinfo, parms, text) |
| 3620 | struct mac_display_info *dpyinfo; | 3635 | struct mac_display_info *dpyinfo; |
| 3621 | Lisp_Object parms; | 3636 | Lisp_Object parms, text; |
| 3622 | { | 3637 | { |
| 3623 | #if 0 /* MAC_TODO : Mac version */ | ||
| 3624 | struct frame *f; | 3638 | struct frame *f; |
| 3625 | Lisp_Object frame, tem; | 3639 | Lisp_Object frame, tem; |
| 3626 | Lisp_Object name; | 3640 | Lisp_Object name; |
| @@ -3629,8 +3643,11 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3629 | int count = SPECPDL_INDEX (); | 3643 | int count = SPECPDL_INDEX (); |
| 3630 | struct gcpro gcpro1, gcpro2, gcpro3; | 3644 | struct gcpro gcpro1, gcpro2, gcpro3; |
| 3631 | struct kboard *kb; | 3645 | struct kboard *kb; |
| 3646 | int face_change_count_before = face_change_count; | ||
| 3647 | Lisp_Object buffer; | ||
| 3648 | struct buffer *old_buffer; | ||
| 3632 | 3649 | ||
| 3633 | check_x (); | 3650 | check_mac (); |
| 3634 | 3651 | ||
| 3635 | /* Use this general default value to start with until we know if | 3652 | /* Use this general default value to start with until we know if |
| 3636 | this frame has a specified name. */ | 3653 | this frame has a specified name. */ |
| @@ -3643,7 +3660,7 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3643 | #endif | 3660 | #endif |
| 3644 | 3661 | ||
| 3645 | /* Get the name of the frame to use for resource lookup. */ | 3662 | /* Get the name of the frame to use for resource lookup. */ |
| 3646 | name = w32_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); | 3663 | name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); |
| 3647 | if (!STRINGP (name) | 3664 | if (!STRINGP (name) |
| 3648 | && !EQ (name, Qunbound) | 3665 | && !EQ (name, Qunbound) |
| 3649 | && !NILP (name)) | 3666 | && !NILP (name)) |
| @@ -3652,31 +3669,50 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3652 | 3669 | ||
| 3653 | frame = Qnil; | 3670 | frame = Qnil; |
| 3654 | GCPRO3 (parms, name, frame); | 3671 | GCPRO3 (parms, name, frame); |
| 3655 | tip_frame = f = make_frame (1); | 3672 | f = make_frame (1); |
| 3656 | XSETFRAME (frame, f); | 3673 | XSETFRAME (frame, f); |
| 3674 | |||
| 3675 | buffer = Fget_buffer_create (build_string (" *tip*")); | ||
| 3676 | Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil); | ||
| 3677 | old_buffer = current_buffer; | ||
| 3678 | set_buffer_internal_1 (XBUFFER (buffer)); | ||
| 3679 | current_buffer->truncate_lines = Qnil; | ||
| 3680 | specbind (Qinhibit_read_only, Qt); | ||
| 3681 | specbind (Qinhibit_modification_hooks, Qt); | ||
| 3682 | Ferase_buffer (); | ||
| 3683 | Finsert (1, &text); | ||
| 3684 | set_buffer_internal_1 (old_buffer); | ||
| 3685 | |||
| 3657 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | 3686 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
| 3687 | record_unwind_protect (unwind_create_tip_frame, frame); | ||
| 3658 | 3688 | ||
| 3659 | f->output_method = output_w32; | 3689 | /* By setting the output method, we're essentially saying that |
| 3660 | f->output_data.w32 = | 3690 | the frame is live, as per FRAME_LIVE_P. If we get a signal |
| 3661 | (struct w32_output *) xmalloc (sizeof (struct w32_output)); | 3691 | from this point on, x_destroy_window might screw up reference |
| 3662 | bzero (f->output_data.w32, sizeof (struct w32_output)); | 3692 | counts etc. */ |
| 3663 | #if 0 | 3693 | f->output_method = output_mac; |
| 3664 | f->output_data.w32->icon_bitmap = -1; | 3694 | f->output_data.mac = |
| 3665 | #endif | 3695 | (struct mac_output *) xmalloc (sizeof (struct mac_output)); |
| 3666 | FRAME_FONTSET (f) = -1; | 3696 | bzero (f->output_data.mac, sizeof (struct mac_output)); |
| 3697 | |||
| 3698 | FRAME_FONTSET (f) = -1; | ||
| 3667 | f->icon_name = Qnil; | 3699 | f->icon_name = Qnil; |
| 3668 | 3700 | ||
| 3701 | #if 0 /* GLYPH_DEBUG TODO: image support. */ | ||
| 3702 | image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; | ||
| 3703 | dpyinfo_refcount = dpyinfo->reference_count; | ||
| 3704 | #endif /* GLYPH_DEBUG */ | ||
| 3669 | #ifdef MULTI_KBOARD | 3705 | #ifdef MULTI_KBOARD |
| 3670 | FRAME_KBOARD (f) = kb; | 3706 | FRAME_KBOARD (f) = kb; |
| 3671 | #endif | 3707 | #endif |
| 3672 | f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; | 3708 | f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; |
| 3673 | f->output_data.w32->explicit_parent = 0; | 3709 | f->output_data.mac->explicit_parent = 0; |
| 3674 | 3710 | ||
| 3675 | /* Set the name; the functions to which we pass f expect the name to | 3711 | /* Set the name; the functions to which we pass f expect the name to |
| 3676 | be set. */ | 3712 | be set. */ |
| 3677 | if (EQ (name, Qunbound) || NILP (name)) | 3713 | if (EQ (name, Qunbound) || NILP (name)) |
| 3678 | { | 3714 | { |
| 3679 | f->name = build_string (dpyinfo->x_id_name); | 3715 | f->name = build_string (dpyinfo->mac_id_name); |
| 3680 | f->explicit_name = 0; | 3716 | f->explicit_name = 0; |
| 3681 | } | 3717 | } |
| 3682 | else | 3718 | else |
| @@ -3687,12 +3723,12 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3687 | specbind (Qx_resource_name, name); | 3723 | specbind (Qx_resource_name, name); |
| 3688 | } | 3724 | } |
| 3689 | 3725 | ||
| 3690 | /* Extract the window parameters from the supplied values | 3726 | /* Extract the window parameters from the supplied values that are |
| 3691 | that are needed to determine window geometry. */ | 3727 | needed to determine window geometry. */ |
| 3692 | { | 3728 | { |
| 3693 | Lisp_Object font; | 3729 | Lisp_Object font; |
| 3694 | 3730 | ||
| 3695 | font = w32_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING); | 3731 | font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING); |
| 3696 | 3732 | ||
| 3697 | BLOCK_INPUT; | 3733 | BLOCK_INPUT; |
| 3698 | /* First, try whatever font the caller has specified. */ | 3734 | /* First, try whatever font the caller has specified. */ |
| @@ -3706,22 +3742,16 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3706 | } | 3742 | } |
| 3707 | 3743 | ||
| 3708 | /* Try out a font which we hope has bold and italic variations. */ | 3744 | /* Try out a font which we hope has bold and italic variations. */ |
| 3709 | if (!STRINGP (font)) | ||
| 3710 | font = x_new_font (f, "-adobe-courier-medium-r-*-*-*-120-*-*-*-*-iso8859-1"); | ||
| 3711 | if (!STRINGP (font)) | ||
| 3712 | font = x_new_font (f, "-misc-fixed-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); | ||
| 3713 | if (! STRINGP (font)) | ||
| 3714 | font = x_new_font (f, "-*-*-medium-r-normal-*-*-140-*-*-c-*-iso8859-1"); | ||
| 3715 | if (! STRINGP (font)) | 3745 | if (! STRINGP (font)) |
| 3716 | /* This was formerly the first thing tried, but it finds too many fonts | 3746 | font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1"); |
| 3717 | and takes too long. */ | ||
| 3718 | font = x_new_font (f, "-*-*-medium-r-*-*-*-*-*-*-c-*-iso8859-1"); | ||
| 3719 | /* If those didn't work, look for something which will at least work. */ | 3747 | /* If those didn't work, look for something which will at least work. */ |
| 3720 | if (! STRINGP (font)) | 3748 | if (! STRINGP (font)) |
| 3721 | font = x_new_font (f, "-*-fixed-*-*-*-*-*-140-*-*-c-*-iso8859-1"); | 3749 | font = x_new_font (f, "-*-monaco-*-12-*-mac-roman"); |
| 3750 | if (! STRINGP (font)) | ||
| 3751 | font = x_new_font (f, "-*-courier-*-10-*-mac-roman"); | ||
| 3722 | UNBLOCK_INPUT; | 3752 | UNBLOCK_INPUT; |
| 3723 | if (! STRINGP (font)) | 3753 | if (! STRINGP (font)) |
| 3724 | font = build_string ("fixed"); | 3754 | error ("Cannot find any usable font"); |
| 3725 | 3755 | ||
| 3726 | x_default_parameter (f, parms, Qfont, font, | 3756 | x_default_parameter (f, parms, Qfont, font, |
| 3727 | "font", "Font", RES_TYPE_STRING); | 3757 | "font", "Font", RES_TYPE_STRING); |
| @@ -3737,7 +3767,7 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3737 | { | 3767 | { |
| 3738 | Lisp_Object value; | 3768 | Lisp_Object value; |
| 3739 | 3769 | ||
| 3740 | value = w32_get_arg (parms, Qinternal_border_width, | 3770 | value = mac_get_arg (parms, Qinternal_border_width, |
| 3741 | "internalBorder", "internalBorder", RES_TYPE_NUMBER); | 3771 | "internalBorder", "internalBorder", RES_TYPE_NUMBER); |
| 3742 | if (! EQ (value, Qunbound)) | 3772 | if (! EQ (value, Qunbound)) |
| 3743 | parms = Fcons (Fcons (Qinternal_border_width, value), | 3773 | parms = Fcons (Fcons (Qinternal_border_width, value), |
| @@ -3768,34 +3798,26 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3768 | happen. */ | 3798 | happen. */ |
| 3769 | init_frame_faces (f); | 3799 | init_frame_faces (f); |
| 3770 | 3800 | ||
| 3771 | f->output_data.w32->parent_desc = FRAME_W32_DISPLAY_INFO (f)->root_window; | 3801 | f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; |
| 3772 | 3802 | ||
| 3773 | window_prompting = x_figure_window_size (f, parms, 0); | 3803 | window_prompting = x_figure_window_size (f, parms, 0); |
| 3774 | 3804 | ||
| 3775 | { | 3805 | { |
| 3776 | XSetWindowAttributes attrs; | ||
| 3777 | unsigned long mask; | ||
| 3778 | |||
| 3779 | BLOCK_INPUT; | 3806 | BLOCK_INPUT; |
| 3780 | mask = CWBackPixel | CWOverrideRedirect | CWSaveUnder | CWEventMask; | 3807 | Rect r; |
| 3781 | /* Window managers looks at the override-redirect flag to | 3808 | |
| 3782 | determine whether or net to give windows a decoration (Xlib | 3809 | SetRect (&r, 0, 0, 1, 1); |
| 3783 | 3.2.8). */ | 3810 | if (CreateNewWindow (kHelpWindowClass, |
| 3784 | attrs.override_redirect = True; | 3811 | kWindowNoActivatesAttribute |
| 3785 | attrs.save_under = True; | 3812 | | kWindowIgnoreClicksAttribute, |
| 3786 | attrs.background_pixel = FRAME_BACKGROUND_PIXEL (f); | 3813 | &r, &tip_window) == noErr) |
| 3787 | /* Arrange for getting MapNotify and UnmapNotify events. */ | 3814 | { |
| 3788 | attrs.event_mask = StructureNotifyMask; | 3815 | FRAME_MAC_WINDOW (f) = tip_window; |
| 3789 | tip_window | 3816 | SetWRefCon (tip_window, (long) f->output_data.mac); |
| 3790 | = FRAME_W32_WINDOW (f) | 3817 | /* so that update events can find this mac_output struct */ |
| 3791 | = XCreateWindow (FRAME_W32_DISPLAY (f), | 3818 | f->output_data.mac->mFP = f; |
| 3792 | FRAME_W32_DISPLAY_INFO (f)->root_window, | 3819 | ShowWindow (tip_window); |
| 3793 | /* x, y, width, height */ | 3820 | } |
| 3794 | 0, 0, 1, 1, | ||
| 3795 | /* Border. */ | ||
| 3796 | 1, | ||
| 3797 | CopyFromParent, InputOutput, CopyFromParent, | ||
| 3798 | mask, &attrs); | ||
| 3799 | UNBLOCK_INPUT; | 3821 | UNBLOCK_INPUT; |
| 3800 | } | 3822 | } |
| 3801 | 3823 | ||
| @@ -3813,8 +3835,8 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3813 | FRAME_LINES (f). */ | 3835 | FRAME_LINES (f). */ |
| 3814 | width = FRAME_COLS (f); | 3836 | width = FRAME_COLS (f); |
| 3815 | height = FRAME_LINES (f); | 3837 | height = FRAME_LINES (f); |
| 3816 | FRAME_LINES (f) = 0; | ||
| 3817 | SET_FRAME_COLS (f, 0); | 3838 | SET_FRAME_COLS (f, 0); |
| 3839 | FRAME_LINES (f) = 0; | ||
| 3818 | change_frame_size (f, height, width, 1, 0, 0); | 3840 | change_frame_size (f, height, width, 1, 0, 0); |
| 3819 | 3841 | ||
| 3820 | /* Add `tooltip' frame parameter's default value. */ | 3842 | /* Add `tooltip' frame parameter's default value. */ |
| @@ -3822,6 +3844,26 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3822 | Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt), | 3844 | Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt), |
| 3823 | Qnil)); | 3845 | Qnil)); |
| 3824 | 3846 | ||
| 3847 | /* Set up faces after all frame parameters are known. This call | ||
| 3848 | also merges in face attributes specified for new frames. | ||
| 3849 | |||
| 3850 | Frame parameters may be changed if .Xdefaults contains | ||
| 3851 | specifications for the default font. For example, if there is an | ||
| 3852 | `Emacs.default.attributeBackground: pink', the `background-color' | ||
| 3853 | attribute of the frame get's set, which let's the internal border | ||
| 3854 | of the tooltip frame appear in pink. Prevent this. */ | ||
| 3855 | { | ||
| 3856 | Lisp_Object bg = Fframe_parameter (frame, Qbackground_color); | ||
| 3857 | |||
| 3858 | /* Set tip_frame here, so that */ | ||
| 3859 | tip_frame = frame; | ||
| 3860 | call1 (Qface_set_after_frame_default, frame); | ||
| 3861 | |||
| 3862 | if (!EQ (bg, Fframe_parameter (frame, Qbackground_color))) | ||
| 3863 | Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg), | ||
| 3864 | Qnil)); | ||
| 3865 | } | ||
| 3866 | |||
| 3825 | f->no_split = 1; | 3867 | f->no_split = 1; |
| 3826 | 3868 | ||
| 3827 | UNGCPRO; | 3869 | UNGCPRO; |
| @@ -3833,17 +3875,80 @@ x_create_tip_frame (dpyinfo, parms) | |||
| 3833 | 3875 | ||
| 3834 | /* Now that the frame is official, it counts as a reference to | 3876 | /* Now that the frame is official, it counts as a reference to |
| 3835 | its display. */ | 3877 | its display. */ |
| 3836 | FRAME_W32_DISPLAY_INFO (f)->reference_count++; | 3878 | FRAME_MAC_DISPLAY_INFO (f)->reference_count++; |
| 3879 | |||
| 3880 | /* Setting attributes of faces of the tooltip frame from resources | ||
| 3881 | and similar will increment face_change_count, which leads to the | ||
| 3882 | clearing of all current matrices. Since this isn't necessary | ||
| 3883 | here, avoid it by resetting face_change_count to the value it | ||
| 3884 | had before we created the tip frame. */ | ||
| 3885 | face_change_count = face_change_count_before; | ||
| 3837 | 3886 | ||
| 3887 | /* Discard the unwind_protect. */ | ||
| 3838 | return unbind_to (count, frame); | 3888 | return unbind_to (count, frame); |
| 3839 | #endif /* MAC_TODO */ | 3889 | } |
| 3840 | return Qnil; | 3890 | |
| 3891 | |||
| 3892 | /* Compute where to display tip frame F. PARMS is the list of frame | ||
| 3893 | parameters for F. DX and DY are specified offsets from the current | ||
| 3894 | location of the mouse. WIDTH and HEIGHT are the width and height | ||
| 3895 | of the tooltip. Return coordinates relative to the root window of | ||
| 3896 | the display in *ROOT_X, and *ROOT_Y. */ | ||
| 3897 | |||
| 3898 | static void | ||
| 3899 | compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) | ||
| 3900 | struct frame *f; | ||
| 3901 | Lisp_Object parms, dx, dy; | ||
| 3902 | int width, height; | ||
| 3903 | int *root_x, *root_y; | ||
| 3904 | { | ||
| 3905 | Lisp_Object left, top; | ||
| 3906 | |||
| 3907 | /* User-specified position? */ | ||
| 3908 | left = Fcdr (Fassq (Qleft, parms)); | ||
| 3909 | top = Fcdr (Fassq (Qtop, parms)); | ||
| 3910 | |||
| 3911 | /* Move the tooltip window where the mouse pointer is. Resize and | ||
| 3912 | show it. */ | ||
| 3913 | if (!INTEGERP (left) || !INTEGERP (top)) | ||
| 3914 | { | ||
| 3915 | Point mouse_pos; | ||
| 3916 | |||
| 3917 | BLOCK_INPUT; | ||
| 3918 | GetMouse (&mouse_pos); | ||
| 3919 | LocalToGlobal (&mouse_pos); | ||
| 3920 | *root_x = mouse_pos.h; | ||
| 3921 | *root_y = mouse_pos.v; | ||
| 3922 | UNBLOCK_INPUT; | ||
| 3923 | } | ||
| 3924 | |||
| 3925 | if (INTEGERP (top)) | ||
| 3926 | *root_y = XINT (top); | ||
| 3927 | else if (*root_y + XINT (dy) - height < 0) | ||
| 3928 | *root_y -= XINT (dy); | ||
| 3929 | else | ||
| 3930 | { | ||
| 3931 | *root_y -= height; | ||
| 3932 | *root_y += XINT (dy); | ||
| 3933 | } | ||
| 3934 | |||
| 3935 | if (INTEGERP (left)) | ||
| 3936 | *root_x = XINT (left); | ||
| 3937 | else if (*root_x + XINT (dx) + width <= FRAME_MAC_DISPLAY_INFO (f)->width) | ||
| 3938 | /* It fits to the right of the pointer. */ | ||
| 3939 | *root_x += XINT (dx); | ||
| 3940 | else if (width + XINT (dx) <= *root_x) | ||
| 3941 | /* It fits to the left of the pointer. */ | ||
| 3942 | *root_x -= width + XINT (dx); | ||
| 3943 | else | ||
| 3944 | /* Put it left-justified on the screen -- it ought to fit that way. */ | ||
| 3945 | *root_x = 0; | ||
| 3841 | } | 3946 | } |
| 3842 | 3947 | ||
| 3843 | 3948 | ||
| 3844 | DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, | 3949 | DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, |
| 3845 | doc : /* Show STRING in a "tooltip" window on frame FRAME. | 3950 | doc: /* Show STRING in a "tooltip" window on frame FRAME. |
| 3846 | A tooltip window is a small window displaying a string. | 3951 | A tooltip window is a small X window displaying a string. |
| 3847 | 3952 | ||
| 3848 | FRAME nil or omitted means use the selected frame. | 3953 | FRAME nil or omitted means use the selected frame. |
| 3849 | 3954 | ||
| @@ -3859,19 +3964,19 @@ displayed at the mouse position, with offset DX added (default is 5 if | |||
| 3859 | DX isn't specified). Likewise for the y-position; if a `top' frame | 3964 | DX isn't specified). Likewise for the y-position; if a `top' frame |
| 3860 | parameter is specified, it determines the y-position of the tooltip | 3965 | parameter is specified, it determines the y-position of the tooltip |
| 3861 | window, otherwise it is displayed at the mouse position, with offset | 3966 | window, otherwise it is displayed at the mouse position, with offset |
| 3862 | DY added (default is 10). */) | 3967 | DY added (default is -10). |
| 3863 | (string, frame, parms, timeout, dx, dy) | 3968 | |
| 3969 | A tooltip's maximum size is specified by `x-max-tooltip-size'. | ||
| 3970 | Text larger than the specified size is clipped. */) | ||
| 3971 | (string, frame, parms, timeout, dx, dy) | ||
| 3864 | Lisp_Object string, frame, parms, timeout, dx, dy; | 3972 | Lisp_Object string, frame, parms, timeout, dx, dy; |
| 3865 | { | 3973 | { |
| 3866 | struct frame *f; | 3974 | struct frame *f; |
| 3867 | struct window *w; | 3975 | struct window *w; |
| 3868 | Window root, child; | 3976 | int root_x, root_y; |
| 3869 | Lisp_Object buffer, top, left; | ||
| 3870 | struct buffer *old_buffer; | 3977 | struct buffer *old_buffer; |
| 3871 | struct text_pos pos; | 3978 | struct text_pos pos; |
| 3872 | int i, width, height; | 3979 | int i, width, height; |
| 3873 | int root_x, root_y, win_x, win_y; | ||
| 3874 | unsigned pmask; | ||
| 3875 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; | 3980 | struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; |
| 3876 | int old_windows_or_buffers_changed = windows_or_buffers_changed; | 3981 | int old_windows_or_buffers_changed = windows_or_buffers_changed; |
| 3877 | int count = SPECPDL_INDEX (); | 3982 | int count = SPECPDL_INDEX (); |
| @@ -3920,13 +4025,11 @@ DY added (default is 10). */) | |||
| 3920 | call1 (Qcancel_timer, timer); | 4025 | call1 (Qcancel_timer, timer); |
| 3921 | } | 4026 | } |
| 3922 | 4027 | ||
| 3923 | #if 0 /* MAC_TODO : Mac specifics */ | ||
| 3924 | BLOCK_INPUT; | 4028 | BLOCK_INPUT; |
| 3925 | compute_tip_xy (f, parms, dx, dy, &root_x, &root_y); | 4029 | compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f), |
| 3926 | XMoveWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), | 4030 | FRAME_PIXEL_HEIGHT (f), &root_x, &root_y); |
| 3927 | root_x, root_y - FRAME_PIXEL_HEIGHT (f)); | 4031 | MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false); |
| 3928 | UNBLOCK_INPUT; | 4032 | UNBLOCK_INPUT; |
| 3929 | #endif /* MAC_TODO */ | ||
| 3930 | goto start_timer; | 4033 | goto start_timer; |
| 3931 | } | 4034 | } |
| 3932 | } | 4035 | } |
| @@ -3953,26 +4056,36 @@ DY added (default is 10). */) | |||
| 3953 | 4056 | ||
| 3954 | /* Create a frame for the tooltip, and record it in the global | 4057 | /* Create a frame for the tooltip, and record it in the global |
| 3955 | variable tip_frame. */ | 4058 | variable tip_frame. */ |
| 3956 | frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms); | 4059 | frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms, string); |
| 3957 | f = XFRAME (frame); | 4060 | f = XFRAME (frame); |
| 3958 | 4061 | ||
| 3959 | /* Set up the frame's root window. Currently we use a size of 80 | 4062 | /* Set up the frame's root window. */ |
| 3960 | columns x 40 lines. If someone wants to show a larger tip, he | ||
| 3961 | will loose. I don't think this is a realistic case. */ | ||
| 3962 | w = XWINDOW (FRAME_ROOT_WINDOW (f)); | 4063 | w = XWINDOW (FRAME_ROOT_WINDOW (f)); |
| 3963 | w->left_col = w->top_line = make_number (0); | 4064 | w->left_col = w->top_line = make_number (0); |
| 3964 | w->total_cols = make_number (80); | 4065 | |
| 3965 | w->total_lines = make_number (40); | 4066 | if (CONSP (Vx_max_tooltip_size) |
| 4067 | && INTEGERP (XCAR (Vx_max_tooltip_size)) | ||
| 4068 | && XINT (XCAR (Vx_max_tooltip_size)) > 0 | ||
| 4069 | && INTEGERP (XCDR (Vx_max_tooltip_size)) | ||
| 4070 | && XINT (XCDR (Vx_max_tooltip_size)) > 0) | ||
| 4071 | { | ||
| 4072 | w->total_cols = XCAR (Vx_max_tooltip_size); | ||
| 4073 | w->total_lines = XCDR (Vx_max_tooltip_size); | ||
| 4074 | } | ||
| 4075 | else | ||
| 4076 | { | ||
| 4077 | w->total_cols = make_number (80); | ||
| 4078 | w->total_lines = make_number (40); | ||
| 4079 | } | ||
| 4080 | |||
| 4081 | FRAME_TOTAL_COLS (f) = XINT (w->total_cols); | ||
| 3966 | adjust_glyphs (f); | 4082 | adjust_glyphs (f); |
| 3967 | w->pseudo_window_p = 1; | 4083 | w->pseudo_window_p = 1; |
| 3968 | 4084 | ||
| 3969 | /* Display the tooltip text in a temporary buffer. */ | 4085 | /* Display the tooltip text in a temporary buffer. */ |
| 3970 | buffer = Fget_buffer_create (build_string (" *tip*")); | ||
| 3971 | Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil); | ||
| 3972 | old_buffer = current_buffer; | 4086 | old_buffer = current_buffer; |
| 3973 | set_buffer_internal_1 (XBUFFER (buffer)); | 4087 | set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer)); |
| 3974 | Ferase_buffer (); | 4088 | current_buffer->truncate_lines = Qnil; |
| 3975 | Finsert (1, &string); | ||
| 3976 | clear_glyph_matrix (w->desired_matrix); | 4089 | clear_glyph_matrix (w->desired_matrix); |
| 3977 | clear_glyph_matrix (w->current_matrix); | 4090 | clear_glyph_matrix (w->current_matrix); |
| 3978 | SET_TEXT_POS (pos, BEGV, BEGV_BYTE); | 4091 | SET_TEXT_POS (pos, BEGV, BEGV_BYTE); |
| @@ -3993,7 +4106,7 @@ DY added (default is 10). */) | |||
| 3993 | /* Let the row go over the full width of the frame. */ | 4106 | /* Let the row go over the full width of the frame. */ |
| 3994 | row->full_width_p = 1; | 4107 | row->full_width_p = 1; |
| 3995 | 4108 | ||
| 3996 | /* There's a glyph at the end of rows that is use to place | 4109 | /* There's a glyph at the end of rows that is used to place |
| 3997 | the cursor there. Don't include the width of this glyph. */ | 4110 | the cursor there. Don't include the width of this glyph. */ |
| 3998 | if (row->used[TEXT_AREA]) | 4111 | if (row->used[TEXT_AREA]) |
| 3999 | { | 4112 | { |
| @@ -4014,17 +4127,13 @@ DY added (default is 10). */) | |||
| 4014 | 4127 | ||
| 4015 | /* Move the tooltip window where the mouse pointer is. Resize and | 4128 | /* Move the tooltip window where the mouse pointer is. Resize and |
| 4016 | show it. */ | 4129 | show it. */ |
| 4017 | #if 0 /* TODO : Mac specifics */ | 4130 | compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); |
| 4018 | compute_tip_xy (f, parms, dx, dy, &root_x, &root_y); | ||
| 4019 | 4131 | ||
| 4020 | BLOCK_INPUT; | 4132 | BLOCK_INPUT; |
| 4021 | XQueryPointer (FRAME_W32_DISPLAY (f), FRAME_W32_DISPLAY_INFO (f)->root_window, | 4133 | MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false); |
| 4022 | &root, &child, &root_x, &root_y, &win_x, &win_y, &pmask); | 4134 | SizeWindow (FRAME_MAC_WINDOW (f), width, height, true); |
| 4023 | XMoveResizeWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), | 4135 | BringToFront (FRAME_MAC_WINDOW (f)); |
| 4024 | root_x + 5, root_y - height - 5, width, height); | ||
| 4025 | XMapRaised (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f)); | ||
| 4026 | UNBLOCK_INPUT; | 4136 | UNBLOCK_INPUT; |
| 4027 | #endif /* MAC_TODO */ | ||
| 4028 | 4137 | ||
| 4029 | /* Draw into the window. */ | 4138 | /* Draw into the window. */ |
| 4030 | w->must_be_updated_p = 1; | 4139 | w->must_be_updated_p = 1; |
| @@ -4046,8 +4155,8 @@ DY added (default is 10). */) | |||
| 4046 | 4155 | ||
| 4047 | DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, | 4156 | DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0, |
| 4048 | doc: /* Hide the current tooltip window, if there is any. | 4157 | doc: /* Hide the current tooltip window, if there is any. |
| 4049 | Value is t is tooltip was open, nil otherwise. */) | 4158 | Value is t if tooltip was open, nil otherwise. */) |
| 4050 | () | 4159 | () |
| 4051 | { | 4160 | { |
| 4052 | int count; | 4161 | int count; |
| 4053 | Lisp_Object deleted, frame, timer; | 4162 | Lisp_Object deleted, frame, timer; |
| @@ -4249,7 +4358,8 @@ syms_of_macfns () | |||
| 4249 | staticpro (&Qsuppress_icon); | 4358 | staticpro (&Qsuppress_icon); |
| 4250 | Qundefined_color = intern ("undefined-color"); | 4359 | Qundefined_color = intern ("undefined-color"); |
| 4251 | staticpro (&Qundefined_color); | 4360 | staticpro (&Qundefined_color); |
| 4252 | /* This is the end of symbol initialization. */ | 4361 | Qcancel_timer = intern ("cancel-timer"); |
| 4362 | staticpro (&Qcancel_timer); | ||
| 4253 | 4363 | ||
| 4254 | Qhyper = intern ("hyper"); | 4364 | Qhyper = intern ("hyper"); |
| 4255 | staticpro (&Qhyper); | 4365 | staticpro (&Qhyper); |
| @@ -4265,6 +4375,7 @@ syms_of_macfns () | |||
| 4265 | staticpro (&Qcontrol); | 4375 | staticpro (&Qcontrol); |
| 4266 | Qshift = intern ("shift"); | 4376 | Qshift = intern ("shift"); |
| 4267 | staticpro (&Qshift); | 4377 | staticpro (&Qshift); |
| 4378 | /* This is the end of symbol initialization. */ | ||
| 4268 | 4379 | ||
| 4269 | /* Text property `display' should be nonsticky by default. */ | 4380 | /* Text property `display' should be nonsticky by default. */ |
| 4270 | Vtext_property_default_nonsticky | 4381 | Vtext_property_default_nonsticky |
| @@ -4314,6 +4425,11 @@ or when you set the mouse color. */); | |||
| 4314 | doc: /* A string indicating the foreground color of the cursor box. */); | 4425 | doc: /* A string indicating the foreground color of the cursor box. */); |
| 4315 | Vx_cursor_fore_pixel = Qnil; | 4426 | Vx_cursor_fore_pixel = Qnil; |
| 4316 | 4427 | ||
| 4428 | DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size, | ||
| 4429 | doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS). | ||
| 4430 | Text larger than this is clipped. */); | ||
| 4431 | Vx_max_tooltip_size = Fcons (make_number (80), make_number (40)); | ||
| 4432 | |||
| 4317 | DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, | 4433 | DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, |
| 4318 | doc: /* Non-nil if no window manager is in use. | 4434 | doc: /* Non-nil if no window manager is in use. |
| 4319 | Emacs doesn't try to figure this out; this is always nil | 4435 | Emacs doesn't try to figure this out; this is always nil |
| @@ -4386,6 +4502,9 @@ Chinese, Japanese, and Korean. */); | |||
| 4386 | tip_frame = Qnil; | 4502 | tip_frame = Qnil; |
| 4387 | staticpro (&tip_frame); | 4503 | staticpro (&tip_frame); |
| 4388 | 4504 | ||
| 4505 | last_show_tip_args = Qnil; | ||
| 4506 | staticpro (&last_show_tip_args); | ||
| 4507 | |||
| 4389 | #if 0 /* MAC_TODO */ | 4508 | #if 0 /* MAC_TODO */ |
| 4390 | defsubr (&Sx_file_dialog); | 4509 | defsubr (&Sx_file_dialog); |
| 4391 | #endif | 4510 | #endif |
diff --git a/src/macgui.h b/src/macgui.h index 2bb346e9d30..58081df52b4 100644 --- a/src/macgui.h +++ b/src/macgui.h | |||
| @@ -57,16 +57,27 @@ typedef unsigned long Time; | |||
| 57 | #undef init_process | 57 | #undef init_process |
| 58 | #define init_process emacs_init_process | 58 | #define init_process emacs_init_process |
| 59 | #undef INFINITY | 59 | #undef INFINITY |
| 60 | typedef struct OpaqueWindowPtr* Window; | ||
| 61 | #else | 60 | #else |
| 62 | #include <QuickDraw.h> /* for WindowPtr */ | 61 | #include <QuickDraw.h> /* for WindowPtr */ |
| 63 | #include <QDOffscreen.h> /* for GWorldPtr */ | 62 | #include <QDOffscreen.h> /* for GWorldPtr */ |
| 64 | #include <Controls.h> /* for ControlHandle in xdisp.c */ | 63 | #include <Controls.h> /* for ControlHandle in xdisp.c */ |
| 65 | typedef WindowPtr Window; | 64 | #include <Gestalt.h> |
| 66 | #endif | 65 | #endif |
| 67 | 66 | ||
| 68 | typedef GWorldPtr Pixmap; | 67 | typedef GWorldPtr Pixmap; |
| 69 | 68 | ||
| 69 | #if TARGET_API_MAC_CARBON | ||
| 70 | typedef struct OpaqueWindowPtr *Window; | ||
| 71 | #define Cursor ThemeCursor | ||
| 72 | #define No_Cursor (-1) | ||
| 73 | #else | ||
| 74 | typedef WindowPtr Window; | ||
| 75 | #define SetPortWindowPort(w) SetPort(w) | ||
| 76 | #define Cursor CursHandle | ||
| 77 | #define No_Cursor (0) | ||
| 78 | extern CursPtr arrow_cursor; | ||
| 79 | #endif | ||
| 80 | |||
| 70 | #define FACE_DEFAULT (~0) | 81 | #define FACE_DEFAULT (~0) |
| 71 | 82 | ||
| 72 | 83 | ||
diff --git a/src/macmenu.c b/src/macmenu.c index de768d4aea5..d205ee3b877 100644 --- a/src/macmenu.c +++ b/src/macmenu.c | |||
| @@ -1784,11 +1784,7 @@ mac_menu_show (f, x, y, for_click, keymaps, title, error) | |||
| 1784 | pos.h = x; | 1784 | pos.h = x; |
| 1785 | pos.v = y; | 1785 | pos.v = y; |
| 1786 | 1786 | ||
| 1787 | #if TARGET_API_MAC_CARBON | 1787 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 1788 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 1789 | #else | ||
| 1790 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 1791 | #endif | ||
| 1792 | 1788 | ||
| 1793 | LocalToGlobal (&pos); | 1789 | LocalToGlobal (&pos); |
| 1794 | 1790 | ||
| @@ -1942,11 +1938,7 @@ mac_dialog (widget_value *wv) | |||
| 1942 | 1938 | ||
| 1943 | window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1); | 1939 | window_ptr = GetNewCWindow (DIALOG_WINDOW_RESOURCE, NULL, (WindowPtr) -1); |
| 1944 | 1940 | ||
| 1945 | #if TARGET_API_MAC_CARBON | 1941 | SetPortWindowPort (window_ptr); |
| 1946 | SetPort (GetWindowPort (window_ptr)); | ||
| 1947 | #else | ||
| 1948 | SetPort (window_ptr); | ||
| 1949 | #endif | ||
| 1950 | 1942 | ||
| 1951 | TextFont (0); | 1943 | TextFont (0); |
| 1952 | /* Left and right margins in the dialog are 13 pixels each.*/ | 1944 | /* Left and right margins in the dialog are 13 pixels each.*/ |
| @@ -1964,11 +1956,7 @@ mac_dialog (widget_value *wv) | |||
| 1964 | SizeWindow (window_ptr, dialog_width, 78, 0); | 1956 | SizeWindow (window_ptr, dialog_width, 78, 0); |
| 1965 | ShowWindow (window_ptr); | 1957 | ShowWindow (window_ptr); |
| 1966 | 1958 | ||
| 1967 | #if TARGET_API_MAC_CARBON | 1959 | SetPortWindowPort (window_ptr); |
| 1968 | SetPort (GetWindowPort (window_ptr)); | ||
| 1969 | #else | ||
| 1970 | SetPort (window_ptr); | ||
| 1971 | #endif | ||
| 1972 | 1960 | ||
| 1973 | TextFont (0); | 1961 | TextFont (0); |
| 1974 | 1962 | ||
diff --git a/src/macterm.c b/src/macterm.c index 9351fd5e36f..6a3cad56f46 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -53,7 +53,6 @@ Boston, MA 02111-1307, USA. */ | |||
| 53 | #if defined (__MRC__) || (__MSL__ >= 0x6000) | 53 | #if defined (__MRC__) || (__MSL__ >= 0x6000) |
| 54 | #include <ControlDefinitions.h> | 54 | #include <ControlDefinitions.h> |
| 55 | #endif | 55 | #endif |
| 56 | #include <Gestalt.h> | ||
| 57 | 56 | ||
| 58 | #if __profile__ | 57 | #if __profile__ |
| 59 | #include <profiler.h> | 58 | #include <profiler.h> |
| @@ -196,14 +195,6 @@ static Lisp_Object last_mouse_scroll_bar; | |||
| 196 | 195 | ||
| 197 | static Time last_mouse_movement_time; | 196 | static Time last_mouse_movement_time; |
| 198 | 197 | ||
| 199 | enum mouse_tracking_type { | ||
| 200 | mouse_tracking_none, | ||
| 201 | mouse_tracking_mouse_movement, | ||
| 202 | mouse_tracking_scroll_bar | ||
| 203 | }; | ||
| 204 | |||
| 205 | enum mouse_tracking_type mouse_tracking_in_progress = mouse_tracking_none; | ||
| 206 | |||
| 207 | struct scroll_bar *tracked_scroll_bar = NULL; | 198 | struct scroll_bar *tracked_scroll_bar = NULL; |
| 208 | 199 | ||
| 209 | /* Incremented by XTread_socket whenever it really tries to read | 200 | /* Incremented by XTread_socket whenever it really tries to read |
| @@ -364,11 +355,7 @@ XDrawLine (display, w, gc, x1, y1, x2, y2) | |||
| 364 | GC gc; | 355 | GC gc; |
| 365 | int x1, y1, x2, y2; | 356 | int x1, y1, x2, y2; |
| 366 | { | 357 | { |
| 367 | #if TARGET_API_MAC_CARBON | 358 | SetPortWindowPort (w); |
| 368 | SetPort (GetWindowPort (w)); | ||
| 369 | #else | ||
| 370 | SetPort (w); | ||
| 371 | #endif | ||
| 372 | 359 | ||
| 373 | mac_set_colors (gc); | 360 | mac_set_colors (gc); |
| 374 | 361 | ||
| @@ -416,11 +403,7 @@ XClearArea (display, w, x, y, width, height, exposures) | |||
| 416 | xgc.foreground = mwp->x_compatible.foreground_pixel; | 403 | xgc.foreground = mwp->x_compatible.foreground_pixel; |
| 417 | xgc.background = mwp->x_compatible.background_pixel; | 404 | xgc.background = mwp->x_compatible.background_pixel; |
| 418 | 405 | ||
| 419 | #if TARGET_API_MAC_CARBON | 406 | SetPortWindowPort (w); |
| 420 | SetPort (GetWindowPort (w)); | ||
| 421 | #else | ||
| 422 | SetPort (w); | ||
| 423 | #endif | ||
| 424 | 407 | ||
| 425 | mac_set_colors (&xgc); | 408 | mac_set_colors (&xgc); |
| 426 | SetRect (&r, x, y, x + width, y + height); | 409 | SetRect (&r, x, y, x + width, y + height); |
| @@ -441,11 +424,7 @@ XClearWindow (display, w) | |||
| 441 | xgc.foreground = mwp->x_compatible.foreground_pixel; | 424 | xgc.foreground = mwp->x_compatible.foreground_pixel; |
| 442 | xgc.background = mwp->x_compatible.background_pixel; | 425 | xgc.background = mwp->x_compatible.background_pixel; |
| 443 | 426 | ||
| 444 | #if TARGET_API_MAC_CARBON | 427 | SetPortWindowPort (w); |
| 445 | SetPort (GetWindowPort (w)); | ||
| 446 | #else | ||
| 447 | SetPort (w); | ||
| 448 | #endif | ||
| 449 | 428 | ||
| 450 | mac_set_colors (&xgc); | 429 | mac_set_colors (&xgc); |
| 451 | 430 | ||
| @@ -480,11 +459,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) | |||
| 480 | bitmap.baseAddr = (char *)bits; | 459 | bitmap.baseAddr = (char *)bits; |
| 481 | SetRect (&(bitmap.bounds), 0, 0, width, height); | 460 | SetRect (&(bitmap.bounds), 0, 0, width, height); |
| 482 | 461 | ||
| 483 | #if TARGET_API_MAC_CARBON | 462 | SetPortWindowPort (w); |
| 484 | SetPort (GetWindowPort (w)); | ||
| 485 | #else | ||
| 486 | SetPort (w); | ||
| 487 | #endif | ||
| 488 | 463 | ||
| 489 | mac_set_colors (gc); | 464 | mac_set_colors (gc); |
| 490 | SetRect (&r, x, y, x + width, y + height); | 465 | SetRect (&r, x, y, x + width, y + height); |
| @@ -509,11 +484,7 @@ mac_set_clip_rectangle (display, w, r) | |||
| 509 | WindowPtr w; | 484 | WindowPtr w; |
| 510 | Rect *r; | 485 | Rect *r; |
| 511 | { | 486 | { |
| 512 | #if TARGET_API_MAC_CARBON | 487 | SetPortWindowPort (w); |
| 513 | SetPort (GetWindowPort (w)); | ||
| 514 | #else | ||
| 515 | SetPort (w); | ||
| 516 | #endif | ||
| 517 | 488 | ||
| 518 | ClipRect (r); | 489 | ClipRect (r); |
| 519 | } | 490 | } |
| @@ -528,11 +499,7 @@ mac_reset_clipping (display, w) | |||
| 528 | { | 499 | { |
| 529 | Rect r; | 500 | Rect r; |
| 530 | 501 | ||
| 531 | #if TARGET_API_MAC_CARBON | 502 | SetPortWindowPort (w); |
| 532 | SetPort (GetWindowPort (w)); | ||
| 533 | #else | ||
| 534 | SetPort (w); | ||
| 535 | #endif | ||
| 536 | 503 | ||
| 537 | SetRect (&r, -32767, -32767, 32767, 32767); | 504 | SetRect (&r, -32767, -32767, 32767, 32767); |
| 538 | ClipRect (&r); | 505 | ClipRect (&r); |
| @@ -601,11 +568,7 @@ XCreatePixmap (display, w, width, height, depth) | |||
| 601 | Rect r; | 568 | Rect r; |
| 602 | QDErr err; | 569 | QDErr err; |
| 603 | 570 | ||
| 604 | #if TARGET_API_MAC_CARBON | 571 | SetPortWindowPort (w); |
| 605 | SetPort (GetWindowPort (w)); | ||
| 606 | #else | ||
| 607 | SetPort (w); | ||
| 608 | #endif | ||
| 609 | 572 | ||
| 610 | SetRect (&r, 0, 0, width, height); | 573 | SetRect (&r, 0, 0, width, height); |
| 611 | err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0); | 574 | err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0); |
| @@ -666,11 +629,7 @@ XFillRectangle (display, w, gc, x, y, width, height) | |||
| 666 | { | 629 | { |
| 667 | Rect r; | 630 | Rect r; |
| 668 | 631 | ||
| 669 | #if TARGET_API_MAC_CARBON | 632 | SetPortWindowPort (w); |
| 670 | SetPort (GetWindowPort (w)); | ||
| 671 | #else | ||
| 672 | SetPort (w); | ||
| 673 | #endif | ||
| 674 | 633 | ||
| 675 | mac_set_colors (gc); | 634 | mac_set_colors (gc); |
| 676 | SetRect (&r, x, y, x + width, y + height); | 635 | SetRect (&r, x, y, x + width, y + height); |
| @@ -716,11 +675,7 @@ mac_draw_rectangle (display, w, gc, x, y, width, height) | |||
| 716 | { | 675 | { |
| 717 | Rect r; | 676 | Rect r; |
| 718 | 677 | ||
| 719 | #if TARGET_API_MAC_CARBON | 678 | SetPortWindowPort (w); |
| 720 | SetPort (GetWindowPort (w)); | ||
| 721 | #else | ||
| 722 | SetPort (w); | ||
| 723 | #endif | ||
| 724 | 679 | ||
| 725 | mac_set_colors (gc); | 680 | mac_set_colors (gc); |
| 726 | SetRect (&r, x, y, x + width + 1, y + height + 1); | 681 | SetRect (&r, x, y, x + width + 1, y + height + 1); |
| @@ -766,11 +721,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, | |||
| 766 | char *buf; | 721 | char *buf; |
| 767 | int nchars, mode, bytes_per_char; | 722 | int nchars, mode, bytes_per_char; |
| 768 | { | 723 | { |
| 769 | #if TARGET_API_MAC_CARBON | 724 | SetPortWindowPort (w); |
| 770 | SetPort (GetWindowPort (w)); | ||
| 771 | #else | ||
| 772 | SetPort (w); | ||
| 773 | #endif | ||
| 774 | 725 | ||
| 775 | mac_set_colors (gc); | 726 | mac_set_colors (gc); |
| 776 | 727 | ||
| @@ -861,11 +812,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x, | |||
| 861 | { | 812 | { |
| 862 | Rect src_r, dest_r; | 813 | Rect src_r, dest_r; |
| 863 | 814 | ||
| 864 | #if TARGET_API_MAC_CARBON | 815 | SetPortWindowPort (dest); |
| 865 | SetPort (GetWindowPort (dest)); | ||
| 866 | #else | ||
| 867 | SetPort (dest); | ||
| 868 | #endif | ||
| 869 | 816 | ||
| 870 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 817 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 871 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); | 818 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); |
| @@ -901,11 +848,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y, | |||
| 901 | { | 848 | { |
| 902 | Rect src_r, dest_r; | 849 | Rect src_r, dest_r; |
| 903 | 850 | ||
| 904 | #if TARGET_API_MAC_CARBON | 851 | SetPortWindowPort (dest); |
| 905 | SetPort (GetWindowPort (dest)); | ||
| 906 | #else | ||
| 907 | SetPort (dest); | ||
| 908 | #endif | ||
| 909 | 852 | ||
| 910 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 853 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 911 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); | 854 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); |
| @@ -965,7 +908,7 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) | |||
| 965 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); | 908 | SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); |
| 966 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); | 909 | SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); |
| 967 | 910 | ||
| 968 | SetPort (GetWindowPort (w)); | 911 | SetPortWindowPort (w); |
| 969 | 912 | ||
| 970 | ForeColor (blackColor); | 913 | ForeColor (blackColor); |
| 971 | BackColor (whiteColor); | 914 | BackColor (whiteColor); |
| @@ -1290,7 +1233,7 @@ x_update_window_begin (w) | |||
| 1290 | { | 1233 | { |
| 1291 | int i; | 1234 | int i; |
| 1292 | 1235 | ||
| 1293 | for (i = 0; i < w->desired_matrix->nrows; ++i) | 1236 | for (i = 0; i < w->desired_matrix->nrows; ++i) |
| 1294 | if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) | 1237 | if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) |
| 1295 | break; | 1238 | break; |
| 1296 | 1239 | ||
| @@ -1385,11 +1328,7 @@ x_update_end (f) | |||
| 1385 | /* Reset the background color of Mac OS Window to that of the frame after | 1328 | /* Reset the background color of Mac OS Window to that of the frame after |
| 1386 | update so that it is used by Mac Toolbox to clear the update region before | 1329 | update so that it is used by Mac Toolbox to clear the update region before |
| 1387 | an update event is generated. */ | 1330 | an update event is generated. */ |
| 1388 | #if TARGET_API_MAC_CARBON | 1331 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 1389 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 1390 | #else | ||
| 1391 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 1392 | #endif | ||
| 1393 | 1332 | ||
| 1394 | mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); | 1333 | mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); |
| 1395 | 1334 | ||
| @@ -3745,11 +3684,7 @@ construct_mouse_click (result, event, f) | |||
| 3745 | 3684 | ||
| 3746 | mouseLoc = event->where; | 3685 | mouseLoc = event->where; |
| 3747 | 3686 | ||
| 3748 | #if TARGET_API_MAC_CARBON | 3687 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 3749 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 3750 | #else | ||
| 3751 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 3752 | #endif | ||
| 3753 | 3688 | ||
| 3754 | GlobalToLocal (&mouseLoc); | 3689 | GlobalToLocal (&mouseLoc); |
| 3755 | XSETINT (result->x, mouseLoc.h); | 3690 | XSETINT (result->x, mouseLoc.h); |
| @@ -3778,6 +3713,7 @@ note_mouse_movement (frame, pos) | |||
| 3778 | FRAME_PTR frame; | 3713 | FRAME_PTR frame; |
| 3779 | Point *pos; | 3714 | Point *pos; |
| 3780 | { | 3715 | { |
| 3716 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame); | ||
| 3781 | #if TARGET_API_MAC_CARBON | 3717 | #if TARGET_API_MAC_CARBON |
| 3782 | Rect r; | 3718 | Rect r; |
| 3783 | #endif | 3719 | #endif |
| @@ -3792,9 +3728,17 @@ note_mouse_movement (frame, pos) | |||
| 3792 | if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect)) | 3728 | if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect)) |
| 3793 | #endif | 3729 | #endif |
| 3794 | { | 3730 | { |
| 3795 | frame->mouse_moved = 1; | 3731 | if (frame == dpyinfo->mouse_face_mouse_frame) |
| 3796 | last_mouse_scroll_bar = Qnil; | 3732 | /* This case corresponds to LeaveNotify in X11. */ |
| 3797 | note_mouse_highlight (frame, -1, -1); | 3733 | { |
| 3734 | /* If we move outside the frame, then we're certainly no | ||
| 3735 | longer on any text in the frame. */ | ||
| 3736 | clear_mouse_face (dpyinfo); | ||
| 3737 | dpyinfo->mouse_face_mouse_frame = 0; | ||
| 3738 | if (!dpyinfo->grabbed) | ||
| 3739 | rif->define_frame_cursor (frame, | ||
| 3740 | frame->output_data.mac->nontext_cursor); | ||
| 3741 | } | ||
| 3798 | } | 3742 | } |
| 3799 | /* Has the mouse moved off the glyph it was on at the last sighting? */ | 3743 | /* Has the mouse moved off the glyph it was on at the last sighting? */ |
| 3800 | else if (pos->h < last_mouse_glyph.left | 3744 | else if (pos->h < last_mouse_glyph.left |
| @@ -3942,6 +3886,23 @@ remember_mouse_glyph (f1, gx, gy) | |||
| 3942 | } | 3886 | } |
| 3943 | 3887 | ||
| 3944 | 3888 | ||
| 3889 | static WindowPtr | ||
| 3890 | mac_front_window () | ||
| 3891 | { | ||
| 3892 | #if TARGET_API_MAC_CARBON | ||
| 3893 | return GetFrontWindowOfClass (kDocumentWindowClass, true); | ||
| 3894 | #else | ||
| 3895 | WindowPtr front_window = FrontWindow (); | ||
| 3896 | |||
| 3897 | if (tip_window && front_window == tip_window) | ||
| 3898 | return GetNextWindow (front_window); | ||
| 3899 | else | ||
| 3900 | return front_window; | ||
| 3901 | #endif | ||
| 3902 | } | ||
| 3903 | |||
| 3904 | #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP) | ||
| 3905 | |||
| 3945 | /* Return the current position of the mouse. | 3906 | /* Return the current position of the mouse. |
| 3946 | *fp should be a frame which indicates which display to ask about. | 3907 | *fp should be a frame which indicates which display to ask about. |
| 3947 | 3908 | ||
| @@ -3973,12 +3934,12 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) | |||
| 3973 | { | 3934 | { |
| 3974 | Point mouse_pos; | 3935 | Point mouse_pos; |
| 3975 | int ignore1, ignore2; | 3936 | int ignore1, ignore2; |
| 3976 | WindowPtr wp = FrontWindow (); | 3937 | WindowPtr wp = mac_front_window (); |
| 3977 | struct frame *f; | 3938 | struct frame *f; |
| 3978 | Lisp_Object frame, tail; | 3939 | Lisp_Object frame, tail; |
| 3979 | 3940 | ||
| 3980 | if (is_emacs_window(wp)) | 3941 | if (is_emacs_window(wp)) |
| 3981 | f = ((mac_output *) GetWRefCon (wp))->mFP; | 3942 | f = mac_window_to_frame (wp); |
| 3982 | 3943 | ||
| 3983 | BLOCK_INPUT; | 3944 | BLOCK_INPUT; |
| 3984 | 3945 | ||
| @@ -3992,11 +3953,7 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time) | |||
| 3992 | 3953 | ||
| 3993 | last_mouse_scroll_bar = Qnil; | 3954 | last_mouse_scroll_bar = Qnil; |
| 3994 | 3955 | ||
| 3995 | #if TARGET_API_MAC_CARBON | 3956 | SetPortWindowPort (wp); |
| 3996 | SetPort (GetWindowPort (wp)); | ||
| 3997 | #else | ||
| 3998 | SetPort (wp); | ||
| 3999 | #endif | ||
| 4000 | 3957 | ||
| 4001 | GetMouse (&mouse_pos); | 3958 | GetMouse (&mouse_pos); |
| 4002 | 3959 | ||
| @@ -4491,6 +4448,8 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp) | |||
| 4491 | EventRecord *er; | 4448 | EventRecord *er; |
| 4492 | struct input_event *bufp; | 4449 | struct input_event *bufp; |
| 4493 | { | 4450 | { |
| 4451 | int win_y, top_range; | ||
| 4452 | |||
| 4494 | if (! GC_WINDOWP (bar->window)) | 4453 | if (! GC_WINDOWP (bar->window)) |
| 4495 | abort (); | 4454 | abort (); |
| 4496 | 4455 | ||
| @@ -4525,6 +4484,24 @@ x_scroll_bar_handle_click (bar, part_code, er, bufp) | |||
| 4525 | bufp->part = scroll_bar_handle; | 4484 | bufp->part = scroll_bar_handle; |
| 4526 | break; | 4485 | break; |
| 4527 | } | 4486 | } |
| 4487 | |||
| 4488 | win_y = XINT (bufp->y) - XINT (bar->top); | ||
| 4489 | top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height)); | ||
| 4490 | |||
| 4491 | win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER; | ||
| 4492 | |||
| 4493 | win_y -= 24; | ||
| 4494 | |||
| 4495 | if (! NILP (bar->dragging)) | ||
| 4496 | win_y -= XINT (bar->dragging); | ||
| 4497 | |||
| 4498 | if (win_y < 0) | ||
| 4499 | win_y = 0; | ||
| 4500 | if (win_y > top_range) | ||
| 4501 | win_y = top_range; | ||
| 4502 | |||
| 4503 | XSETINT (bufp->x, win_y); | ||
| 4504 | XSETINT (bufp->y, top_range); | ||
| 4528 | } | 4505 | } |
| 4529 | 4506 | ||
| 4530 | 4507 | ||
| @@ -4574,16 +4551,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) | |||
| 4574 | unsigned long *time; | 4551 | unsigned long *time; |
| 4575 | { | 4552 | { |
| 4576 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); | 4553 | struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); |
| 4577 | WindowPtr wp = FrontWindow (); | 4554 | WindowPtr wp = mac_front_window (); |
| 4578 | Point mouse_pos; | 4555 | Point mouse_pos; |
| 4579 | struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; | 4556 | struct frame *f = mac_window_to_frame (wp); |
| 4580 | int win_y, top_range; | 4557 | int win_y, top_range; |
| 4581 | 4558 | ||
| 4582 | #if TARGET_API_MAC_CARBON | 4559 | SetPortWindowPort (wp); |
| 4583 | SetPort (GetWindowPort (wp)); | ||
| 4584 | #else | ||
| 4585 | SetPort (wp); | ||
| 4586 | #endif | ||
| 4587 | 4560 | ||
| 4588 | GetMouse (&mouse_pos); | 4561 | GetMouse (&mouse_pos); |
| 4589 | 4562 | ||
| @@ -4810,7 +4783,11 @@ mac_define_frame_cursor (f, cursor) | |||
| 4810 | struct frame *f; | 4783 | struct frame *f; |
| 4811 | Cursor cursor; | 4784 | Cursor cursor; |
| 4812 | { | 4785 | { |
| 4813 | /* MAC TODO */ | 4786 | #if TARGET_API_MAC_CARBON |
| 4787 | SetThemeCursor (cursor); | ||
| 4788 | #else | ||
| 4789 | SetCursor (*cursor); | ||
| 4790 | #endif | ||
| 4814 | } | 4791 | } |
| 4815 | 4792 | ||
| 4816 | 4793 | ||
| @@ -5078,11 +5055,7 @@ x_calc_absolute_position (f) | |||
| 5078 | GrafPtr savePort; | 5055 | GrafPtr savePort; |
| 5079 | GetPort (&savePort); | 5056 | GetPort (&savePort); |
| 5080 | 5057 | ||
| 5081 | #if TARGET_API_MAC_CARBON | 5058 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 5082 | SetPort (GetWindowPort (FRAME_MAC_WINDOW (f))); | ||
| 5083 | #else | ||
| 5084 | SetPort (FRAME_MAC_WINDOW (f)); | ||
| 5085 | #endif | ||
| 5086 | 5059 | ||
| 5087 | #if TARGET_API_MAC_CARBON | 5060 | #if TARGET_API_MAC_CARBON |
| 5088 | { | 5061 | { |
| @@ -5457,10 +5430,15 @@ x_free_frame_resources (f) | |||
| 5457 | struct frame *f; | 5430 | struct frame *f; |
| 5458 | { | 5431 | { |
| 5459 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); | 5432 | struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); |
| 5433 | WindowPtr wp = FRAME_MAC_WINDOW (f); | ||
| 5460 | 5434 | ||
| 5461 | BLOCK_INPUT; | 5435 | BLOCK_INPUT; |
| 5462 | 5436 | ||
| 5463 | DisposeWindow (FRAME_MAC_WINDOW (f)); | 5437 | DisposeWindow (wp); |
| 5438 | if (wp == tip_window) | ||
| 5439 | /* Neither WaitNextEvent nor ReceiveNextEvent receives `window | ||
| 5440 | closed' event. So we reset tip_window here. */ | ||
| 5441 | tip_window = NULL; | ||
| 5464 | 5442 | ||
| 5465 | free_frame_menubar (f); | 5443 | free_frame_menubar (f); |
| 5466 | 5444 | ||
| @@ -6984,6 +6962,11 @@ Lisp_Object drag_and_drop_file_list; | |||
| 6984 | 6962 | ||
| 6985 | Point saved_menu_event_location; | 6963 | Point saved_menu_event_location; |
| 6986 | 6964 | ||
| 6965 | #if !TARGET_API_MAC_CARBON | ||
| 6966 | /* Place holder for the default arrow cursor. */ | ||
| 6967 | CursPtr arrow_cursor; | ||
| 6968 | #endif | ||
| 6969 | |||
| 6987 | /* Apple Events */ | 6970 | /* Apple Events */ |
| 6988 | static void init_required_apple_events (void); | 6971 | static void init_required_apple_events (void); |
| 6989 | static pascal OSErr | 6972 | static pascal OSErr |
| @@ -7170,6 +7153,8 @@ do_init_managers (void) | |||
| 7170 | InitCursor (); | 7153 | InitCursor (); |
| 7171 | 7154 | ||
| 7172 | #if !TARGET_API_MAC_CARBON | 7155 | #if !TARGET_API_MAC_CARBON |
| 7156 | arrow_cursor = &qd.arrow; | ||
| 7157 | |||
| 7173 | /* set up some extra stack space for use by emacs */ | 7158 | /* set up some extra stack space for use by emacs */ |
| 7174 | SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); | 7159 | SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); |
| 7175 | 7160 | ||
| @@ -7198,8 +7183,12 @@ do_check_ram_size (void) | |||
| 7198 | static void | 7183 | static void |
| 7199 | do_window_update (WindowPtr win) | 7184 | do_window_update (WindowPtr win) |
| 7200 | { | 7185 | { |
| 7201 | struct mac_output *mwp = (mac_output *) GetWRefCon (win); | 7186 | struct frame *f = mac_window_to_frame (win); |
| 7202 | struct frame *f = mwp->mFP; | 7187 | |
| 7188 | if (win == tip_window) | ||
| 7189 | /* The tooltip has been drawn already. Avoid the | ||
| 7190 | SET_FRAME_GARBAGED below. */ | ||
| 7191 | return; | ||
| 7203 | 7192 | ||
| 7204 | if (f) | 7193 | if (f) |
| 7205 | { | 7194 | { |
| @@ -7250,13 +7239,11 @@ is_emacs_window (WindowPtr win) | |||
| 7250 | static void | 7239 | static void |
| 7251 | do_window_activate (WindowPtr win) | 7240 | do_window_activate (WindowPtr win) |
| 7252 | { | 7241 | { |
| 7253 | mac_output *mwp; | ||
| 7254 | struct frame *f; | 7242 | struct frame *f; |
| 7255 | 7243 | ||
| 7256 | if (is_emacs_window (win)) | 7244 | if (is_emacs_window (win)) |
| 7257 | { | 7245 | { |
| 7258 | mwp = (mac_output *) GetWRefCon (win); | 7246 | f = mac_window_to_frame (win); |
| 7259 | f = mwp->mFP; | ||
| 7260 | 7247 | ||
| 7261 | if (f) | 7248 | if (f) |
| 7262 | { | 7249 | { |
| @@ -7269,13 +7256,11 @@ do_window_activate (WindowPtr win) | |||
| 7269 | static void | 7256 | static void |
| 7270 | do_window_deactivate (WindowPtr win) | 7257 | do_window_deactivate (WindowPtr win) |
| 7271 | { | 7258 | { |
| 7272 | mac_output *mwp; | ||
| 7273 | struct frame *f; | 7259 | struct frame *f; |
| 7274 | 7260 | ||
| 7275 | if (is_emacs_window (win)) | 7261 | if (is_emacs_window (win)) |
| 7276 | { | 7262 | { |
| 7277 | mwp = (mac_output *) GetWRefCon (win); | 7263 | f = mac_window_to_frame (win); |
| 7278 | f = mwp->mFP; | ||
| 7279 | 7264 | ||
| 7280 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) | 7265 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) |
| 7281 | { | 7266 | { |
| @@ -7289,14 +7274,12 @@ static void | |||
| 7289 | do_app_resume () | 7274 | do_app_resume () |
| 7290 | { | 7275 | { |
| 7291 | WindowPtr wp; | 7276 | WindowPtr wp; |
| 7292 | mac_output *mwp; | ||
| 7293 | struct frame *f; | 7277 | struct frame *f; |
| 7294 | 7278 | ||
| 7295 | wp = FrontWindow(); | 7279 | wp = mac_front_window (); |
| 7296 | if (is_emacs_window (wp)) | 7280 | if (is_emacs_window (wp)) |
| 7297 | { | 7281 | { |
| 7298 | mwp = (mac_output *) GetWRefCon (wp); | 7282 | f = mac_window_to_frame (wp); |
| 7299 | f = mwp->mFP; | ||
| 7300 | 7283 | ||
| 7301 | if (f) | 7284 | if (f) |
| 7302 | { | 7285 | { |
| @@ -7313,14 +7296,12 @@ static void | |||
| 7313 | do_app_suspend () | 7296 | do_app_suspend () |
| 7314 | { | 7297 | { |
| 7315 | WindowPtr wp; | 7298 | WindowPtr wp; |
| 7316 | mac_output *mwp; | ||
| 7317 | struct frame *f; | 7299 | struct frame *f; |
| 7318 | 7300 | ||
| 7319 | wp = FrontWindow(); | 7301 | wp = mac_front_window (); |
| 7320 | if (is_emacs_window (wp)) | 7302 | if (is_emacs_window (wp)) |
| 7321 | { | 7303 | { |
| 7322 | mwp = (mac_output *) GetWRefCon (wp); | 7304 | f = mac_window_to_frame (wp); |
| 7323 | f = mwp->mFP; | ||
| 7324 | 7305 | ||
| 7325 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) | 7306 | if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) |
| 7326 | { | 7307 | { |
| @@ -7335,67 +7316,38 @@ do_app_suspend () | |||
| 7335 | 7316 | ||
| 7336 | 7317 | ||
| 7337 | static void | 7318 | static void |
| 7338 | do_mouse_moved (Point mouse_pos) | 7319 | do_mouse_moved (mouse_pos, f) |
| 7320 | Point mouse_pos; | ||
| 7321 | FRAME_PTR *f; | ||
| 7339 | { | 7322 | { |
| 7340 | WindowPtr wp = FrontWindow (); | 7323 | WindowPtr wp = mac_front_window (); |
| 7341 | struct frame *f; | 7324 | struct x_display_info *dpyinfo; |
| 7342 | 7325 | ||
| 7343 | if (is_emacs_window (wp)) | 7326 | if (is_emacs_window (wp)) |
| 7344 | { | 7327 | { |
| 7345 | f = ((mac_output *) GetWRefCon (wp))->mFP; | 7328 | *f = mac_window_to_frame (wp); |
| 7329 | dpyinfo = FRAME_MAC_DISPLAY_INFO (*f); | ||
| 7346 | 7330 | ||
| 7347 | #if TARGET_API_MAC_CARBON | 7331 | if (dpyinfo->mouse_face_hidden) |
| 7348 | SetPort (GetWindowPort (wp)); | 7332 | { |
| 7349 | #else | 7333 | dpyinfo->mouse_face_hidden = 0; |
| 7350 | SetPort (wp); | 7334 | clear_mouse_face (dpyinfo); |
| 7351 | #endif | 7335 | } |
| 7352 | |||
| 7353 | GlobalToLocal (&mouse_pos); | ||
| 7354 | 7336 | ||
| 7355 | note_mouse_movement (f, &mouse_pos); | 7337 | SetPortWindowPort (wp); |
| 7356 | } | ||
| 7357 | } | ||
| 7358 | 7338 | ||
| 7339 | GlobalToLocal (&mouse_pos); | ||
| 7359 | 7340 | ||
| 7360 | static void | 7341 | if (dpyinfo->grabbed && tracked_scroll_bar) |
| 7361 | do_os_event (EventRecord *erp) | 7342 | x_scroll_bar_note_movement (tracked_scroll_bar, |
| 7362 | { | 7343 | mouse_pos.v |
| 7363 | switch((erp->message >> 24) & 0x000000FF) | 7344 | - XINT (tracked_scroll_bar->top), |
| 7364 | { | 7345 | TickCount() * (1000 / 60)); |
| 7365 | case suspendResumeMessage: | ||
| 7366 | if((erp->message & resumeFlag) == 1) | ||
| 7367 | do_app_resume (); | ||
| 7368 | else | 7346 | else |
| 7369 | do_app_suspend (); | 7347 | note_mouse_movement (*f, &mouse_pos); |
| 7370 | break; | ||
| 7371 | |||
| 7372 | case mouseMovedMessage: | ||
| 7373 | do_mouse_moved (erp->where); | ||
| 7374 | break; | ||
| 7375 | } | 7348 | } |
| 7376 | } | 7349 | } |
| 7377 | 7350 | ||
| 7378 | static void | ||
| 7379 | do_events (EventRecord *erp) | ||
| 7380 | { | ||
| 7381 | switch (erp->what) | ||
| 7382 | { | ||
| 7383 | case updateEvt: | ||
| 7384 | do_window_update ((WindowPtr) erp->message); | ||
| 7385 | break; | ||
| 7386 | |||
| 7387 | case osEvt: | ||
| 7388 | do_os_event (erp); | ||
| 7389 | break; | ||
| 7390 | |||
| 7391 | case activateEvt: | ||
| 7392 | if ((erp->modifiers & activeFlag) != 0) | ||
| 7393 | do_window_activate ((WindowPtr) erp->message); | ||
| 7394 | else | ||
| 7395 | do_window_deactivate ((WindowPtr) erp->message); | ||
| 7396 | break; | ||
| 7397 | } | ||
| 7398 | } | ||
| 7399 | 7351 | ||
| 7400 | static void | 7352 | static void |
| 7401 | do_apple_menu (SInt16 menu_item) | 7353 | do_apple_menu (SInt16 menu_item) |
| @@ -7433,8 +7385,7 @@ do_menu_choice (SInt32 menu_choice) | |||
| 7433 | 7385 | ||
| 7434 | default: | 7386 | default: |
| 7435 | { | 7387 | { |
| 7436 | WindowPtr wp = FrontWindow (); | 7388 | struct frame *f = mac_window_to_frame (mac_front_window ()); |
| 7437 | struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; | ||
| 7438 | MenuHandle menu = GetMenuHandle (menu_id); | 7389 | MenuHandle menu = GetMenuHandle (menu_id); |
| 7439 | if (menu) | 7390 | if (menu) |
| 7440 | { | 7391 | { |
| @@ -7459,8 +7410,7 @@ do_grow_window (WindowPtr w, EventRecord *e) | |||
| 7459 | long grow_size; | 7410 | long grow_size; |
| 7460 | Rect limit_rect; | 7411 | Rect limit_rect; |
| 7461 | int rows, columns; | 7412 | int rows, columns; |
| 7462 | mac_output *mwp = (mac_output *) GetWRefCon (w); | 7413 | struct frame *f = mac_window_to_frame (w); |
| 7463 | struct frame *f = mwp->mFP; | ||
| 7464 | 7414 | ||
| 7465 | SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); | 7415 | SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); |
| 7466 | 7416 | ||
| @@ -7489,16 +7439,11 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7489 | Rect zoom_rect, port_rect; | 7439 | Rect zoom_rect, port_rect; |
| 7490 | Point top_left; | 7440 | Point top_left; |
| 7491 | int w_title_height, columns, rows, width, height, dummy, x, y; | 7441 | int w_title_height, columns, rows, width, height, dummy, x, y; |
| 7492 | mac_output *mwp = (mac_output *) GetWRefCon (w); | 7442 | struct frame *f = mac_window_to_frame (w); |
| 7493 | struct frame *f = mwp->mFP; | ||
| 7494 | 7443 | ||
| 7495 | GetPort (&save_port); | 7444 | GetPort (&save_port); |
| 7496 | 7445 | ||
| 7497 | #if TARGET_API_MAC_CARBON | 7446 | SetPortWindowPort (w); |
| 7498 | SetPort (GetWindowPort (w)); | ||
| 7499 | #else | ||
| 7500 | SetPort (w); | ||
| 7501 | #endif | ||
| 7502 | 7447 | ||
| 7503 | /* Clear window to avoid flicker. */ | 7448 | /* Clear window to avoid flicker. */ |
| 7504 | #if TARGET_API_MAC_CARBON | 7449 | #if TARGET_API_MAC_CARBON |
| @@ -7551,7 +7496,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7551 | } | 7496 | } |
| 7552 | #endif /* not TARGET_API_MAC_CARBON */ | 7497 | #endif /* not TARGET_API_MAC_CARBON */ |
| 7553 | 7498 | ||
| 7554 | ZoomWindow (w, zoom_in_or_out, w == FrontWindow ()); | 7499 | ZoomWindow (w, zoom_in_or_out, w == mac_front_window ()); |
| 7555 | 7500 | ||
| 7556 | /* retrieve window size and update application values */ | 7501 | /* retrieve window size and update application values */ |
| 7557 | #if TARGET_API_MAC_CARBON | 7502 | #if TARGET_API_MAC_CARBON |
| @@ -7561,7 +7506,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) | |||
| 7561 | #endif | 7506 | #endif |
| 7562 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); | 7507 | rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); |
| 7563 | columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); | 7508 | columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); |
| 7564 | x_set_window_size (mwp->mFP, 0, columns, rows); | 7509 | x_set_window_size (f, 0, columns, rows); |
| 7565 | 7510 | ||
| 7566 | SetPort (save_port); | 7511 | SetPort (save_port); |
| 7567 | } | 7512 | } |
| @@ -7892,8 +7837,8 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon, | |||
| 7892 | { | 7837 | { |
| 7893 | struct input_event event; | 7838 | struct input_event event; |
| 7894 | Lisp_Object frame; | 7839 | Lisp_Object frame; |
| 7895 | struct frame *f = ((mac_output *) GetWRefCon(window))->mFP; | 7840 | struct frame *f = mac_window_to_frame (window); |
| 7896 | SetPort (GetWindowPort (window)); | 7841 | SetPortWindowPort (window); |
| 7897 | GlobalToLocal (&mouse); | 7842 | GlobalToLocal (&mouse); |
| 7898 | 7843 | ||
| 7899 | event.kind = DRAG_N_DROP_EVENT; | 7844 | event.kind = DRAG_N_DROP_EVENT; |
| @@ -8067,26 +8012,26 @@ keycode_to_xkeysym (int keyCode, int *xKeySym) | |||
| 8067 | /* Emacs calls this whenever it wants to read an input event from the | 8012 | /* Emacs calls this whenever it wants to read an input event from the |
| 8068 | user. */ | 8013 | user. */ |
| 8069 | int | 8014 | int |
| 8070 | XTread_socket (int sd, int expected, struct input_event *hold_quit) | 8015 | XTread_socket (sd, expected, hold_quit) |
| 8016 | int sd, expected; | ||
| 8017 | struct input_event *hold_quit; | ||
| 8071 | { | 8018 | { |
| 8072 | struct input_event inev; | 8019 | struct input_event inev; |
| 8073 | int count = 0; | 8020 | int count = 0; |
| 8074 | #if USE_CARBON_EVENTS | 8021 | #if USE_CARBON_EVENTS |
| 8075 | OSStatus rneResult; | ||
| 8076 | EventRef eventRef; | 8022 | EventRef eventRef; |
| 8077 | EventMouseButton mouseBtn; | 8023 | EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget (); |
| 8024 | #else | ||
| 8025 | EventMask event_mask; | ||
| 8078 | #endif | 8026 | #endif |
| 8079 | EventRecord er; | 8027 | EventRecord er; |
| 8080 | int the_modifiers; | 8028 | struct mac_display_info *dpyinfo = &one_mac_display_info; |
| 8081 | EventMask event_mask; | ||
| 8082 | 8029 | ||
| 8083 | #if 0 | ||
| 8084 | if (interrupt_input_blocked) | 8030 | if (interrupt_input_blocked) |
| 8085 | { | 8031 | { |
| 8086 | interrupt_input_pending = 1; | 8032 | interrupt_input_pending = 1; |
| 8087 | return -1; | 8033 | return -1; |
| 8088 | } | 8034 | } |
| 8089 | #endif | ||
| 8090 | 8035 | ||
| 8091 | interrupt_input_pending = 0; | 8036 | interrupt_input_pending = 0; |
| 8092 | BLOCK_INPUT; | 8037 | BLOCK_INPUT; |
| @@ -8108,26 +8053,33 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8108 | if (terminate_flag) | 8053 | if (terminate_flag) |
| 8109 | Fkill_emacs (make_number (1)); | 8054 | Fkill_emacs (make_number (1)); |
| 8110 | 8055 | ||
| 8111 | /* It is necessary to set this (additional) argument slot of an | 8056 | #if !USE_CARBON_EVENTS |
| 8112 | event to nil because keyboard.c protects incompletely processed | ||
| 8113 | event from being garbage collected by placing them in the | ||
| 8114 | kbd_buffer_gcpro vector. */ | ||
| 8115 | EVENT_INIT (inev); | ||
| 8116 | inev.kind = NO_EVENT; | ||
| 8117 | inev.arg = Qnil; | ||
| 8118 | |||
| 8119 | event_mask = everyEvent; | 8057 | event_mask = everyEvent; |
| 8120 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) | 8058 | if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) |
| 8121 | event_mask -= highLevelEventMask; | 8059 | event_mask -= highLevelEventMask; |
| 8122 | 8060 | ||
| 8123 | #if USE_CARBON_EVENTS | 8061 | while (WaitNextEvent (event_mask, &er, |
| 8124 | rneResult = ReceiveNextEvent (0, NULL, | 8062 | (expected ? app_sleep_time : 0L), NULL)) |
| 8125 | expected | 8063 | #else |
| 8126 | ? TicksToEventTime (app_sleep_time) | 8064 | while (!ReceiveNextEvent (0, NULL, |
| 8127 | : 0, | 8065 | (expected ? TicksToEventTime (app_sleep_time) : 0), |
| 8128 | kEventRemoveFromQueue, &eventRef); | 8066 | kEventRemoveFromQueue, &eventRef)) |
| 8129 | if (!rneResult) | 8067 | #endif /* !USE_CARBON_EVENTS */ |
| 8130 | { | 8068 | { |
| 8069 | int do_help = 0; | ||
| 8070 | struct frame *f; | ||
| 8071 | |||
| 8072 | expected = 0; | ||
| 8073 | |||
| 8074 | /* It is necessary to set this (additional) argument slot of an | ||
| 8075 | event to nil because keyboard.c protects incompletely | ||
| 8076 | processed event from being garbage collected by placing them | ||
| 8077 | in the kbd_buffer_gcpro vector. */ | ||
| 8078 | EVENT_INIT (inev); | ||
| 8079 | inev.kind = NO_EVENT; | ||
| 8080 | inev.arg = Qnil; | ||
| 8081 | |||
| 8082 | #if USE_CARBON_EVENTS | ||
| 8131 | /* Handle new events */ | 8083 | /* Handle new events */ |
| 8132 | if (!mac_convert_event_ref (eventRef, &er)) | 8084 | if (!mac_convert_event_ref (eventRef, &er)) |
| 8133 | switch (GetEventClass (eventRef)) | 8085 | switch (GetEventClass (eventRef)) |
| @@ -8137,13 +8089,12 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8137 | { | 8089 | { |
| 8138 | SInt32 delta; | 8090 | SInt32 delta; |
| 8139 | Point point; | 8091 | Point point; |
| 8140 | WindowPtr window_ptr = FrontNonFloatingWindow (); | 8092 | WindowPtr window_ptr = mac_front_window (); |
| 8141 | struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | 8093 | |
| 8142 | if (!IsValidWindowPtr (window_ptr)) | 8094 | if (!IsValidWindowPtr (window_ptr)) |
| 8143 | { | 8095 | { |
| 8144 | SysBeep(1); | 8096 | SysBeep(1); |
| 8145 | UNBLOCK_INPUT; | 8097 | break; |
| 8146 | return 0; | ||
| 8147 | } | 8098 | } |
| 8148 | 8099 | ||
| 8149 | GetEventParameter(eventRef, kEventParamMouseWheelDelta, | 8100 | GetEventParameter(eventRef, kEventParamMouseWheelDelta, |
| @@ -8154,459 +8105,557 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8154 | NULL, &point); | 8105 | NULL, &point); |
| 8155 | inev.kind = WHEEL_EVENT; | 8106 | inev.kind = WHEEL_EVENT; |
| 8156 | inev.code = 0; | 8107 | inev.code = 0; |
| 8157 | inev.modifiers = (mac_event_to_emacs_modifiers(eventRef) | 8108 | inev.modifiers = (mac_event_to_emacs_modifiers (eventRef) |
| 8158 | | ((delta < 0) ? down_modifier | 8109 | | ((delta < 0) ? down_modifier |
| 8159 | : up_modifier)); | 8110 | : up_modifier)); |
| 8160 | SetPort (GetWindowPort (window_ptr)); | 8111 | SetPortWindowPort (window_ptr); |
| 8161 | GlobalToLocal (&point); | 8112 | GlobalToLocal (&point); |
| 8162 | XSETINT (inev.x, point.h); | 8113 | XSETINT (inev.x, point.h); |
| 8163 | XSETINT (inev.y, point.v); | 8114 | XSETINT (inev.y, point.v); |
| 8164 | XSETFRAME (inev.frame_or_window, mwp->mFP); | 8115 | XSETFRAME (inev.frame_or_window, |
| 8116 | mac_window_to_frame (window_ptr)); | ||
| 8165 | inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); | 8117 | inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); |
| 8166 | } | 8118 | } |
| 8167 | else | 8119 | else |
| 8168 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | 8120 | SendEventToEventTarget (eventRef, toolbox_dispatcher); |
| 8169 | 8121 | ||
| 8170 | break; | 8122 | break; |
| 8171 | default: | 8123 | default: |
| 8172 | /* Send the event to the appropriate receiver. */ | 8124 | /* Send the event to the appropriate receiver. */ |
| 8173 | SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); | 8125 | SendEventToEventTarget (eventRef, toolbox_dispatcher); |
| 8174 | } | 8126 | } |
| 8175 | else | 8127 | else |
| 8176 | #else | ||
| 8177 | if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL)) | ||
| 8178 | #endif /* USE_CARBON_EVENTS */ | 8128 | #endif /* USE_CARBON_EVENTS */ |
| 8179 | switch (er.what) | 8129 | switch (er.what) |
| 8180 | { | ||
| 8181 | case mouseDown: | ||
| 8182 | case mouseUp: | ||
| 8183 | { | 8130 | { |
| 8184 | WindowPtr window_ptr = FrontWindow (); | 8131 | case mouseDown: |
| 8185 | SInt16 part_code; | 8132 | case mouseUp: |
| 8133 | { | ||
| 8134 | WindowPtr window_ptr; | ||
| 8135 | SInt16 part_code; | ||
| 8136 | int tool_bar_p = 0; | ||
| 8137 | |||
| 8138 | if (dpyinfo->grabbed && last_mouse_frame | ||
| 8139 | && FRAME_LIVE_P (last_mouse_frame)) | ||
| 8140 | { | ||
| 8141 | window_ptr = FRAME_MAC_WINDOW (last_mouse_frame); | ||
| 8142 | part_code = inContent; | ||
| 8143 | } | ||
| 8144 | else | ||
| 8145 | { | ||
| 8146 | window_ptr = FrontWindow (); | ||
| 8147 | if (tip_window && window_ptr == tip_window) | ||
| 8148 | { | ||
| 8149 | HideWindow (tip_window); | ||
| 8150 | window_ptr = FrontWindow (); | ||
| 8151 | } | ||
| 8186 | 8152 | ||
| 8187 | #if USE_CARBON_EVENTS | 8153 | #if USE_CARBON_EVENTS |
| 8188 | /* This is needed to send mouse events like aqua window buttons | 8154 | /* This is needed to send mouse events like aqua |
| 8189 | to the correct handler. */ | 8155 | window buttons to the correct handler. */ |
| 8190 | if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) { | 8156 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8191 | break; | 8157 | != eventNotHandledErr) |
| 8192 | } | 8158 | break; |
| 8193 | 8159 | ||
| 8194 | if (!is_emacs_window(window_ptr)) | 8160 | if (!is_emacs_window (window_ptr)) |
| 8195 | break; | 8161 | break; |
| 8196 | #endif | 8162 | #endif |
| 8163 | part_code = FindWindow (er.where, &window_ptr); | ||
| 8164 | } | ||
| 8165 | |||
| 8166 | switch (part_code) | ||
| 8167 | { | ||
| 8168 | case inMenuBar: | ||
| 8169 | if (er.what == mouseDown) | ||
| 8170 | { | ||
| 8171 | f = mac_window_to_frame (mac_front_window ()); | ||
| 8172 | saved_menu_event_location = er.where; | ||
| 8173 | inev.kind = MENU_BAR_ACTIVATE_EVENT; | ||
| 8174 | XSETFRAME (inev.frame_or_window, f); | ||
| 8175 | } | ||
| 8176 | break; | ||
| 8197 | 8177 | ||
| 8198 | if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | 8178 | case inContent: |
| 8199 | && er.what == mouseUp) | 8179 | if (window_ptr != mac_front_window ()) |
| 8200 | { | 8180 | SelectWindow (window_ptr); |
| 8201 | struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); | 8181 | else |
| 8202 | Point mouse_loc = er.where; | 8182 | { |
| 8183 | SInt16 control_part_code; | ||
| 8184 | ControlHandle ch; | ||
| 8185 | Point mouse_loc = er.where; | ||
| 8186 | |||
| 8187 | f = mac_window_to_frame (window_ptr); | ||
| 8188 | /* convert to local coordinates of new window */ | ||
| 8189 | SetPortWindowPort (window_ptr); | ||
| 8203 | 8190 | ||
| 8204 | /* Convert to local coordinates of new window. */ | 8191 | GlobalToLocal (&mouse_loc); |
| 8205 | #if TARGET_API_MAC_CARBON | 8192 | #if TARGET_API_MAC_CARBON |
| 8206 | SetPort (GetWindowPort (window_ptr)); | 8193 | ch = FindControlUnderMouse (mouse_loc, window_ptr, |
| 8194 | &control_part_code); | ||
| 8207 | #else | 8195 | #else |
| 8208 | SetPort (window_ptr); | 8196 | control_part_code = FindControl (mouse_loc, window_ptr, |
| 8197 | &ch); | ||
| 8209 | #endif | 8198 | #endif |
| 8210 | 8199 | ||
| 8211 | GlobalToLocal (&mouse_loc); | ||
| 8212 | |||
| 8213 | #if USE_CARBON_EVENTS | 8200 | #if USE_CARBON_EVENTS |
| 8214 | inev.code = mac_get_mouse_btn (eventRef); | 8201 | inev.code = mac_get_mouse_btn (eventRef); |
| 8202 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | ||
| 8215 | #else | 8203 | #else |
| 8216 | inev.code = mac_get_emulate_btn (er.modifiers); | 8204 | inev.code = mac_get_emulated_btn (er.modifiers); |
| 8205 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | ||
| 8217 | #endif | 8206 | #endif |
| 8218 | inev.kind = SCROLL_BAR_CLICK_EVENT; | 8207 | XSETINT (inev.x, mouse_loc.h); |
| 8219 | inev.frame_or_window = tracked_scroll_bar->window; | 8208 | XSETINT (inev.y, mouse_loc.v); |
| 8220 | inev.part = scroll_bar_handle; | 8209 | inev.timestamp = er.when * (1000 / 60); |
| 8221 | #if USE_CARBON_EVENTS | 8210 | /* ticks to milliseconds */ |
| 8222 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8211 | |
| 8212 | if (dpyinfo->grabbed && tracked_scroll_bar | ||
| 8213 | #if TARGET_API_MAC_CARBON | ||
| 8214 | || ch != 0 | ||
| 8223 | #else | 8215 | #else |
| 8224 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8216 | || control_part_code != 0 |
| 8225 | #endif | 8217 | #endif |
| 8226 | inev.modifiers |= up_modifier; | 8218 | ) |
| 8227 | inev.timestamp = er.when * (1000 / 60); | 8219 | { |
| 8228 | /* ticks to milliseconds */ | 8220 | struct scroll_bar *bar; |
| 8221 | |||
| 8222 | if (dpyinfo->grabbed && tracked_scroll_bar) | ||
| 8223 | { | ||
| 8224 | bar = tracked_scroll_bar; | ||
| 8225 | control_part_code = kControlIndicatorPart; | ||
| 8226 | } | ||
| 8227 | else | ||
| 8228 | bar = (struct scroll_bar *) GetControlReference (ch); | ||
| 8229 | x_scroll_bar_handle_click (bar, control_part_code, | ||
| 8230 | &er, &inev); | ||
| 8231 | if (er.what == mouseDown | ||
| 8232 | && control_part_code == kControlIndicatorPart) | ||
| 8233 | tracked_scroll_bar = bar; | ||
| 8234 | else | ||
| 8235 | tracked_scroll_bar = NULL; | ||
| 8236 | } | ||
| 8237 | else | ||
| 8238 | { | ||
| 8239 | Lisp_Object window; | ||
| 8240 | int x = mouse_loc.h; | ||
| 8241 | int y = mouse_loc.v; | ||
| 8242 | |||
| 8243 | window = window_from_coordinates (f, x, y, 0, 0, 0, 1); | ||
| 8244 | if (EQ (window, f->tool_bar_window)) | ||
| 8245 | { | ||
| 8246 | if (er.what == mouseDown) | ||
| 8247 | handle_tool_bar_click (f, x, y, 1, 0); | ||
| 8248 | else | ||
| 8249 | handle_tool_bar_click (f, x, y, 0, | ||
| 8250 | inev.modifiers); | ||
| 8251 | tool_bar_p = 1; | ||
| 8252 | } | ||
| 8253 | else | ||
| 8254 | { | ||
| 8255 | XSETFRAME (inev.frame_or_window, f); | ||
| 8256 | inev.kind = MOUSE_CLICK_EVENT; | ||
| 8257 | } | ||
| 8258 | } | ||
| 8259 | |||
| 8260 | if (er.what == mouseDown) | ||
| 8261 | { | ||
| 8262 | dpyinfo->grabbed |= (1 << inev.code); | ||
| 8263 | last_mouse_frame = f; | ||
| 8264 | /* Ignore any mouse motion that happened | ||
| 8265 | before this event; any subsequent | ||
| 8266 | mouse-movement Emacs events should reflect | ||
| 8267 | only motion after the ButtonPress. */ | ||
| 8268 | if (f != 0) | ||
| 8269 | f->mouse_moved = 0; | ||
| 8270 | |||
| 8271 | if (!tool_bar_p) | ||
| 8272 | last_tool_bar_item = -1; | ||
| 8273 | } | ||
| 8274 | else | ||
| 8275 | { | ||
| 8276 | if (dpyinfo->grabbed & (1 << inev.code) == 0) | ||
| 8277 | /* If a button is released though it was not | ||
| 8278 | previously pressed, that would be because | ||
| 8279 | of multi-button emulation. */ | ||
| 8280 | dpyinfo->grabbed = 0; | ||
| 8281 | else | ||
| 8282 | dpyinfo->grabbed &= ~(1 << inev.code); | ||
| 8283 | } | ||
| 8284 | |||
| 8285 | switch (er.what) | ||
| 8286 | { | ||
| 8287 | case mouseDown: | ||
| 8288 | inev.modifiers |= down_modifier; | ||
| 8289 | break; | ||
| 8290 | case mouseUp: | ||
| 8291 | inev.modifiers |= up_modifier; | ||
| 8292 | break; | ||
| 8293 | } | ||
| 8294 | } | ||
| 8295 | break; | ||
| 8229 | 8296 | ||
| 8230 | XSETINT (inev.x, XFASTINT (tracked_scroll_bar->left) + 2); | 8297 | case inDrag: |
| 8231 | XSETINT (inev.y, mouse_loc.v - 24); | 8298 | #if TARGET_API_MAC_CARBON |
| 8232 | tracked_scroll_bar->dragging = Qnil; | 8299 | if (er.what == mouseDown) |
| 8233 | mouse_tracking_in_progress = mouse_tracking_none; | 8300 | { |
| 8234 | tracked_scroll_bar = NULL; | 8301 | BitMap bm; |
| 8235 | break; | ||
| 8236 | } | ||
| 8237 | 8302 | ||
| 8238 | part_code = FindWindow (er.where, &window_ptr); | 8303 | GetQDGlobalsScreenBits (&bm); |
| 8304 | DragWindow (window_ptr, er.where, &bm.bounds); | ||
| 8305 | } | ||
| 8306 | #else /* not TARGET_API_MAC_CARBON */ | ||
| 8307 | DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | ||
| 8308 | #endif /* not TARGET_API_MAC_CARBON */ | ||
| 8309 | break; | ||
| 8239 | 8310 | ||
| 8240 | switch (part_code) | 8311 | case inGoAway: |
| 8241 | { | 8312 | if (TrackGoAway (window_ptr, er.where)) |
| 8242 | case inMenuBar: | 8313 | { |
| 8243 | if (er.what == mouseDown) | 8314 | inev.kind = DELETE_WINDOW_EVENT; |
| 8244 | { | 8315 | XSETFRAME (inev.frame_or_window, |
| 8245 | struct frame *f = ((mac_output *) | 8316 | mac_window_to_frame (window_ptr)); |
| 8246 | GetWRefCon (FrontWindow ()))->mFP; | 8317 | } |
| 8247 | saved_menu_event_location = er.where; | 8318 | break; |
| 8248 | inev.kind = MENU_BAR_ACTIVATE_EVENT; | ||
| 8249 | XSETFRAME (inev.frame_or_window, f); | ||
| 8250 | } | ||
| 8251 | break; | ||
| 8252 | 8319 | ||
| 8253 | case inContent: | 8320 | /* window resize handling added --ben */ |
| 8254 | if (window_ptr != FrontWindow ()) | 8321 | case inGrow: |
| 8255 | SelectWindow (window_ptr); | 8322 | if (er.what == mouseDown) |
| 8256 | else | 8323 | { |
| 8257 | { | 8324 | do_grow_window(window_ptr, &er); |
| 8258 | SInt16 control_part_code; | 8325 | break; |
| 8259 | ControlHandle ch; | 8326 | } |
| 8260 | struct mac_output *mwp = (mac_output *) | ||
| 8261 | GetWRefCon (window_ptr); | ||
| 8262 | Point mouse_loc = er.where; | ||
| 8263 | |||
| 8264 | /* convert to local coordinates of new window */ | ||
| 8265 | #if TARGET_API_MAC_CARBON | ||
| 8266 | SetPort (GetWindowPort (window_ptr)); | ||
| 8267 | #else | ||
| 8268 | SetPort (window_ptr); | ||
| 8269 | #endif | ||
| 8270 | 8327 | ||
| 8271 | GlobalToLocal (&mouse_loc); | 8328 | /* window zoom handling added --ben */ |
| 8272 | #if TARGET_API_MAC_CARBON | 8329 | case inZoomIn: |
| 8273 | ch = FindControlUnderMouse (mouse_loc, window_ptr, | 8330 | case inZoomOut: |
| 8274 | &control_part_code); | 8331 | if (TrackBox (window_ptr, er.where, part_code)) |
| 8275 | #else | 8332 | do_zoom_window (window_ptr, part_code); |
| 8276 | control_part_code = FindControl (mouse_loc, window_ptr, &ch); | 8333 | break; |
| 8277 | #endif | ||
| 8278 | 8334 | ||
| 8279 | #if USE_CARBON_EVENTS | 8335 | default: |
| 8280 | inev.code = mac_get_mouse_btn (eventRef); | 8336 | break; |
| 8281 | #else | 8337 | } |
| 8282 | inev.code = mac_get_emulate_btn (er.modifiers); | 8338 | } |
| 8283 | #endif | 8339 | break; |
| 8284 | XSETINT (inev.x, mouse_loc.h); | ||
| 8285 | XSETINT (inev.y, mouse_loc.v); | ||
| 8286 | inev.timestamp = er.when * (1000 / 60); | ||
| 8287 | /* ticks to milliseconds */ | ||
| 8288 | 8340 | ||
| 8289 | #if TARGET_API_MAC_CARBON | 8341 | case updateEvt: |
| 8290 | if (ch != 0) | ||
| 8291 | #else | ||
| 8292 | if (control_part_code != 0) | ||
| 8293 | #endif | ||
| 8294 | { | ||
| 8295 | struct scroll_bar *bar = (struct scroll_bar *) | ||
| 8296 | GetControlReference (ch); | ||
| 8297 | x_scroll_bar_handle_click (bar, control_part_code, &er, | ||
| 8298 | &inev); | ||
| 8299 | if (er.what == mouseDown | ||
| 8300 | && control_part_code == kControlIndicatorPart) | ||
| 8301 | { | ||
| 8302 | mouse_tracking_in_progress | ||
| 8303 | = mouse_tracking_scroll_bar; | ||
| 8304 | tracked_scroll_bar = bar; | ||
| 8305 | } | ||
| 8306 | else | ||
| 8307 | { | ||
| 8308 | mouse_tracking_in_progress = mouse_tracking_none; | ||
| 8309 | tracked_scroll_bar = NULL; | ||
| 8310 | } | ||
| 8311 | } | ||
| 8312 | else | ||
| 8313 | { | ||
| 8314 | Lisp_Object window; | ||
| 8315 | int x = mouse_loc.h; | ||
| 8316 | int y = mouse_loc.v; | ||
| 8317 | |||
| 8318 | XSETFRAME (inev.frame_or_window, mwp->mFP); | ||
| 8319 | if (er.what == mouseDown) | ||
| 8320 | mouse_tracking_in_progress | ||
| 8321 | = mouse_tracking_mouse_movement; | ||
| 8322 | else | ||
| 8323 | mouse_tracking_in_progress = mouse_tracking_none; | ||
| 8324 | window = window_from_coordinates (mwp->mFP, x, y, 0, 0, 0, 1); | ||
| 8325 | |||
| 8326 | if (EQ (window, mwp->mFP->tool_bar_window)) | ||
| 8327 | { | ||
| 8328 | if (er.what == mouseDown) | ||
| 8329 | handle_tool_bar_click (mwp->mFP, x, y, 1, 0); | ||
| 8330 | else | ||
| 8331 | handle_tool_bar_click (mwp->mFP, x, y, 0, | ||
| 8332 | #if USE_CARBON_EVENTS | 8342 | #if USE_CARBON_EVENTS |
| 8333 | mac_event_to_emacs_modifiers (eventRef) | 8343 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8334 | #else | 8344 | != eventNotHandledErr) |
| 8335 | er.modifiers | 8345 | break; |
| 8336 | #endif | 8346 | #endif |
| 8337 | ); | 8347 | do_window_update ((WindowPtr) er.message); |
| 8338 | break; | 8348 | break; |
| 8339 | } | ||
| 8340 | else | ||
| 8341 | inev.kind = MOUSE_CLICK_EVENT; | ||
| 8342 | } | ||
| 8343 | 8349 | ||
| 8350 | case osEvt: | ||
| 8344 | #if USE_CARBON_EVENTS | 8351 | #if USE_CARBON_EVENTS |
| 8345 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8352 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8346 | #else | 8353 | != eventNotHandledErr) |
| 8347 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8354 | break; |
| 8348 | #endif | 8355 | #endif |
| 8349 | 8356 | switch ((er.message >> 24) & 0x000000FF) | |
| 8350 | switch (er.what) | 8357 | { |
| 8351 | { | 8358 | case suspendResumeMessage: |
| 8352 | case mouseDown: | 8359 | if ((er.message & resumeFlag) == 1) |
| 8353 | inev.modifiers |= down_modifier; | 8360 | do_app_resume (); |
| 8354 | break; | 8361 | else |
| 8355 | case mouseUp: | 8362 | do_app_suspend (); |
| 8356 | inev.modifiers |= up_modifier; | ||
| 8357 | break; | ||
| 8358 | } | ||
| 8359 | } | ||
| 8360 | break; | 8363 | break; |
| 8361 | 8364 | ||
| 8362 | case inDrag: | 8365 | case mouseMovedMessage: |
| 8363 | #if TARGET_API_MAC_CARBON | 8366 | previous_help_echo_string = help_echo_string; |
| 8364 | if (er.what == mouseDown) | 8367 | help_echo_string = help_echo_object = help_echo_window = Qnil; |
| 8365 | { | 8368 | help_echo_pos = -1; |
| 8366 | BitMap bm; | ||
| 8367 | 8369 | ||
| 8368 | GetQDGlobalsScreenBits (&bm); | 8370 | do_mouse_moved (er.where, &f); |
| 8369 | DragWindow (window_ptr, er.where, &bm.bounds); | ||
| 8370 | } | ||
| 8371 | #else /* not TARGET_API_MAC_CARBON */ | ||
| 8372 | DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | ||
| 8373 | #endif /* not TARGET_API_MAC_CARBON */ | ||
| 8374 | break; | ||
| 8375 | 8371 | ||
| 8376 | case inGoAway: | 8372 | /* If the contents of the global variable |
| 8377 | if (TrackGoAway (window_ptr, er.where)) | 8373 | help_echo_string has changed, generate a |
| 8378 | { | 8374 | HELP_EVENT. */ |
| 8379 | inev.kind = DELETE_WINDOW_EVENT; | 8375 | if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) |
| 8380 | XSETFRAME (inev.frame_or_window, | 8376 | do_help = 1; |
| 8381 | ((mac_output *) GetWRefCon (window_ptr))->mFP); | ||
| 8382 | } | ||
| 8383 | break; | ||
| 8384 | |||
| 8385 | /* window resize handling added --ben */ | ||
| 8386 | case inGrow: | ||
| 8387 | if (er.what == mouseDown) | ||
| 8388 | { | ||
| 8389 | do_grow_window(window_ptr, &er); | ||
| 8390 | break; | ||
| 8391 | } | ||
| 8392 | |||
| 8393 | /* window zoom handling added --ben */ | ||
| 8394 | case inZoomIn: | ||
| 8395 | case inZoomOut: | ||
| 8396 | if (TrackBox (window_ptr, er.where, part_code)) | ||
| 8397 | do_zoom_window (window_ptr, part_code); | ||
| 8398 | break; | ||
| 8399 | |||
| 8400 | default: | ||
| 8401 | break; | 8377 | break; |
| 8402 | } | 8378 | } |
| 8403 | } | 8379 | break; |
| 8404 | break; | 8380 | |
| 8381 | case activateEvt: | ||
| 8382 | { | ||
| 8383 | WindowPtr window_ptr = (WindowPtr) er.message; | ||
| 8405 | 8384 | ||
| 8406 | case updateEvt: | ||
| 8407 | case osEvt: | ||
| 8408 | case activateEvt: | ||
| 8409 | #if USE_CARBON_EVENTS | 8385 | #if USE_CARBON_EVENTS |
| 8410 | if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) | 8386 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) |
| 8387 | != eventNotHandledErr) | ||
| 8388 | break; | ||
| 8411 | #endif | 8389 | #endif |
| 8412 | do_events (&er); | 8390 | if (window_ptr == tip_window) |
| 8413 | break; | 8391 | { |
| 8392 | HideWindow (tip_window); | ||
| 8393 | break; | ||
| 8394 | } | ||
| 8414 | 8395 | ||
| 8415 | case keyDown: | 8396 | if ((er.modifiers & activeFlag) != 0) |
| 8416 | case autoKey: | 8397 | { |
| 8417 | { | 8398 | Point mouse_loc = er.where; |
| 8418 | int keycode = (er.message & keyCodeMask) >> 8; | ||
| 8419 | int xkeysym; | ||
| 8420 | 8399 | ||
| 8421 | #if USE_CARBON_EVENTS | 8400 | do_window_activate (window_ptr); |
| 8422 | /* When using Carbon Events, we need to pass raw keyboard events | ||
| 8423 | to the TSM ourselves. If TSM handles it, it will pass back | ||
| 8424 | noErr, otherwise it will pass back "eventNotHandledErr" and | ||
| 8425 | we can process it normally. */ | ||
| 8426 | if ((!NILP (Vmac_pass_command_to_system) | ||
| 8427 | || !(er.modifiers & cmdKey)) | ||
| 8428 | && (!NILP (Vmac_pass_control_to_system) | ||
| 8429 | || !(er.modifiers & controlKey))) | ||
| 8430 | { | ||
| 8431 | OSStatus err; | ||
| 8432 | err = SendEventToEventTarget (eventRef, | ||
| 8433 | GetEventDispatcherTarget ()); | ||
| 8434 | if (err != eventNotHandledErr) | ||
| 8435 | break; | ||
| 8436 | } | ||
| 8437 | #endif | ||
| 8438 | 8401 | ||
| 8439 | if (!IsValidWindowPtr (FrontNonFloatingWindow ())) | 8402 | SetPortWindowPort (window_ptr); |
| 8440 | { | 8403 | GlobalToLocal (&mouse_loc); |
| 8441 | SysBeep (1); | 8404 | /* activateEvt counts as mouse movement, |
| 8442 | UNBLOCK_INPUT; | 8405 | so update things that depend on mouse position. */ |
| 8443 | return 0; | 8406 | note_mouse_movement (mac_window_to_frame (window_ptr), |
| 8444 | } | 8407 | &mouse_loc); |
| 8408 | } | ||
| 8409 | else | ||
| 8410 | { | ||
| 8411 | do_window_deactivate (window_ptr); | ||
| 8445 | 8412 | ||
| 8446 | ObscureCursor (); | 8413 | f = mac_window_to_frame (window_ptr); |
| 8414 | if (f == dpyinfo->mouse_face_mouse_frame) | ||
| 8415 | { | ||
| 8416 | /* If we move outside the frame, then we're | ||
| 8417 | certainly no longer on any text in the | ||
| 8418 | frame. */ | ||
| 8419 | clear_mouse_face (dpyinfo); | ||
| 8420 | dpyinfo->mouse_face_mouse_frame = 0; | ||
| 8421 | } | ||
| 8447 | 8422 | ||
| 8448 | if (keycode_to_xkeysym (keycode, &xkeysym)) | 8423 | /* Generate a nil HELP_EVENT to cancel a help-echo. |
| 8449 | { | 8424 | Do it only if there's something to cancel. |
| 8450 | inev.code = 0xff00 | xkeysym; | 8425 | Otherwise, the startup message is cleared when the |
| 8451 | inev.kind = NON_ASCII_KEYSTROKE_EVENT; | 8426 | mouse leaves the frame. */ |
| 8452 | } | 8427 | if (any_help_event_p) |
| 8453 | else | 8428 | do_help = -1; |
| 8454 | { | 8429 | } |
| 8455 | if (er.modifiers & (controlKey | | 8430 | } |
| 8456 | (NILP (Vmac_command_key_is_meta) ? optionKey | 8431 | break; |
| 8457 | : cmdKey))) | ||
| 8458 | { | ||
| 8459 | /* This code comes from Keyboard Resource, Appendix | ||
| 8460 | C of IM - Text. This is necessary since shift is | ||
| 8461 | ignored in KCHR table translation when option or | ||
| 8462 | command is pressed. It also does not translate | ||
| 8463 | correctly control-shift chars like C-% so mask off | ||
| 8464 | shift here also */ | ||
| 8465 | int new_modifiers = er.modifiers & 0xe600; | ||
| 8466 | /* mask off option and command */ | ||
| 8467 | int new_keycode = keycode | new_modifiers; | ||
| 8468 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | ||
| 8469 | unsigned long some_state = 0; | ||
| 8470 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | ||
| 8471 | &some_state) & 0xff; | ||
| 8472 | } | ||
| 8473 | else | ||
| 8474 | inev.code = er.message & charCodeMask; | ||
| 8475 | inev.kind = ASCII_KEYSTROKE_EVENT; | ||
| 8476 | } | ||
| 8477 | } | ||
| 8478 | 8432 | ||
| 8479 | /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil, | 8433 | case keyDown: |
| 8480 | convert non-ASCII characters typed at the Mac keyboard | 8434 | case autoKey: |
| 8481 | (presumed to be in the Mac Roman encoding) to iso-latin-1 | ||
| 8482 | encoding before they are passed to Emacs. This enables the | ||
| 8483 | Mac keyboard to be used to enter non-ASCII iso-latin-1 | ||
| 8484 | characters directly. */ | ||
| 8485 | if (mac_keyboard_text_encoding != kTextEncodingMacRoman | ||
| 8486 | && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128) | ||
| 8487 | { | 8435 | { |
| 8488 | static TECObjectRef converter = NULL; | 8436 | int keycode = (er.message & keyCodeMask) >> 8; |
| 8489 | OSStatus the_err = noErr; | 8437 | int xkeysym; |
| 8490 | OSStatus convert_status = noErr; | ||
| 8491 | 8438 | ||
| 8492 | if (converter == NULL) | 8439 | #if USE_CARBON_EVENTS |
| 8440 | /* When using Carbon Events, we need to pass raw keyboard | ||
| 8441 | events to the TSM ourselves. If TSM handles it, it | ||
| 8442 | will pass back noErr, otherwise it will pass back | ||
| 8443 | "eventNotHandledErr" and we can process it | ||
| 8444 | normally. */ | ||
| 8445 | if ((!NILP (Vmac_pass_command_to_system) | ||
| 8446 | || !(er.modifiers & cmdKey)) | ||
| 8447 | && (!NILP (Vmac_pass_control_to_system) | ||
| 8448 | || !(er.modifiers & controlKey))) | ||
| 8449 | if (SendEventToEventTarget (eventRef, toolbox_dispatcher) | ||
| 8450 | != eventNotHandledErr) | ||
| 8451 | break; | ||
| 8452 | #endif | ||
| 8453 | |||
| 8454 | #if TARGET_API_MAC_CARBON | ||
| 8455 | if (!IsValidWindowPtr (mac_front_window ())) | ||
| 8493 | { | 8456 | { |
| 8494 | the_err = TECCreateConverter (&converter, | 8457 | SysBeep (1); |
| 8495 | kTextEncodingMacRoman, | 8458 | break; |
| 8496 | mac_keyboard_text_encoding); | ||
| 8497 | current_mac_keyboard_text_encoding | ||
| 8498 | = mac_keyboard_text_encoding; | ||
| 8499 | } | 8459 | } |
| 8500 | else if (mac_keyboard_text_encoding | 8460 | #endif |
| 8501 | != current_mac_keyboard_text_encoding) | 8461 | |
| 8462 | ObscureCursor (); | ||
| 8463 | |||
| 8464 | if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) | ||
| 8502 | { | 8465 | { |
| 8503 | /* Free the converter for the current encoding before | 8466 | clear_mouse_face (dpyinfo); |
| 8504 | creating a new one. */ | 8467 | dpyinfo->mouse_face_hidden = 1; |
| 8505 | TECDisposeConverter (converter); | ||
| 8506 | the_err = TECCreateConverter (&converter, | ||
| 8507 | kTextEncodingMacRoman, | ||
| 8508 | mac_keyboard_text_encoding); | ||
| 8509 | current_mac_keyboard_text_encoding | ||
| 8510 | = mac_keyboard_text_encoding; | ||
| 8511 | } | 8468 | } |
| 8512 | 8469 | ||
| 8513 | if (the_err == noErr) | 8470 | if (keycode_to_xkeysym (keycode, &xkeysym)) |
| 8514 | { | 8471 | { |
| 8515 | unsigned char ch = inev.code; | 8472 | inev.code = 0xff00 | xkeysym; |
| 8516 | ByteCount actual_input_length, actual_output_length; | 8473 | inev.kind = NON_ASCII_KEYSTROKE_EVENT; |
| 8517 | unsigned char outch; | 8474 | } |
| 8518 | 8475 | else | |
| 8519 | convert_status = TECConvertText (converter, &ch, 1, | 8476 | { |
| 8520 | &actual_input_length, | 8477 | if (er.modifiers & (controlKey | |
| 8521 | &outch, 1, | 8478 | (NILP (Vmac_command_key_is_meta) ? optionKey |
| 8522 | &actual_output_length); | 8479 | : cmdKey))) |
| 8523 | if (convert_status == noErr | 8480 | { |
| 8524 | && actual_input_length == 1 | 8481 | /* This code comes from Keyboard Resource, |
| 8525 | && actual_output_length == 1) | 8482 | Appendix C of IM - Text. This is necessary |
| 8526 | inev.code = outch; | 8483 | since shift is ignored in KCHR table |
| 8484 | translation when option or command is pressed. | ||
| 8485 | It also does not translate correctly | ||
| 8486 | control-shift chars like C-% so mask off shift | ||
| 8487 | here also */ | ||
| 8488 | int new_modifiers = er.modifiers & 0xe600; | ||
| 8489 | /* mask off option and command */ | ||
| 8490 | int new_keycode = keycode | new_modifiers; | ||
| 8491 | Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); | ||
| 8492 | unsigned long some_state = 0; | ||
| 8493 | inev.code = KeyTranslate (kchr_ptr, new_keycode, | ||
| 8494 | &some_state) & 0xff; | ||
| 8495 | } | ||
| 8496 | else | ||
| 8497 | inev.code = er.message & charCodeMask; | ||
| 8498 | inev.kind = ASCII_KEYSTROKE_EVENT; | ||
| 8527 | } | 8499 | } |
| 8528 | } | 8500 | } |
| 8529 | 8501 | ||
| 8502 | /* If variable mac-convert-keyboard-input-to-latin-1 is | ||
| 8503 | non-nil, convert non-ASCII characters typed at the Mac | ||
| 8504 | keyboard (presumed to be in the Mac Roman encoding) to | ||
| 8505 | iso-latin-1 encoding before they are passed to Emacs. | ||
| 8506 | This enables the Mac keyboard to be used to enter | ||
| 8507 | non-ASCII iso-latin-1 characters directly. */ | ||
| 8508 | if (mac_keyboard_text_encoding != kTextEncodingMacRoman | ||
| 8509 | && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128) | ||
| 8510 | { | ||
| 8511 | static TECObjectRef converter = NULL; | ||
| 8512 | OSStatus the_err = noErr; | ||
| 8513 | OSStatus convert_status = noErr; | ||
| 8514 | |||
| 8515 | if (converter == NULL) | ||
| 8516 | { | ||
| 8517 | the_err = TECCreateConverter (&converter, | ||
| 8518 | kTextEncodingMacRoman, | ||
| 8519 | mac_keyboard_text_encoding); | ||
| 8520 | current_mac_keyboard_text_encoding | ||
| 8521 | = mac_keyboard_text_encoding; | ||
| 8522 | } | ||
| 8523 | else if (mac_keyboard_text_encoding | ||
| 8524 | != current_mac_keyboard_text_encoding) | ||
| 8525 | { | ||
| 8526 | /* Free the converter for the current encoding | ||
| 8527 | before creating a new one. */ | ||
| 8528 | TECDisposeConverter (converter); | ||
| 8529 | the_err = TECCreateConverter (&converter, | ||
| 8530 | kTextEncodingMacRoman, | ||
| 8531 | mac_keyboard_text_encoding); | ||
| 8532 | current_mac_keyboard_text_encoding | ||
| 8533 | = mac_keyboard_text_encoding; | ||
| 8534 | } | ||
| 8535 | |||
| 8536 | if (the_err == noErr) | ||
| 8537 | { | ||
| 8538 | unsigned char ch = inev.code; | ||
| 8539 | ByteCount actual_input_length, actual_output_length; | ||
| 8540 | unsigned char outch; | ||
| 8541 | |||
| 8542 | convert_status = TECConvertText (converter, &ch, 1, | ||
| 8543 | &actual_input_length, | ||
| 8544 | &outch, 1, | ||
| 8545 | &actual_output_length); | ||
| 8546 | if (convert_status == noErr | ||
| 8547 | && actual_input_length == 1 | ||
| 8548 | && actual_output_length == 1) | ||
| 8549 | inev.code = outch; | ||
| 8550 | } | ||
| 8551 | } | ||
| 8552 | |||
| 8530 | #if USE_CARBON_EVENTS | 8553 | #if USE_CARBON_EVENTS |
| 8531 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8554 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
| 8532 | #else | 8555 | #else |
| 8533 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8556 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
| 8534 | #endif | 8557 | #endif |
| 8558 | XSETFRAME (inev.frame_or_window, | ||
| 8559 | mac_window_to_frame (mac_front_window ())); | ||
| 8560 | inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ | ||
| 8561 | break; | ||
| 8535 | 8562 | ||
| 8536 | { | 8563 | case kHighLevelEvent: |
| 8537 | mac_output *mwp | 8564 | drag_and_drop_file_list = Qnil; |
| 8538 | = (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); | ||
| 8539 | XSETFRAME (inev.frame_or_window, mwp->mFP); | ||
| 8540 | } | ||
| 8541 | |||
| 8542 | inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ | ||
| 8543 | break; | ||
| 8544 | |||
| 8545 | case kHighLevelEvent: | ||
| 8546 | drag_and_drop_file_list = Qnil; | ||
| 8547 | 8565 | ||
| 8548 | AEProcessAppleEvent(&er); | 8566 | AEProcessAppleEvent(&er); |
| 8549 | 8567 | ||
| 8550 | /* Build a DRAG_N_DROP_EVENT type event as is done in | 8568 | /* Build a DRAG_N_DROP_EVENT type event as is done in |
| 8551 | constuct_drag_n_drop in w32term.c. */ | 8569 | constuct_drag_n_drop in w32term.c. */ |
| 8552 | if (!NILP (drag_and_drop_file_list)) | 8570 | if (!NILP (drag_and_drop_file_list)) |
| 8553 | { | 8571 | { |
| 8554 | struct frame *f = NULL; | 8572 | struct frame *f = NULL; |
| 8555 | WindowPtr wp; | 8573 | WindowPtr wp; |
| 8556 | Lisp_Object frame; | 8574 | Lisp_Object frame; |
| 8557 | 8575 | ||
| 8558 | wp = FrontNonFloatingWindow (); | 8576 | wp = mac_front_window (); |
| 8559 | 8577 | ||
| 8560 | if (!wp) | 8578 | if (!wp) |
| 8561 | { | 8579 | { |
| 8562 | struct frame *f = XFRAME (XCAR (Vframe_list)); | 8580 | struct frame *f = XFRAME (XCAR (Vframe_list)); |
| 8563 | CollapseWindow (FRAME_MAC_WINDOW (f), false); | 8581 | CollapseWindow (FRAME_MAC_WINDOW (f), false); |
| 8564 | wp = FrontNonFloatingWindow (); | 8582 | wp = mac_front_window (); |
| 8565 | } | 8583 | } |
| 8566 | 8584 | ||
| 8567 | if (wp && is_emacs_window(wp)) | 8585 | if (wp && is_emacs_window (wp)) |
| 8568 | f = ((mac_output *) GetWRefCon (wp))->mFP; | 8586 | f = mac_window_to_frame (wp); |
| 8569 | 8587 | ||
| 8570 | inev.kind = DRAG_N_DROP_EVENT; | 8588 | inev.kind = DRAG_N_DROP_EVENT; |
| 8571 | inev.code = 0; | 8589 | inev.code = 0; |
| 8572 | inev.timestamp = er.when * (1000 / 60); | 8590 | inev.timestamp = er.when * (1000 / 60); |
| 8573 | /* ticks to milliseconds */ | 8591 | /* ticks to milliseconds */ |
| 8574 | #if USE_CARBON_EVENTS | 8592 | #if USE_CARBON_EVENTS |
| 8575 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); | 8593 | inev.modifiers = mac_event_to_emacs_modifiers (eventRef); |
| 8576 | #else | 8594 | #else |
| 8577 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); | 8595 | inev.modifiers = mac_to_emacs_modifiers (er.modifiers); |
| 8578 | #endif | 8596 | #endif |
| 8579 | 8597 | ||
| 8580 | XSETINT (inev.x, 0); | 8598 | XSETINT (inev.x, 0); |
| 8581 | XSETINT (inev.y, 0); | 8599 | XSETINT (inev.y, 0); |
| 8582 | 8600 | ||
| 8583 | XSETFRAME (frame, f); | 8601 | XSETFRAME (frame, f); |
| 8584 | inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); | 8602 | inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); |
| 8585 | 8603 | ||
| 8586 | /* Regardless of whether Emacs was suspended or in the | 8604 | /* Regardless of whether Emacs was suspended or in the |
| 8587 | foreground, ask it to redraw its entire screen. | 8605 | foreground, ask it to redraw its entire screen. |
| 8588 | Otherwise parts of the screen can be left in an | 8606 | Otherwise parts of the screen can be left in an |
| 8589 | inconsistent state. */ | 8607 | inconsistent state. */ |
| 8590 | if (wp) | 8608 | if (wp) |
| 8591 | #if TARGET_API_MAC_CARBON | 8609 | #if TARGET_API_MAC_CARBON |
| 8592 | { | 8610 | { |
| 8593 | Rect r; | 8611 | Rect r; |
| 8594 | 8612 | ||
| 8595 | GetWindowPortBounds (wp, &r); | 8613 | GetWindowPortBounds (wp, &r); |
| 8596 | InvalWindowRect (wp, &r); | 8614 | InvalWindowRect (wp, &r); |
| 8597 | } | 8615 | } |
| 8598 | #else /* not TARGET_API_MAC_CARBON */ | 8616 | #else /* not TARGET_API_MAC_CARBON */ |
| 8599 | InvalRect (&(wp->portRect)); | 8617 | InvalRect (&(wp->portRect)); |
| 8600 | #endif /* not TARGET_API_MAC_CARBON */ | 8618 | #endif /* not TARGET_API_MAC_CARBON */ |
| 8601 | } | 8619 | } |
| 8602 | default: | 8620 | default: |
| 8603 | break; | 8621 | break; |
| 8604 | } | 8622 | } |
| 8605 | #if USE_CARBON_EVENTS | 8623 | #if USE_CARBON_EVENTS |
| 8606 | ReleaseEvent (eventRef); | 8624 | ReleaseEvent (eventRef); |
| 8607 | } | ||
| 8608 | #endif | 8625 | #endif |
| 8609 | 8626 | ||
| 8627 | if (inev.kind != NO_EVENT) | ||
| 8628 | { | ||
| 8629 | kbd_buffer_store_event_hold (&inev, hold_quit); | ||
| 8630 | count++; | ||
| 8631 | } | ||
| 8632 | |||
| 8633 | if (do_help | ||
| 8634 | && !(hold_quit && hold_quit->kind != NO_EVENT)) | ||
| 8635 | { | ||
| 8636 | Lisp_Object frame; | ||
| 8637 | |||
| 8638 | if (f) | ||
| 8639 | XSETFRAME (frame, f); | ||
| 8640 | else | ||
| 8641 | frame = Qnil; | ||
| 8642 | |||
| 8643 | if (do_help > 0) | ||
| 8644 | { | ||
| 8645 | any_help_event_p = 1; | ||
| 8646 | gen_help_event (help_echo_string, frame, help_echo_window, | ||
| 8647 | help_echo_object, help_echo_pos); | ||
| 8648 | } | ||
| 8649 | else | ||
| 8650 | { | ||
| 8651 | help_echo_string = Qnil; | ||
| 8652 | gen_help_event (Qnil, frame, Qnil, Qnil, 0); | ||
| 8653 | } | ||
| 8654 | count++; | ||
| 8655 | } | ||
| 8656 | |||
| 8657 | } | ||
| 8658 | |||
| 8610 | /* If the focus was just given to an autoraising frame, | 8659 | /* If the focus was just given to an autoraising frame, |
| 8611 | raise it now. */ | 8660 | raise it now. */ |
| 8612 | /* ??? This ought to be able to handle more than one such frame. */ | 8661 | /* ??? This ought to be able to handle more than one such frame. */ |
| @@ -8620,58 +8669,6 @@ XTread_socket (int sd, int expected, struct input_event *hold_quit) | |||
| 8620 | check_alarm (); /* simulate the handling of a SIGALRM */ | 8669 | check_alarm (); /* simulate the handling of a SIGALRM */ |
| 8621 | #endif | 8670 | #endif |
| 8622 | 8671 | ||
| 8623 | { | ||
| 8624 | static Point old_mouse_pos = { -1, -1 }; | ||
| 8625 | |||
| 8626 | if (app_is_suspended) | ||
| 8627 | { | ||
| 8628 | old_mouse_pos.h = -1; | ||
| 8629 | old_mouse_pos.v = -1; | ||
| 8630 | } | ||
| 8631 | else | ||
| 8632 | { | ||
| 8633 | Point mouse_pos; | ||
| 8634 | WindowPtr wp; | ||
| 8635 | struct frame *f; | ||
| 8636 | Lisp_Object bar; | ||
| 8637 | struct scroll_bar *sb; | ||
| 8638 | |||
| 8639 | wp = FrontWindow (); | ||
| 8640 | if (is_emacs_window (wp)) | ||
| 8641 | { | ||
| 8642 | f = ((mac_output *) GetWRefCon (wp))->mFP; | ||
| 8643 | |||
| 8644 | #if TARGET_API_MAC_CARBON | ||
| 8645 | SetPort (GetWindowPort (wp)); | ||
| 8646 | #else | ||
| 8647 | SetPort (wp); | ||
| 8648 | #endif | ||
| 8649 | |||
| 8650 | GetMouse (&mouse_pos); | ||
| 8651 | |||
| 8652 | if (!EqualPt (mouse_pos, old_mouse_pos)) | ||
| 8653 | { | ||
| 8654 | if (mouse_tracking_in_progress == mouse_tracking_scroll_bar | ||
| 8655 | && tracked_scroll_bar) | ||
| 8656 | x_scroll_bar_note_movement (tracked_scroll_bar, | ||
| 8657 | mouse_pos.v | ||
| 8658 | - XINT (tracked_scroll_bar->top), | ||
| 8659 | TickCount() * (1000 / 60)); | ||
| 8660 | else | ||
| 8661 | note_mouse_movement (f, &mouse_pos); | ||
| 8662 | |||
| 8663 | old_mouse_pos = mouse_pos; | ||
| 8664 | } | ||
| 8665 | } | ||
| 8666 | } | ||
| 8667 | } | ||
| 8668 | |||
| 8669 | if (inev.kind != NO_EVENT) | ||
| 8670 | { | ||
| 8671 | kbd_buffer_store_event_hold (&inev, hold_quit); | ||
| 8672 | count++; | ||
| 8673 | } | ||
| 8674 | |||
| 8675 | UNBLOCK_INPUT; | 8672 | UNBLOCK_INPUT; |
| 8676 | return count; | 8673 | return count; |
| 8677 | } | 8674 | } |
| @@ -8700,7 +8697,7 @@ __convert_from_newlines (unsigned char * p, size_t * n) | |||
| 8700 | ROWS Macintosh window, using font with name FONTNAME and size | 8697 | ROWS Macintosh window, using font with name FONTNAME and size |
| 8701 | FONTSIZE. */ | 8698 | FONTSIZE. */ |
| 8702 | void | 8699 | void |
| 8703 | NewMacWindow (FRAME_PTR fp) | 8700 | make_mac_frame (FRAME_PTR fp) |
| 8704 | { | 8701 | { |
| 8705 | mac_output *mwp; | 8702 | mac_output *mwp; |
| 8706 | #if TARGET_API_MAC_CARBON | 8703 | #if TARGET_API_MAC_CARBON |
| @@ -8719,33 +8716,52 @@ NewMacWindow (FRAME_PTR fp) | |||
| 8719 | making_terminal_window = 0; | 8716 | making_terminal_window = 0; |
| 8720 | } | 8717 | } |
| 8721 | else | 8718 | else |
| 8722 | if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) | 8719 | { |
| 8723 | abort (); | 8720 | #if TARGET_API_MAC_CARBON |
| 8721 | Rect r; | ||
| 8722 | |||
| 8723 | SetRect (&r, 0, 0, 1, 1); | ||
| 8724 | if (CreateNewWindow (kDocumentWindowClass, | ||
| 8725 | kWindowStandardDocumentAttributes | ||
| 8726 | /* | kWindowToolbarButtonAttribute */, | ||
| 8727 | &r, &mwp->mWP) != noErr) | ||
| 8728 | #else | ||
| 8729 | if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) | ||
| 8730 | #endif | ||
| 8731 | abort (); | ||
| 8732 | } | ||
| 8724 | 8733 | ||
| 8725 | SetWRefCon (mwp->mWP, (long) mwp); | 8734 | SetWRefCon (mwp->mWP, (long) mwp); |
| 8726 | /* so that update events can find this mac_output struct */ | 8735 | /* so that update events can find this mac_output struct */ |
| 8727 | mwp->mFP = fp; /* point back to emacs frame */ | 8736 | mwp->mFP = fp; /* point back to emacs frame */ |
| 8728 | 8737 | ||
| 8729 | #if TARGET_API_MAC_CARBON | 8738 | SetPortWindowPort (mwp->mWP); |
| 8730 | SetPort (GetWindowPort (mwp->mWP)); | ||
| 8731 | #else | ||
| 8732 | SetPort (mwp->mWP); | ||
| 8733 | #endif | ||
| 8734 | |||
| 8735 | mwp->fontset = -1; | ||
| 8736 | 8739 | ||
| 8737 | SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false); | 8740 | SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false); |
| 8738 | ShowWindow (mwp->mWP); | ||
| 8739 | |||
| 8740 | } | 8741 | } |
| 8741 | 8742 | ||
| 8742 | 8743 | ||
| 8743 | void | 8744 | void |
| 8744 | make_mac_frame (struct frame *f) | 8745 | make_mac_terminal_frame (struct frame *f) |
| 8745 | { | 8746 | { |
| 8746 | FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; | 8747 | Lisp_Object frame; |
| 8748 | |||
| 8749 | XSETFRAME (frame, f); | ||
| 8750 | |||
| 8751 | f->output_method = output_mac; | ||
| 8752 | f->output_data.mac = (struct mac_output *) | ||
| 8753 | xmalloc (sizeof (struct mac_output)); | ||
| 8754 | bzero (f->output_data.mac, sizeof (struct mac_output)); | ||
| 8755 | |||
| 8756 | XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f); | ||
| 8747 | 8757 | ||
| 8748 | NewMacWindow(f); | 8758 | FRAME_COLS (f) = 96; |
| 8759 | FRAME_LINES (f) = 4; | ||
| 8760 | |||
| 8761 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; | ||
| 8762 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right; | ||
| 8763 | |||
| 8764 | FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; | ||
| 8749 | 8765 | ||
| 8750 | f->output_data.mac->cursor_pixel = 0; | 8766 | f->output_data.mac->cursor_pixel = 0; |
| 8751 | f->output_data.mac->border_pixel = 0x00ff00; | 8767 | f->output_data.mac->border_pixel = 0x00ff00; |
| @@ -8753,8 +8769,6 @@ make_mac_frame (struct frame *f) | |||
| 8753 | f->output_data.mac->cursor_foreground_pixel = 0x0000ff; | 8769 | f->output_data.mac->cursor_foreground_pixel = 0x0000ff; |
| 8754 | 8770 | ||
| 8755 | FRAME_FONTSET (f) = -1; | 8771 | FRAME_FONTSET (f) = -1; |
| 8756 | f->output_data.mac->scroll_bar_foreground_pixel = -1; | ||
| 8757 | f->output_data.mac->scroll_bar_background_pixel = -1; | ||
| 8758 | f->output_data.mac->explicit_parent = 0; | 8772 | f->output_data.mac->explicit_parent = 0; |
| 8759 | f->left_pos = 4; | 8773 | f->left_pos = 4; |
| 8760 | f->top_pos = 4; | 8774 | f->top_pos = 4; |
| @@ -8762,37 +8776,11 @@ make_mac_frame (struct frame *f) | |||
| 8762 | 8776 | ||
| 8763 | f->internal_border_width = 0; | 8777 | f->internal_border_width = 0; |
| 8764 | 8778 | ||
| 8765 | f->output_method = output_mac; | ||
| 8766 | |||
| 8767 | f->auto_raise = 1; | 8779 | f->auto_raise = 1; |
| 8768 | f->auto_lower = 1; | 8780 | f->auto_lower = 1; |
| 8769 | 8781 | ||
| 8770 | f->new_text_cols = 0; | 8782 | f->new_text_cols = 0; |
| 8771 | f->new_text_lines = 0; | 8783 | f->new_text_lines = 0; |
| 8772 | } | ||
| 8773 | |||
| 8774 | void | ||
| 8775 | make_mac_terminal_frame (struct frame *f) | ||
| 8776 | { | ||
| 8777 | Lisp_Object frame; | ||
| 8778 | |||
| 8779 | XSETFRAME (frame, f); | ||
| 8780 | |||
| 8781 | f->output_method = output_mac; | ||
| 8782 | f->output_data.mac = (struct mac_output *) | ||
| 8783 | xmalloc (sizeof (struct mac_output)); | ||
| 8784 | bzero (f->output_data.mac, sizeof (struct mac_output)); | ||
| 8785 | FRAME_FONTSET (f) = -1; | ||
| 8786 | f->output_data.mac->scroll_bar_foreground_pixel = -1; | ||
| 8787 | f->output_data.mac->scroll_bar_background_pixel = -1; | ||
| 8788 | |||
| 8789 | XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f); | ||
| 8790 | |||
| 8791 | FRAME_COLS (f) = 96; | ||
| 8792 | FRAME_LINES (f) = 4; | ||
| 8793 | |||
| 8794 | FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; | ||
| 8795 | FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right; | ||
| 8796 | 8784 | ||
| 8797 | make_mac_frame (f); | 8785 | make_mac_frame (f); |
| 8798 | 8786 | ||
| @@ -8810,6 +8798,8 @@ make_mac_terminal_frame (struct frame *f) | |||
| 8810 | Fmodify_frame_parameters (frame, | 8798 | Fmodify_frame_parameters (frame, |
| 8811 | Fcons (Fcons (Qbackground_color, | 8799 | Fcons (Fcons (Qbackground_color, |
| 8812 | build_string ("white")), Qnil)); | 8800 | build_string ("white")), Qnil)); |
| 8801 | |||
| 8802 | ShowWindow (f->output_data.mac->mWP); | ||
| 8813 | } | 8803 | } |
| 8814 | 8804 | ||
| 8815 | 8805 | ||
| @@ -8864,6 +8854,8 @@ mac_initialize_display_info () | |||
| 8864 | dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; | 8854 | dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; |
| 8865 | dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; | 8855 | dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; |
| 8866 | dpyinfo->mouse_face_window = Qnil; | 8856 | dpyinfo->mouse_face_window = Qnil; |
| 8857 | dpyinfo->mouse_face_overlay = Qnil; | ||
| 8858 | dpyinfo->mouse_face_hidden = 0; | ||
| 8867 | } | 8859 | } |
| 8868 | 8860 | ||
| 8869 | struct mac_display_info * | 8861 | struct mac_display_info * |
| @@ -9020,8 +9012,7 @@ mac_check_for_quit_char () | |||
| 9020 | if (event) | 9012 | if (event) |
| 9021 | { | 9013 | { |
| 9022 | struct input_event e; | 9014 | struct input_event e; |
| 9023 | struct mac_output *mwp = | 9015 | |
| 9024 | (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); | ||
| 9025 | /* Use an input_event to emulate what the interrupt handler does. */ | 9016 | /* Use an input_event to emulate what the interrupt handler does. */ |
| 9026 | EVENT_INIT (e); | 9017 | EVENT_INIT (e); |
| 9027 | e.kind = ASCII_KEYSTROKE_EVENT; | 9018 | e.kind = ASCII_KEYSTROKE_EVENT; |
| @@ -9029,7 +9020,7 @@ mac_check_for_quit_char () | |||
| 9029 | e.arg = Qnil; | 9020 | e.arg = Qnil; |
| 9030 | e.modifiers = NULL; | 9021 | e.modifiers = NULL; |
| 9031 | e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); | 9022 | e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); |
| 9032 | XSETFRAME (e.frame_or_window, mwp->mFP); | 9023 | XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ())); |
| 9033 | /* Remove event from queue to prevent looping. */ | 9024 | /* Remove event from queue to prevent looping. */ |
| 9034 | RemoveEventFromQueue (GetMainEventQueue (), event); | 9025 | RemoveEventFromQueue (GetMainEventQueue (), event); |
| 9035 | ReleaseEvent (event); | 9026 | ReleaseEvent (event); |
diff --git a/src/undo.c b/src/undo.c index dd086db6c40..9fdc46a3b13 100644 --- a/src/undo.c +++ b/src/undo.c | |||
| @@ -292,14 +292,15 @@ but another undo command will undo to the previous boundary. */) | |||
| 292 | 292 | ||
| 293 | /* At garbage collection time, make an undo list shorter at the end, | 293 | /* At garbage collection time, make an undo list shorter at the end, |
| 294 | returning the truncated list. | 294 | returning the truncated list. |
| 295 | MINSIZE and MAXSIZE are the limits on size allowed, as described below. | 295 | MINSIZE, MAXSIZE and LIMITSIZE are the limits on size allowed, |
| 296 | In practice, these are the values of undo-limit and | 296 | as described below. |
| 297 | undo-strong-limit. */ | 297 | In practice, these are the values of undo-limit, |
| 298 | undo-strong-limit, and undo-outer-limit. */ | ||
| 298 | 299 | ||
| 299 | Lisp_Object | 300 | Lisp_Object |
| 300 | truncate_undo_list (list, minsize, maxsize) | 301 | truncate_undo_list (list, minsize, maxsize, limitsize) |
| 301 | Lisp_Object list; | 302 | Lisp_Object list; |
| 302 | int minsize, maxsize; | 303 | int minsize, maxsize, limitsize; |
| 303 | { | 304 | { |
| 304 | Lisp_Object prev, next, last_boundary; | 305 | Lisp_Object prev, next, last_boundary; |
| 305 | int size_so_far = 0; | 306 | int size_so_far = 0; |
| @@ -308,7 +309,8 @@ truncate_undo_list (list, minsize, maxsize) | |||
| 308 | next = list; | 309 | next = list; |
| 309 | last_boundary = Qnil; | 310 | last_boundary = Qnil; |
| 310 | 311 | ||
| 311 | /* Always preserve at least the most recent undo record. | 312 | /* Always preserve at least the most recent undo record |
| 313 | unless it is really horribly big. | ||
| 312 | If the first element is an undo boundary, skip past it. | 314 | If the first element is an undo boundary, skip past it. |
| 313 | 315 | ||
| 314 | Skip, skip, skip the undo, skip, skip, skip the undo, | 316 | Skip, skip, skip the undo, skip, skip, skip the undo, |
| @@ -323,6 +325,7 @@ truncate_undo_list (list, minsize, maxsize) | |||
| 323 | prev = next; | 325 | prev = next; |
| 324 | next = XCDR (next); | 326 | next = XCDR (next); |
| 325 | } | 327 | } |
| 328 | |||
| 326 | while (CONSP (next) && ! NILP (XCAR (next))) | 329 | while (CONSP (next) && ! NILP (XCAR (next))) |
| 327 | { | 330 | { |
| 328 | Lisp_Object elt; | 331 | Lisp_Object elt; |
| @@ -338,13 +341,20 @@ truncate_undo_list (list, minsize, maxsize) | |||
| 338 | + SCHARS (XCAR (elt))); | 341 | + SCHARS (XCAR (elt))); |
| 339 | } | 342 | } |
| 340 | 343 | ||
| 344 | /* If we reach LIMITSIZE before the first boundary, | ||
| 345 | we're heading for memory full, so truncate the list to nothing. */ | ||
| 346 | if (size_so_far > limitsize) | ||
| 347 | return Qnil; | ||
| 348 | |||
| 341 | /* Advance to next element. */ | 349 | /* Advance to next element. */ |
| 342 | prev = next; | 350 | prev = next; |
| 343 | next = XCDR (next); | 351 | next = XCDR (next); |
| 344 | } | 352 | } |
| 353 | |||
| 345 | if (CONSP (next)) | 354 | if (CONSP (next)) |
| 346 | last_boundary = prev; | 355 | last_boundary = prev; |
| 347 | 356 | ||
| 357 | /* Keep more if it fits. */ | ||
| 348 | while (CONSP (next)) | 358 | while (CONSP (next)) |
| 349 | { | 359 | { |
| 350 | Lisp_Object elt; | 360 | Lisp_Object elt; |
diff --git a/src/xdisp.c b/src/xdisp.c index 48f73c5c738..67049a151cc 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -198,8 +198,6 @@ Boston, MA 02111-1307, USA. */ | |||
| 198 | #endif | 198 | #endif |
| 199 | #ifdef MAC_OS | 199 | #ifdef MAC_OS |
| 200 | #include "macterm.h" | 200 | #include "macterm.h" |
| 201 | |||
| 202 | Cursor No_Cursor; | ||
| 203 | #endif | 201 | #endif |
| 204 | 202 | ||
| 205 | #ifndef FRAME_X_OUTPUT | 203 | #ifndef FRAME_X_OUTPUT |
| @@ -20636,11 +20634,7 @@ define_frame_cursor1 (f, cursor, pointer) | |||
| 20636 | cursor = FRAME_X_OUTPUT (f)->nontext_cursor; | 20634 | cursor = FRAME_X_OUTPUT (f)->nontext_cursor; |
| 20637 | } | 20635 | } |
| 20638 | 20636 | ||
| 20639 | #ifndef HAVE_CARBON | ||
| 20640 | if (cursor != No_Cursor) | 20637 | if (cursor != No_Cursor) |
| 20641 | #else | ||
| 20642 | if (bcmp (&cursor, &No_Cursor, sizeof (Cursor))) | ||
| 20643 | #endif | ||
| 20644 | FRAME_RIF (f)->define_frame_cursor (f, cursor); | 20638 | FRAME_RIF (f)->define_frame_cursor (f, cursor); |
| 20645 | } | 20639 | } |
| 20646 | 20640 | ||