aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog111
-rw-r--r--src/dispextern.h28
-rw-r--r--src/dispnew.c14
-rw-r--r--src/frame.h14
-rw-r--r--src/lisp.h35
-rw-r--r--src/msdos.c684
-rw-r--r--src/msdos.h1
-rw-r--r--src/nsterm.h18
-rw-r--r--src/nsterm.m112
-rw-r--r--src/term.c448
-rw-r--r--src/termchar.h48
-rw-r--r--src/w32term.c117
-rw-r--r--src/w32term.h33
-rw-r--r--src/xdisp.c541
-rw-r--r--src/xmenu.c5
-rw-r--r--src/xterm.c98
-rw-r--r--src/xterm.h33
17 files changed, 821 insertions, 1519 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 17e4b422454..09afa259f83 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,116 @@
12010-11-05 Eli Zaretskii <eliz@gnu.org> 12010-11-05 Eli Zaretskii <eliz@gnu.org>
2 2
3 Unify mouse-highlight code for all GUI and TTY sessions.
4
5 * term.c: Remove static mouse_face_* variables. All users
6 changed.
7 (term_show_mouse_face, term_clear_mouse_face)
8 (fast_find_position, term_mouse_highlight): Functions deleted.
9 (tty_draw_row_with_mouse_face): New function.
10 (term_mouse_movement): Call note_mouse_highlight instead of
11 term_mouse_highlight.
12
13 * nsterm.m (ns_update_window_begin, ns_update_window_end)
14 (ns_update_end, x_destroy_window, ns_frame_up_to_date)
15 (ns_dumpglyphs_box_or_relief, ns_maybe_dumpglyphs_background)
16 (ns_dumpglyphs_image, ns_dumpglyphs_stretch)
17 (ns_initialize_display_info, keyDown, mouseMoved, mouseExited):
18 Replace Display_Info with Mouse_HLInfo everywhere where
19 mouse_face_* members were accessed for mouse highlight purposes.
20
21 * xterm.c (x_update_window_begin, x_update_window_end)
22 (x_update_end, XTframe_up_to_date, x_set_mouse_face_gc)
23 (handle_one_xevent, x_free_frame_resources, x_term_init): Replace
24 Display_Info with Mouse_HLInfo everywhere where mouse_face_*
25 members were accessed for mouse highlight purposes.
26
27 * w32term.c (x_update_window_begin, x_update_window_end)
28 (x_update_end, w32_read_socket, x_free_frame_resources)
29 (w32_initialize_display_info): Replace Display_Info with
30 Mouse_HLInfo everywhere where mouse_face_* members were accessed
31 for mouse highlight purposes.
32
33 * xdisp.c (show_mouse_face, note_mode_line_or_margin_highlight)
34 (note_mouse_highlight) [HAVE_WINDOW_SYSTEM]: Don't run GUI code
35 unless the frame is on a window-system.
36 (get_tool_bar_item, handle_tool_bar_click)
37 (note_tool_bar_highlight, draw_glyphs, erase_phys_cursor)
38 (show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
39 (note_mode_line_or_margin_highlight, note_mouse_highlight)
40 (x_clear_window_mouse_face, cancel_mouse_face, expose_frame):
41 Replace Display_Info with Mouse_HLInfo everywhere where
42 mouse_face_* members were accessed for mouse highlight purposes.
43 (coords_in_mouse_face_p): Move prototype out of the
44 HAVE_WINDOW_SYSTEM conditional.
45 (x_y_to_hpos_vpos, frame_to_window_pixel_xy): Move out of the
46 HAVE_WINDOW_SYSTEM block.
47 (try_window_id) [HAVE_GPM || MSDOS]: Call
48 x_clear_window_mouse_face.
49 (draw_row_with_mouse_face): Implementation for HAVE_WINDOW_SYSTEM
50 systems. Call tty_draw_row_with_mouse_face for TTY systems.
51 (show_mouse_face): Call draw_row_with_mouse_face, instead of
52 calling draw_glyphs directly.
53 (show_mouse_face, clear_mouse_face, coords_in_mouse_face_p)
54 (cursor_in_mouse_face_p, rows_from_pos_range)
55 (mouse_face_from_buffer_pos, mouse_face_from_string_pos)
56 (note_mode_line_or_margin_highlight, note_mouse_highlight)
57 (x_clear_window_mouse_face, cancel_mouse_face): Move out of the
58 HAVE_WINDOW_SYSTEM block. Ifdef away window-system specific
59 fragments.
60 (note_mouse_highlight): Call popup_activated for MSDOS as well.
61 Clear mouse highlight if pointer is over glyphs whose OBJECT is an
62 integer.
63 (mouse_face_from_buffer_pos): Add parentheses around && within ||.
64 (x_consider_frame_title, tool_bar_lines_needed): Move
65 prototypes to HAVE_WINDOW_SYSTEM-only part.
66 (get_window_cursor_type): Move inside a HAVE_WINDOW_SYSTEM-only
67 part. Remove "#ifdef HAVE_WINDOW_SYSTEM" from body of function.
68 (null_glyph_slice): Move declaration into HAVE_WINDOW_SYSTEM-only
69 part.
70
71 * dispnew.c (mirror_make_current): Set Y coordinate of the
72 mode-line and header-line rows.
73 (init_display): Setup initial frame's output_data for text
74 terminal frames.
75
76 * xmenu.c (popup_activated): Don't define on MSDOS, which now has
77 its own definition on msdos.c.
78
79 * msdos.c (show_mouse_face, clear_mouse_face)
80 (fast_find_position, IT_note_mode_line_highlight)
81 (IT_note_mouse_highlight): Functions deleted.
82 (IT_frame_up_to_date, dos_rawgetc): Call note_mouse_highlight
83 instead of IT_note_mouse_highlight.
84 (draw_row_with_mouse_face, popup_activated): New functions.
85 (dos_set_window_size, draw_row_with_mouse_face, IT_update_begin)
86 (IT_update_end, IT_frame_up_to_date, internal_terminal_init)
87 (dos_rawgetc): Replace Display_Info with Mouse_HLInfo everywhere
88 where mouse_face_* members were accessed for mouse highlight
89 purposes.
90
91 * msdos.h (initialize_msdos_display): Add prototype.
92
93 * frame.h (MOUSE_HL_INFO): New macro.
94
95 * lisp.h (Mouse_HLInfo): New data type.
96
97 * xterm.h (struct x_display_info):
98 * w32term.h (struct w32_display_info):
99 * nsterm.h (struct ns_display_info):
100 * termchar.h (struct tty_display_info): Use it instead of
101 mouse_face_* members.
102
103 * dispextern.h (show_mouse_face, clear_mouse_face): Update type of
104 1st argument.
105 (frame_to_window_pixel_xy, note_mouse_highlight)
106 (x_clear_window_mouse_face, cancel_mouse_face, clear_mouse_face)
107 (show_mouse_face, cursor_in_mouse_face_p): Move prototypes out of
108 HAVE_WINDOW_SYSTEM conditional.
109 (draw_row_with_mouse_face): Declare prototype.
110 (tty_draw_row_with_mouse_face): Declare prototype.
111
1122010-11-05 Eli Zaretskii <eliz@gnu.org>
113
3 * term.c (append_glyphless_glyph, produce_glyphless_glyph): Remove 114 * term.c (append_glyphless_glyph, produce_glyphless_glyph): Remove
4 unused variables. 115 unused variables.
5 116
diff --git a/src/dispextern.h b/src/dispextern.h
index c2eeb6ec527..30bd051b0ac 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -69,6 +69,11 @@ typedef Pixmap XImagePtr;
69typedef XImagePtr XImagePtr_or_DC; 69typedef XImagePtr XImagePtr_or_DC;
70#endif 70#endif
71 71
72#ifndef HAVE_WINDOW_SYSTEM
73typedef int Cursor;
74#define No_Cursor (0)
75#endif
76
72#ifndef NativeRectangle 77#ifndef NativeRectangle
73#define NativeRectangle int 78#define NativeRectangle int
74#endif 79#endif
@@ -3060,28 +3065,31 @@ extern void x_update_cursor (struct frame *, int);
3060extern void x_clear_cursor (struct window *); 3065extern void x_clear_cursor (struct window *);
3061extern void x_draw_vertical_border (struct window *w); 3066extern void x_draw_vertical_border (struct window *w);
3062 3067
3063extern void frame_to_window_pixel_xy (struct window *, int *, int *);
3064extern int get_glyph_string_clip_rects (struct glyph_string *, 3068extern int get_glyph_string_clip_rects (struct glyph_string *,
3065 NativeRectangle *, int); 3069 NativeRectangle *, int);
3066extern void get_glyph_string_clip_rect (struct glyph_string *, 3070extern void get_glyph_string_clip_rect (struct glyph_string *,
3067 NativeRectangle *nr); 3071 NativeRectangle *nr);
3068extern Lisp_Object find_hot_spot (Lisp_Object, int, int); 3072extern Lisp_Object find_hot_spot (Lisp_Object, int, int);
3069extern void note_mouse_highlight (struct frame *, int, int);
3070extern void x_clear_window_mouse_face (struct window *);
3071extern void cancel_mouse_face (struct frame *);
3072 3073
3073extern void handle_tool_bar_click (struct frame *, 3074extern void handle_tool_bar_click (struct frame *,
3074 int, int, int, unsigned int); 3075 int, int, int, unsigned int);
3075 3076
3076/* msdos.c defines its own versions of these functions. */
3077extern int clear_mouse_face (Display_Info *);
3078extern void show_mouse_face (Display_Info *, enum draw_glyphs_face);
3079extern int cursor_in_mouse_face_p (struct window *w);
3080
3081extern void expose_frame (struct frame *, int, int, int, int); 3077extern void expose_frame (struct frame *, int, int, int, int);
3082extern int x_intersect_rectangles (XRectangle *, XRectangle *, 3078extern int x_intersect_rectangles (XRectangle *, XRectangle *,
3083 XRectangle *); 3079 XRectangle *);
3084#endif 3080#endif /* HAVE_WINDOW_SYSTEM */
3081
3082extern void frame_to_window_pixel_xy (struct window *, int *, int *);
3083extern void note_mouse_highlight (struct frame *, int, int);
3084extern void x_clear_window_mouse_face (struct window *);
3085extern void cancel_mouse_face (struct frame *);
3086extern int clear_mouse_face (Mouse_HLInfo *);
3087extern void show_mouse_face (Mouse_HLInfo *, enum draw_glyphs_face);
3088extern int cursor_in_mouse_face_p (struct window *w);
3089extern void draw_row_with_mouse_face (struct window *, int, struct glyph_row *,
3090 int, int, enum draw_glyphs_face);
3091extern void tty_draw_row_with_mouse_face (struct window *, struct glyph_row *,
3092 int, int, enum draw_glyphs_face);
3085 3093
3086/* Flags passed to try_window. */ 3094/* Flags passed to try_window. */
3087#define TRY_WINDOW_CHECK_MARGINS (1 << 0) 3095#define TRY_WINDOW_CHECK_MARGINS (1 << 0)
diff --git a/src/dispnew.c b/src/dispnew.c
index 44dad60473d..116d9972ba5 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -2893,6 +2893,14 @@ mirror_make_current (struct window *w, int frame_row)
2893 else 2893 else
2894 swap_glyph_pointers (desired_row, current_row); 2894 swap_glyph_pointers (desired_row, current_row);
2895 current_row->enabled_p = 1; 2895 current_row->enabled_p = 1;
2896
2897 /* Set the Y coordinate of the mode/header line's row.
2898 It is needed in draw_row_with_mouse_face to find the
2899 screen coordinates. (Window-based redisplay sets
2900 this in update_window, but no one seems to do that
2901 for frame-based redisplay.) */
2902 if (current_row->mode_line_p)
2903 current_row->y = row;
2896 } 2904 }
2897 } 2905 }
2898 2906
@@ -6416,6 +6424,12 @@ init_display (void)
6416 f->terminal = t; 6424 f->terminal = t;
6417 6425
6418 t->reference_count++; 6426 t->reference_count++;
6427#ifdef MSDOS
6428 f->output_data.tty->display_info = &the_only_display_info;
6429#else
6430 if (f->output_method == output_termcap)
6431 create_tty_output (f);
6432#endif
6419 t->display_info.tty->top_frame = selected_frame; 6433 t->display_info.tty->top_frame = selected_frame;
6420 change_frame_size (XFRAME (selected_frame), 6434 change_frame_size (XFRAME (selected_frame),
6421 FrameRows (t->display_info.tty), 6435 FrameRows (t->display_info.tty),
diff --git a/src/frame.h b/src/frame.h
index e66fd9341c7..31f601737c8 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -544,6 +544,20 @@ typedef struct frame *FRAME_PTR;
544#define FRAME_WINDOW_P(f) (0) 544#define FRAME_WINDOW_P(f) (0)
545#endif 545#endif
546 546
547/* Return a pointer to the structure holding information about the
548 region of text, if any, that is currently shown in mouse-face on
549 frame F. We need to define two versions because a TTY-only build
550 does not have FRAME_X_DISPLAY_INFO. */
551#ifdef HAVE_WINDOW_SYSTEM
552# define MOUSE_HL_INFO(F) \
553 (FRAME_WINDOW_P(F) \
554 ? &(FRAME_X_DISPLAY_INFO(F)->mouse_highlight) \
555 : &(((F)->output_data.tty->display_info)->mouse_highlight))
556#else
557# define MOUSE_HL_INFO(F) \
558 (&(((F)->output_data.tty->display_info)->mouse_highlight))
559#endif
560
547/* Nonzero if frame F is still alive (not deleted). */ 561/* Nonzero if frame F is still alive (not deleted). */
548#define FRAME_LIVE_P(f) ((f)->terminal != 0) 562#define FRAME_LIVE_P(f) ((f)->terminal != 0)
549 563
diff --git a/src/lisp.h b/src/lisp.h
index c9104f88954..4adf9ef9c69 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1563,6 +1563,41 @@ typedef struct {
1563/* The ID of the mode line highlighting face. */ 1563/* The ID of the mode line highlighting face. */
1564#define GLYPH_MODE_LINE_FACE 1 1564#define GLYPH_MODE_LINE_FACE 1
1565 1565
1566/* Structure to hold mouse highlight data. This is here because other
1567 header files need it for defining struct x_output etc. */
1568typedef struct {
1569 /* These variables describe the range of text currently shown in its
1570 mouse-face, together with the window they apply to. As long as
1571 the mouse stays within this range, we need not redraw anything on
1572 its account. Rows and columns are glyph matrix positions in
1573 MOUSE_FACE_WINDOW. */
1574 int mouse_face_beg_row, mouse_face_beg_col;
1575 int mouse_face_beg_x, mouse_face_beg_y;
1576 int mouse_face_end_row, mouse_face_end_col;
1577 int mouse_face_end_x, mouse_face_end_y;
1578 int mouse_face_past_end;
1579 Lisp_Object mouse_face_window;
1580 int mouse_face_face_id;
1581 Lisp_Object mouse_face_overlay;
1582
1583 /* 1 if a mouse motion event came and we didn't handle it right away because
1584 gc was in progress. */
1585 int mouse_face_deferred_gc;
1586
1587 /* FRAME and X, Y position of mouse when last checked for
1588 highlighting. X and Y can be negative or out of range for the frame. */
1589 struct frame *mouse_face_mouse_frame;
1590 int mouse_face_mouse_x, mouse_face_mouse_y;
1591
1592 /* Nonzero means defer mouse-motion highlighting. */
1593 int mouse_face_defer;
1594
1595 /* Nonzero means that the mouse highlight should not be shown. */
1596 int mouse_face_hidden;
1597
1598 int mouse_face_image_state;
1599} Mouse_HLInfo;
1600
1566/* Data type checking */ 1601/* Data type checking */
1567 1602
1568#define NILP(x) EQ (x, Qnil) 1603#define NILP(x) EQ (x, Qnil)
diff --git a/src/msdos.c b/src/msdos.c
index 0957221f597..6593714ba1f 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -584,14 +584,14 @@ dos_set_window_size (int *rows, int *cols)
584 if (current_rows != *rows || current_cols != *cols) 584 if (current_rows != *rows || current_cols != *cols)
585 { 585 {
586 struct frame *f = SELECTED_FRAME(); 586 struct frame *f = SELECTED_FRAME();
587 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 587 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
588 Lisp_Object window = dpyinfo->mouse_face_window; 588 Lisp_Object window = hlinfo->mouse_face_window;
589 589
590 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f) 590 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f)
591 { 591 {
592 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 592 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
593 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 593 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
594 dpyinfo->mouse_face_window = Qnil; 594 hlinfo->mouse_face_window = Qnil;
595 } 595 }
596 } 596 }
597 597
@@ -941,551 +941,79 @@ static Lisp_Object last_mouse_window;
941 941
942static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */ 942static int mouse_preempted = 0; /* non-zero when XMenu gobbles mouse events */
943 943
944/* Set the mouse pointer shape according to whether it is in the 944int
945 area where the mouse highlight is in effect. */ 945popup_activated (void)
946static void
947IT_set_mouse_pointer (int mode)
948{ 946{
949 /* A no-op for now. DOS text-mode mouse pointer doesn't offer too 947 return mouse_preempted;
950 many possibilities to change its shape, and the available
951 functionality pretty much sucks (e.g., almost every reasonable
952 shape will conceal the character it is on). Since the color of
953 the pointer changes in the highlighted area, it is not clear to
954 me whether anything else is required, anyway. */
955} 948}
956 949
957/* Display the active region described by mouse_face_* 950/* Draw TEXT_AREA glyphs between START and END of glyph row ROW on
958 in its mouse-face if HL > 0, in its normal face if HL = 0. */ 951 window W. X is relative to TEXT_AREA in W. HL is a face override
959static void 952 for drawing the glyphs. */
960show_mouse_face (struct tty_display_info *dpyinfo, int hl) 953void
954tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
955 int start_hpos, int end_hpos,
956 enum draw_glyphs_face hl)
961{ 957{
962 struct window *w = XWINDOW (dpyinfo->mouse_face_window);
963 struct frame *f = XFRAME (WINDOW_FRAME (w)); 958 struct frame *f = XFRAME (WINDOW_FRAME (w));
964 int i;
965 struct face *fp;
966 struct tty_display_info *tty = FRAME_TTY (f); 959 struct tty_display_info *tty = FRAME_TTY (f);
960 Mouse_HLInfo *hlinfo = &tty->mouse_highlight;
967 961
968 962 if (hl == DRAW_MOUSE_FACE)
969 /* If window is in the process of being destroyed, don't bother
970 doing anything. */
971 if (w->current_matrix == NULL)
972 goto set_cursor_shape;
973
974 /* Recognize when we are called to operate on rows that don't exist
975 anymore. This can happen when a window is split. */
976 if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows)
977 goto set_cursor_shape;
978
979 /* There's no sense to do anything if the mouse face isn't realized. */
980 if (hl > 0)
981 {
982 if (dpyinfo->mouse_face_hidden)
983 goto set_cursor_shape;
984
985 fp = FACE_FROM_ID (SELECTED_FRAME(), dpyinfo->mouse_face_face_id);
986 if (!fp)
987 goto set_cursor_shape;
988 }
989
990 /* Note that mouse_face_beg_row etc. are window relative. */
991 for (i = dpyinfo->mouse_face_beg_row;
992 i <= dpyinfo->mouse_face_end_row;
993 i++)
994 { 963 {
995 int start_hpos, end_hpos; 964 int vpos = row->y + WINDOW_TOP_EDGE_Y (w);
996 struct glyph_row *row = MATRIX_ROW (w->current_matrix, i); 965 int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w);
997 966 int nglyphs = end_hpos - start_hpos;
998 /* Don't do anything if row doesn't have valid contents. */ 967 int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
999 if (!row->enabled_p) 968 int start_offset = offset;
1000 continue;
1001 969
1002 /* For all but the first row, the highlight starts at column 0. */ 970 if (tty->termscript)
1003 if (i == dpyinfo->mouse_face_beg_row) 971 fprintf (tty->termscript, "\n<MH+ %d-%d:%d>",
1004 start_hpos = dpyinfo->mouse_face_beg_col; 972 kstart, kstart + nglyphs - 1, vpos);
1005 else
1006 start_hpos = 0;
1007
1008 if (i == dpyinfo->mouse_face_end_row)
1009 end_hpos = dpyinfo->mouse_face_end_col;
1010 else
1011 end_hpos = row->used[TEXT_AREA];
1012
1013 if (end_hpos <= start_hpos)
1014 continue;
1015 /* Record that some glyphs of this row are displayed in
1016 mouse-face. */
1017 row->mouse_face_p = hl > 0;
1018 if (hl > 0)
1019 {
1020 int vpos = row->y + WINDOW_TOP_EDGE_Y (w);
1021 int kstart = start_hpos + WINDOW_LEFT_EDGE_X (w);
1022 int nglyphs = end_hpos - start_hpos;
1023 int offset = ScreenPrimary + 2*(vpos*screen_size_X + kstart) + 1;
1024 int start_offset = offset;
1025
1026 if (tty->termscript)
1027 fprintf (tty->termscript, "\n<MH+ %d-%d:%d>",
1028 kstart, kstart + nglyphs - 1, vpos);
1029
1030 mouse_off ();
1031 IT_set_face (dpyinfo->mouse_face_face_id);
1032 /* Since we are going to change only the _colors_ of the
1033 displayed text, there's no need to go through all the
1034 pain of generating and encoding the text from the glyphs.
1035 Instead, we simply poke the attribute byte of each
1036 affected position in video memory with the colors
1037 computed by IT_set_face! */
1038 _farsetsel (_dos_ds);
1039 while (nglyphs--)
1040 {
1041 _farnspokeb (offset, ScreenAttrib);
1042 offset += 2;
1043 }
1044 if (screen_virtual_segment)
1045 dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos);
1046 mouse_on ();
1047 }
1048 else
1049 {
1050 /* We are removing a previously-drawn mouse highlight. The
1051 safest way to do so is to redraw the glyphs anew, since
1052 all kinds of faces and display tables could have changed
1053 behind our back. */
1054 int nglyphs = end_hpos - start_hpos;
1055 int save_x = new_pos_X, save_y = new_pos_Y;
1056
1057 if (end_hpos >= row->used[TEXT_AREA])
1058 nglyphs = row->used[TEXT_AREA] - start_hpos;
1059
1060 /* IT_write_glyphs writes at cursor position, so we need to
1061 temporarily move cursor coordinates to the beginning of
1062 the highlight region. */
1063 new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w);
1064 new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w);
1065
1066 if (tty->termscript)
1067 fprintf (tty->termscript, "<MH- %d-%d:%d>",
1068 new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y);
1069 IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
1070 if (tty->termscript)
1071 fputs ("\n", tty->termscript);
1072 new_pos_X = save_x;
1073 new_pos_Y = save_y;
1074 }
1075 }
1076
1077 set_cursor_shape:
1078 /* Change the mouse pointer shape. */
1079 IT_set_mouse_pointer (hl);
1080}
1081
1082/* Clear out the mouse-highlighted active region.
1083 Redraw it un-highlighted first. */
1084static void
1085clear_mouse_face (struct tty_display_info *dpyinfo)
1086{
1087 if (!dpyinfo->mouse_face_hidden && ! NILP (dpyinfo->mouse_face_window))
1088 show_mouse_face (dpyinfo, 0);
1089
1090 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
1091 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
1092 dpyinfo->mouse_face_window = Qnil;
1093}
1094
1095/* Find the glyph matrix position of buffer position POS in window W.
1096 *HPOS and *VPOS are set to the positions found. W's current glyphs
1097 must be up to date. If POS is above window start return (0, 0).
1098 If POS is after end of W, return end of last line in W. */
1099static int
1100fast_find_position (struct window *w, int pos, int *hpos, int *vpos)
1101{
1102 int i, lastcol, line_start_position, maybe_next_line_p = 0;
1103 int yb = window_text_bottom_y (w);
1104 struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
1105
1106 while (row->y < yb)
1107 {
1108 if (row->used[TEXT_AREA])
1109 line_start_position = row->glyphs[TEXT_AREA]->charpos;
1110 else
1111 line_start_position = 0;
1112
1113 if (line_start_position > pos)
1114 break;
1115 /* If the position sought is the end of the buffer,
1116 don't include the blank lines at the bottom of the window. */
1117 else if (line_start_position == pos
1118 && pos == BUF_ZV (XBUFFER (w->buffer)))
1119 {
1120 maybe_next_line_p = 1;
1121 break;
1122 }
1123 else if (line_start_position > 0)
1124 best_row = row;
1125
1126 /* Don't overstep the last matrix row, lest we get into the
1127 never-never land... */
1128 if (row->y + 1 >= yb)
1129 break;
1130
1131 ++row;
1132 }
1133
1134 /* Find the right column within BEST_ROW. */
1135 lastcol = 0;
1136 row = best_row;
1137 for (i = 0; i < row->used[TEXT_AREA]; i++)
1138 {
1139 struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
1140 int charpos;
1141
1142 charpos = glyph->charpos;
1143 if (charpos == pos)
1144 {
1145 *hpos = i;
1146 *vpos = row->y;
1147 return 1;
1148 }
1149 else if (charpos > pos)
1150 break;
1151 else if (charpos > 0)
1152 lastcol = i;
1153 }
1154
1155 /* If we're looking for the end of the buffer,
1156 and we didn't find it in the line we scanned,
1157 use the start of the following line. */
1158 if (maybe_next_line_p)
1159 {
1160 ++row;
1161 lastcol = 0;
1162 }
1163
1164 *vpos = row->y;
1165 *hpos = lastcol + 1;
1166 return 0;
1167}
1168
1169/* Take proper action when mouse has moved to the mode or top line of
1170 window W, x-position X. MODE_LINE_P non-zero means mouse is on the
1171 mode line. X is relative to the start of the text display area of
1172 W, so the width of fringes and scroll bars must be subtracted
1173 to get a position relative to the start of the mode line. */
1174static void
1175IT_note_mode_line_highlight (struct window *w, int x, int mode_line_p)
1176{
1177 struct glyph_row *row;
1178
1179 if (mode_line_p)
1180 row = MATRIX_MODE_LINE_ROW (w->current_matrix);
1181 else
1182 row = MATRIX_HEADER_LINE_ROW (w->current_matrix);
1183 973
1184 if (row->enabled_p) 974 mouse_off ();
1185 { 975 IT_set_face (hlinfo->mouse_face_face_id);
1186 struct glyph *glyph, *end; 976 /* Since we are going to change only the _colors_ of already
1187 Lisp_Object help; 977 displayed text, there's no need to go through all the pain of
1188 978 generating and encoding the text from the glyphs. Instead,
1189 /* Find the glyph under X. */ 979 we simply poke the attribute byte of each affected position
1190 glyph = (row->glyphs[TEXT_AREA] 980 in video memory with the colors computed by IT_set_face! */
1191 + x 981 _farsetsel (_dos_ds);
1192 /* in case someone implements scroll bars some day... */ 982 while (nglyphs--)
1193 - WINDOW_LEFT_SCROLL_BAR_AREA_WIDTH (w));
1194 end = glyph + row->used[TEXT_AREA];
1195 if (glyph < end
1196 && STRINGP (glyph->object)
1197 && STRING_INTERVALS (glyph->object)
1198 && glyph->charpos >= 0
1199 && glyph->charpos < SCHARS (glyph->object))
1200 { 983 {
1201 /* If we're on a string with `help-echo' text property, 984 _farnspokeb (offset, ScreenAttrib);
1202 arrange for the help to be displayed. This is done by 985 offset += 2;
1203 setting the global variable help_echo to the help string. */
1204 help = Fget_text_property (make_number (glyph->charpos),
1205 Qhelp_echo, glyph->object);
1206 if (!NILP (help))
1207 {
1208 help_echo_string = help;
1209 XSETWINDOW (help_echo_window, w);
1210 help_echo_object = glyph->object;
1211 help_echo_pos = glyph->charpos;
1212 }
1213 } 986 }
987 if (screen_virtual_segment)
988 dosv_refresh_virtual_screen (start_offset, end_hpos - start_hpos);
989 mouse_on ();
1214 } 990 }
1215} 991 else if (hl == DRAW_NORMAL_TEXT)
1216
1217/* Take proper action when the mouse has moved to position X, Y on
1218 frame F as regards highlighting characters that have mouse-face
1219 properties. Also de-highlighting chars where the mouse was before.
1220 X and Y can be negative or out of range. */
1221static void
1222IT_note_mouse_highlight (struct frame *f, int x, int y)
1223{
1224 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
1225 enum window_part part = ON_NOTHING;
1226 Lisp_Object window;
1227 struct window *w;
1228
1229 /* When a menu is active, don't highlight because this looks odd. */
1230 if (mouse_preempted)
1231 return;
1232
1233 if (NILP (Vmouse_highlight)
1234 || !f->glyphs_initialized_p)
1235 return;
1236
1237 dpyinfo->mouse_face_mouse_x = x;
1238 dpyinfo->mouse_face_mouse_y = y;
1239 dpyinfo->mouse_face_mouse_frame = f;
1240
1241 if (dpyinfo->mouse_face_defer)
1242 return;
1243
1244 if (gc_in_progress)
1245 {
1246 dpyinfo->mouse_face_deferred_gc = 1;
1247 return;
1248 }
1249
1250 /* Which window is that in? */
1251 window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
1252
1253 /* If we were displaying active text in another window, clear that. */
1254 if (! EQ (window, dpyinfo->mouse_face_window))
1255 clear_mouse_face (dpyinfo);
1256
1257 /* Not on a window -> return. */
1258 if (!WINDOWP (window))
1259 return;
1260
1261 /* Convert to window-relative coordinates. */
1262 w = XWINDOW (window);
1263
1264 if (part == ON_MODE_LINE || part == ON_HEADER_LINE)
1265 {
1266 /* Mouse is on the mode or top line. */
1267 IT_note_mode_line_highlight (w, x, part == ON_MODE_LINE);
1268 return;
1269 }
1270
1271 IT_set_mouse_pointer (0);
1272
1273 /* Are we in a window whose display is up to date?
1274 And verify the buffer's text has not changed. */
1275 if (part == ON_TEXT
1276 && EQ (w->window_end_valid, w->buffer)
1277 && XFASTINT (w->last_modified) == BUF_MODIFF (XBUFFER (w->buffer))
1278 && (XFASTINT (w->last_overlay_modified)
1279 == BUF_OVERLAY_MODIFF (XBUFFER (w->buffer))))
1280 { 992 {
1281 int pos, i, nrows = w->current_matrix->nrows; 993 /* We are removing a previously-drawn mouse highlight. The
1282 struct glyph_row *row; 994 safest way to do so is to redraw the glyphs anew, since all
1283 struct glyph *glyph; 995 kinds of faces and display tables could have changed behind
996 our back. */
997 int nglyphs = end_hpos - start_hpos;
998 int save_x = new_pos_X, save_y = new_pos_Y;
999
1000 if (end_hpos >= row->used[TEXT_AREA])
1001 nglyphs = row->used[TEXT_AREA] - start_hpos;
1002
1003 /* IT_write_glyphs writes at cursor position, so we need to
1004 temporarily move cursor coordinates to the beginning of
1005 the highlight region. */
1006 new_pos_X = start_hpos + WINDOW_LEFT_EDGE_X (w);
1007 new_pos_Y = row->y + WINDOW_TOP_EDGE_Y (w);
1284 1008
1285 /* Find the glyph under X/Y. */ 1009 if (tty->termscript)
1286 glyph = NULL; 1010 fprintf (tty->termscript, "<MH- %d-%d:%d>",
1287 if (y >= 0 && y < nrows) 1011 new_pos_X, new_pos_X + nglyphs - 1, new_pos_Y);
1288 { 1012 IT_write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
1289 row = MATRIX_ROW (w->current_matrix, y); 1013 if (tty->termscript)
1290 /* Give up if some row before the one we are looking for is 1014 fputs ("\n", tty->termscript);
1291 not enabled. */ 1015 new_pos_X = save_x;
1292 for (i = 0; i <= y; i++) 1016 new_pos_Y = save_y;
1293 if (!MATRIX_ROW (w->current_matrix, i)->enabled_p)
1294 break;
1295 if (i > y /* all rows upto and including the one at Y are enabled */
1296 && row->displays_text_p
1297 && x < window_box_width (w, TEXT_AREA))
1298 {
1299 glyph = row->glyphs[TEXT_AREA];
1300 if (x >= row->used[TEXT_AREA])
1301 glyph = NULL;
1302 else
1303 {
1304 glyph += x;
1305 if (!BUFFERP (glyph->object))
1306 glyph = NULL;
1307 }
1308 }
1309 }
1310
1311 /* Clear mouse face if X/Y not over text. */
1312 if (glyph == NULL)
1313 {
1314 clear_mouse_face (dpyinfo);
1315 return;
1316 }
1317
1318 if (!BUFFERP (glyph->object))
1319 abort ();
1320 pos = glyph->charpos;
1321
1322 /* Check for mouse-face and help-echo. */
1323 {
1324 Lisp_Object mouse_face, overlay, position, *overlay_vec;
1325 int noverlays, obegv, ozv;
1326 struct buffer *obuf;
1327
1328 /* If we get an out-of-range value, return now; avoid an error. */
1329 if (pos > BUF_Z (XBUFFER (w->buffer)))
1330 return;
1331
1332 /* Make the window's buffer temporarily current for
1333 overlays_at and compute_char_face. */
1334 obuf = current_buffer;
1335 current_buffer = XBUFFER (w->buffer);
1336 obegv = BEGV;
1337 ozv = ZV;
1338 BEGV = BEG;
1339 ZV = Z;
1340
1341 /* Is this char mouse-active or does it have help-echo? */
1342 XSETINT (position, pos);
1343
1344 /* Put all the overlays we want in a vector in overlay_vec. */
1345 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
1346 /* Sort overlays into increasing priority order. */
1347 noverlays = sort_overlays (overlay_vec, noverlays, w);
1348
1349 /* Check mouse-face highlighting. */
1350 if (! (EQ (window, dpyinfo->mouse_face_window)
1351 && y >= dpyinfo->mouse_face_beg_row
1352 && y <= dpyinfo->mouse_face_end_row
1353 && (y > dpyinfo->mouse_face_beg_row
1354 || x >= dpyinfo->mouse_face_beg_col)
1355 && (y < dpyinfo->mouse_face_end_row
1356 || x < dpyinfo->mouse_face_end_col
1357 || dpyinfo->mouse_face_past_end)))
1358 {
1359 /* Clear the display of the old active region, if any. */
1360 clear_mouse_face (dpyinfo);
1361
1362 /* Find highest priority overlay that has a mouse-face prop. */
1363 overlay = Qnil;
1364 for (i = noverlays - 1; i >= 0; --i)
1365 {
1366 mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
1367 if (!NILP (mouse_face))
1368 {
1369 overlay = overlay_vec[i];
1370 break;
1371 }
1372 }
1373
1374 /* If no overlay applies, get a text property. */
1375 if (NILP (overlay))
1376 mouse_face = Fget_text_property (position, Qmouse_face,
1377 w->buffer);
1378
1379 /* Handle the overlay case. */
1380 if (! NILP (overlay))
1381 {
1382 /* Find the range of text around this char that
1383 should be active. */
1384 Lisp_Object before, after;
1385 EMACS_INT ignore;
1386
1387 before = Foverlay_start (overlay);
1388 after = Foverlay_end (overlay);
1389 /* Record this as the current active region. */
1390 fast_find_position (w, XFASTINT (before),
1391 &dpyinfo->mouse_face_beg_col,
1392 &dpyinfo->mouse_face_beg_row);
1393 dpyinfo->mouse_face_past_end
1394 = !fast_find_position (w, XFASTINT (after),
1395 &dpyinfo->mouse_face_end_col,
1396 &dpyinfo->mouse_face_end_row);
1397 dpyinfo->mouse_face_window = window;
1398 dpyinfo->mouse_face_face_id
1399 = face_at_buffer_position (w, pos, 0, 0,
1400 &ignore, pos + 1,
1401 !dpyinfo->mouse_face_hidden,
1402 -1);
1403
1404 /* Display it as active. */
1405 show_mouse_face (dpyinfo, 1);
1406 }
1407 /* Handle the text property case. */
1408 else if (! NILP (mouse_face))
1409 {
1410 /* Find the range of text around this char that
1411 should be active. */
1412 Lisp_Object before, after, beginning, end;
1413 EMACS_INT ignore;
1414
1415 beginning = Fmarker_position (w->start);
1416 XSETINT (end, (BUF_Z (XBUFFER (w->buffer))
1417 - XFASTINT (w->window_end_pos)));
1418 before
1419 = Fprevious_single_property_change (make_number (pos + 1),
1420 Qmouse_face,
1421 w->buffer, beginning);
1422 after
1423 = Fnext_single_property_change (position, Qmouse_face,
1424 w->buffer, end);
1425 /* Record this as the current active region. */
1426 fast_find_position (w, XFASTINT (before),
1427 &dpyinfo->mouse_face_beg_col,
1428 &dpyinfo->mouse_face_beg_row);
1429 dpyinfo->mouse_face_past_end
1430 = !fast_find_position (w, XFASTINT (after),
1431 &dpyinfo->mouse_face_end_col,
1432 &dpyinfo->mouse_face_end_row);
1433 dpyinfo->mouse_face_window = window;
1434 dpyinfo->mouse_face_face_id
1435 = face_at_buffer_position (w, pos, 0, 0,
1436 &ignore, pos + 1,
1437 !dpyinfo->mouse_face_hidden,
1438 -1);
1439
1440 /* Display it as active. */
1441 show_mouse_face (dpyinfo, 1);
1442 }
1443 }
1444
1445 /* Look for a `help-echo' property. */
1446 {
1447 Lisp_Object help;
1448
1449 /* Check overlays first. */
1450 help = Qnil;
1451 for (i = noverlays - 1; i >= 0 && NILP (help); --i)
1452 {
1453 overlay = overlay_vec[i];
1454 help = Foverlay_get (overlay, Qhelp_echo);
1455 }
1456
1457 if (!NILP (help))
1458 {
1459 help_echo_string = help;
1460 help_echo_window = window;
1461 help_echo_object = overlay;
1462 help_echo_pos = pos;
1463 }
1464 /* Try text properties. */
1465 else if (NILP (help)
1466 && ((STRINGP (glyph->object)
1467 && glyph->charpos >= 0
1468 && glyph->charpos < SCHARS (glyph->object))
1469 || (BUFFERP (glyph->object)
1470 && glyph->charpos >= BEGV
1471 && glyph->charpos < ZV)))
1472 {
1473 help = Fget_text_property (make_number (glyph->charpos),
1474 Qhelp_echo, glyph->object);
1475 if (!NILP (help))
1476 {
1477 help_echo_string = help;
1478 help_echo_window = window;
1479 help_echo_object = glyph->object;
1480 help_echo_pos = glyph->charpos;
1481 }
1482 }
1483 }
1484
1485 BEGV = obegv;
1486 ZV = ozv;
1487 current_buffer = obuf;
1488 }
1489 } 1017 }
1490} 1018}
1491 1019
@@ -1689,7 +1217,8 @@ static void
1689IT_update_begin (struct frame *f) 1217IT_update_begin (struct frame *f)
1690{ 1218{
1691 struct tty_display_info *display_info = FRAME_X_DISPLAY_INFO (f); 1219 struct tty_display_info *display_info = FRAME_X_DISPLAY_INFO (f);
1692 struct frame *mouse_face_frame = display_info->mouse_face_mouse_frame; 1220 Mouse_HLInfo *hlinfo = &display_info->mouse_highlight;
1221 struct frame *mouse_face_frame = hlinfo->mouse_face_mouse_frame;
1693 1222
1694 if (display_info->termscript) 1223 if (display_info->termscript)
1695 fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN"); 1224 fprintf (display_info->termscript, "\n\n<UPDATE_BEGIN");
@@ -1699,28 +1228,28 @@ IT_update_begin (struct frame *f)
1699 if (f && f == mouse_face_frame) 1228 if (f && f == mouse_face_frame)
1700 { 1229 {
1701 /* Don't do highlighting for mouse motion during the update. */ 1230 /* Don't do highlighting for mouse motion during the update. */
1702 display_info->mouse_face_defer = 1; 1231 hlinfo->mouse_face_defer = 1;
1703 1232
1704 /* If F needs to be redrawn, simply forget about any prior mouse 1233 /* If F needs to be redrawn, simply forget about any prior mouse
1705 highlighting. */ 1234 highlighting. */
1706 if (FRAME_GARBAGED_P (f)) 1235 if (FRAME_GARBAGED_P (f))
1707 display_info->mouse_face_window = Qnil; 1236 hlinfo->mouse_face_window = Qnil;
1708 1237
1709 /* Can we tell that this update does not affect the window 1238 /* Can we tell that this update does not affect the window
1710 where the mouse highlight is? If so, no need to turn off. 1239 where the mouse highlight is? If so, no need to turn off.
1711 Likewise, don't do anything if none of the enabled rows 1240 Likewise, don't do anything if none of the enabled rows
1712 contains glyphs highlighted in mouse face. */ 1241 contains glyphs highlighted in mouse face. */
1713 if (!NILP (display_info->mouse_face_window) 1242 if (!NILP (hlinfo->mouse_face_window)
1714 && WINDOWP (display_info->mouse_face_window)) 1243 && WINDOWP (hlinfo->mouse_face_window))
1715 { 1244 {
1716 struct window *w = XWINDOW (display_info->mouse_face_window); 1245 struct window *w = XWINDOW (hlinfo->mouse_face_window);
1717 int i; 1246 int i;
1718 1247
1719 /* If the mouse highlight is in the window that was deleted 1248 /* If the mouse highlight is in the window that was deleted
1720 (e.g., if it was popped by completion), clear highlight 1249 (e.g., if it was popped by completion), clear highlight
1721 unconditionally. */ 1250 unconditionally. */
1722 if (NILP (w->buffer)) 1251 if (NILP (w->buffer))
1723 display_info->mouse_face_window = Qnil; 1252 hlinfo->mouse_face_window = Qnil;
1724 else 1253 else
1725 { 1254 {
1726 for (i = 0; i < w->desired_matrix->nrows; ++i) 1255 for (i = 0; i < w->desired_matrix->nrows; ++i)
@@ -1730,18 +1259,18 @@ IT_update_begin (struct frame *f)
1730 } 1259 }
1731 1260
1732 if (NILP (w->buffer) || i < w->desired_matrix->nrows) 1261 if (NILP (w->buffer) || i < w->desired_matrix->nrows)
1733 clear_mouse_face (display_info); 1262 clear_mouse_face (hlinfo);
1734 } 1263 }
1735 } 1264 }
1736 else if (mouse_face_frame && !FRAME_LIVE_P (mouse_face_frame)) 1265 else if (mouse_face_frame && !FRAME_LIVE_P (mouse_face_frame))
1737 { 1266 {
1738 /* If the frame with mouse highlight was deleted, invalidate the 1267 /* If the frame with mouse highlight was deleted, invalidate the
1739 highlight info. */ 1268 highlight info. */
1740 display_info->mouse_face_beg_row = display_info->mouse_face_beg_col = -1; 1269 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
1741 display_info->mouse_face_end_row = display_info->mouse_face_end_col = -1; 1270 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
1742 display_info->mouse_face_window = Qnil; 1271 hlinfo->mouse_face_window = Qnil;
1743 display_info->mouse_face_deferred_gc = 0; 1272 hlinfo->mouse_face_deferred_gc = 0;
1744 display_info->mouse_face_mouse_frame = NULL; 1273 hlinfo->mouse_face_mouse_frame = NULL;
1745 } 1274 }
1746 1275
1747 UNBLOCK_INPUT; 1276 UNBLOCK_INPUT;
@@ -1754,25 +1283,25 @@ IT_update_end (struct frame *f)
1754 1283
1755 if (dpyinfo->termscript) 1284 if (dpyinfo->termscript)
1756 fprintf (dpyinfo->termscript, "\n<UPDATE_END\n"); 1285 fprintf (dpyinfo->termscript, "\n<UPDATE_END\n");
1757 dpyinfo->mouse_face_defer = 0; 1286 dpyinfo->mouse_highlight.mouse_face_defer = 0;
1758} 1287}
1759 1288
1760static void 1289static void
1761IT_frame_up_to_date (struct frame *f) 1290IT_frame_up_to_date (struct frame *f)
1762{ 1291{
1763 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 1292 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
1764 Lisp_Object new_cursor, frame_desired_cursor; 1293 Lisp_Object new_cursor, frame_desired_cursor;
1765 struct window *sw; 1294 struct window *sw;
1766 1295
1767 if (dpyinfo->mouse_face_deferred_gc 1296 if (hlinfo->mouse_face_deferred_gc
1768 || (f && f == dpyinfo->mouse_face_mouse_frame)) 1297 || (f && f == hlinfo->mouse_face_mouse_frame))
1769 { 1298 {
1770 BLOCK_INPUT; 1299 BLOCK_INPUT;
1771 if (dpyinfo->mouse_face_mouse_frame) 1300 if (hlinfo->mouse_face_mouse_frame)
1772 IT_note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, 1301 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
1773 dpyinfo->mouse_face_mouse_x, 1302 hlinfo->mouse_face_mouse_x,
1774 dpyinfo->mouse_face_mouse_y); 1303 hlinfo->mouse_face_mouse_y);
1775 dpyinfo->mouse_face_deferred_gc = 0; 1304 hlinfo->mouse_face_deferred_gc = 0;
1776 UNBLOCK_INPUT; 1305 UNBLOCK_INPUT;
1777 } 1306 }
1778 1307
@@ -2317,18 +1846,18 @@ internal_terminal_init (void)
2317 if (colors[1] >= 0 && colors[1] < 16) 1846 if (colors[1] >= 0 && colors[1] < 16)
2318 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1]; 1847 FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1];
2319 } 1848 }
2320 the_only_display_info.mouse_face_mouse_frame = NULL; 1849 the_only_display_info.mouse_highlight.mouse_face_mouse_frame = NULL;
2321 the_only_display_info.mouse_face_deferred_gc = 0; 1850 the_only_display_info.mouse_highlight.mouse_face_deferred_gc = 0;
2322 the_only_display_info.mouse_face_beg_row = 1851 the_only_display_info.mouse_highlight.mouse_face_beg_row =
2323 the_only_display_info.mouse_face_beg_col = -1; 1852 the_only_display_info.mouse_highlight.mouse_face_beg_col = -1;
2324 the_only_display_info.mouse_face_end_row = 1853 the_only_display_info.mouse_highlight.mouse_face_end_row =
2325 the_only_display_info.mouse_face_end_col = -1; 1854 the_only_display_info.mouse_highlight.mouse_face_end_col = -1;
2326 the_only_display_info.mouse_face_face_id = DEFAULT_FACE_ID; 1855 the_only_display_info.mouse_highlight.mouse_face_face_id = DEFAULT_FACE_ID;
2327 the_only_display_info.mouse_face_window = Qnil; 1856 the_only_display_info.mouse_highlight.mouse_face_window = Qnil;
2328 the_only_display_info.mouse_face_mouse_x = 1857 the_only_display_info.mouse_highlight.mouse_face_mouse_x =
2329 the_only_display_info.mouse_face_mouse_y = 0; 1858 the_only_display_info.mouse_highlight.mouse_face_mouse_y = 0;
2330 the_only_display_info.mouse_face_defer = 0; 1859 the_only_display_info.mouse_highlight.mouse_face_defer = 0;
2331 the_only_display_info.mouse_face_hidden = 0; 1860 the_only_display_info.mouse_highlight.mouse_face_hidden = 0;
2332 1861
2333 if (have_mouse) /* detected in dos_ttraw, which see */ 1862 if (have_mouse) /* detected in dos_ttraw, which see */
2334 { 1863 {
@@ -2916,7 +2445,7 @@ dos_rawgetc (void)
2916{ 2445{
2917 struct input_event event; 2446 struct input_event event;
2918 union REGS regs; 2447 union REGS regs;
2919 struct tty_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (SELECTED_FRAME()); 2448 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (SELECTED_FRAME());
2920 EVENT_INIT (event); 2449 EVENT_INIT (event);
2921 2450
2922#ifndef HAVE_X_WINDOWS 2451#ifndef HAVE_X_WINDOWS
@@ -3126,10 +2655,10 @@ dos_rawgetc (void)
3126 if (code == 0) 2655 if (code == 0)
3127 continue; 2656 continue;
3128 2657
3129 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) 2658 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
3130 { 2659 {
3131 clear_mouse_face (dpyinfo); 2660 clear_mouse_face (hlinfo);
3132 dpyinfo->mouse_face_hidden = 1; 2661 hlinfo->mouse_face_hidden = 1;
3133 } 2662 }
3134 2663
3135 if (code >= 0x100) 2664 if (code >= 0x100)
@@ -3157,10 +2686,10 @@ dos_rawgetc (void)
3157 might need to update mouse highlight. */ 2686 might need to update mouse highlight. */
3158 if (mouse_last_x != mouse_prev_x || mouse_last_y != mouse_prev_y) 2687 if (mouse_last_x != mouse_prev_x || mouse_last_y != mouse_prev_y)
3159 { 2688 {
3160 if (dpyinfo->mouse_face_hidden) 2689 if (hlinfo->mouse_face_hidden)
3161 { 2690 {
3162 dpyinfo->mouse_face_hidden = 0; 2691 hlinfo->mouse_face_hidden = 0;
3163 clear_mouse_face (dpyinfo); 2692 clear_mouse_face (hlinfo);
3164 } 2693 }
3165 2694
3166 /* Generate SELECT_WINDOW_EVENTs when needed. */ 2695 /* Generate SELECT_WINDOW_EVENTs when needed. */
@@ -3192,8 +2721,7 @@ dos_rawgetc (void)
3192 previous_help_echo_string = help_echo_string; 2721 previous_help_echo_string = help_echo_string;
3193 help_echo_string = help_echo_object = help_echo_window = Qnil; 2722 help_echo_string = help_echo_object = help_echo_window = Qnil;
3194 help_echo_pos = -1; 2723 help_echo_pos = -1;
3195 IT_note_mouse_highlight (SELECTED_FRAME(), 2724 note_mouse_highlight (SELECTED_FRAME(), mouse_last_x, mouse_last_y);
3196 mouse_last_x, mouse_last_y);
3197 /* If the contents of the global variable help_echo has 2725 /* If the contents of the global variable help_echo has
3198 changed, generate a HELP_EVENT. */ 2726 changed, generate a HELP_EVENT. */
3199 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string)) 2727 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
diff --git a/src/msdos.h b/src/msdos.h
index fe9964af25e..d07c28d410e 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -34,6 +34,7 @@ void dostounix_filename (char *);
34char *rootrelativepath (char *); 34char *rootrelativepath (char *);
35void init_environment (int, char **, int); 35void init_environment (int, char **, int);
36void internal_terminal_init (void); 36void internal_terminal_init (void);
37void initialize_msdos_display (struct terminal *);
37 38
38extern int have_mouse; 39extern int have_mouse;
39void mouse_init (void); 40void mouse_init (void);
diff --git a/src/nsterm.h b/src/nsterm.h
index 21b18f15cae..7ee960bd7a6 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -492,21 +492,9 @@ struct ns_display_info
492 /* The cursor to use for vertical scroll bars. */ 492 /* The cursor to use for vertical scroll bars. */
493 Cursor vertical_scroll_bar_cursor; 493 Cursor vertical_scroll_bar_cursor;
494 494
495 /* most mouse face stuff moved in here as of 21+ (and reasonably so) */ 495 /* Information about the range of text currently shown in
496 int mouse_face_beg_row, mouse_face_beg_col; 496 mouse-face. */
497 int mouse_face_end_row, mouse_face_end_col; 497 Mouse_HLInfo mouse_highlight;
498 int mouse_face_beg_x, mouse_face_beg_y;
499 int mouse_face_end_x, mouse_face_end_y;
500 int mouse_face_past_end;
501 Lisp_Object mouse_face_window;
502 int mouse_face_face_id;
503 int mouse_face_deferred_gc;
504 Lisp_Object mouse_face_overlay;
505 FRAME_PTR mouse_face_mouse_frame;
506 int mouse_face_mouse_x, mouse_face_mouse_y;
507 int mouse_face_defer;
508 int mouse_face_hidden;
509 int mouse_face_image_state;
510 498
511 struct frame *x_highlight_frame; 499 struct frame *x_highlight_frame;
512 struct frame *x_focus_frame; 500 struct frame *x_focus_frame;
diff --git a/src/nsterm.m b/src/nsterm.m
index bdca33efed5..10607766086 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -553,7 +553,7 @@ ns_update_window_begin (struct window *w)
553 -------------------------------------------------------------------------- */ 553 -------------------------------------------------------------------------- */
554{ 554{
555 struct frame *f = XFRAME (WINDOW_FRAME (w)); 555 struct frame *f = XFRAME (WINDOW_FRAME (w));
556 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 556 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
557 NSTRACE (ns_update_window_begin); 557 NSTRACE (ns_update_window_begin);
558 558
559 updated_window = w; 559 updated_window = w;
@@ -561,15 +561,15 @@ ns_update_window_begin (struct window *w)
561 561
562 BLOCK_INPUT; 562 BLOCK_INPUT;
563 563
564 if (f == dpyinfo->mouse_face_mouse_frame) 564 if (f == hlinfo->mouse_face_mouse_frame)
565 { 565 {
566 /* Don't do highlighting for mouse motion during the update. */ 566 /* Don't do highlighting for mouse motion during the update. */
567 dpyinfo->mouse_face_defer = 1; 567 hlinfo->mouse_face_defer = 1;
568 568
569 /* If the frame needs to be redrawn, 569 /* If the frame needs to be redrawn,
570 simply forget about any prior mouse highlighting. */ 570 simply forget about any prior mouse highlighting. */
571 if (FRAME_GARBAGED_P (f)) 571 if (FRAME_GARBAGED_P (f))
572 dpyinfo->mouse_face_window = Qnil; 572 hlinfo->mouse_face_window = Qnil;
573 573
574 /* (further code for mouse faces ifdef'd out in other terms elided) */ 574 /* (further code for mouse faces ifdef'd out in other terms elided) */
575 } 575 }
@@ -586,7 +586,7 @@ ns_update_window_end (struct window *w, int cursor_on_p,
586 external (RIF) call; for one window called before update_end 586 external (RIF) call; for one window called before update_end
587 -------------------------------------------------------------------------- */ 587 -------------------------------------------------------------------------- */
588{ 588{
589 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (XFRAME (w->frame)); 589 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
590 590
591 /* note: this fn is nearly identical in all terms */ 591 /* note: this fn is nearly identical in all terms */
592 if (!w->pseudo_window_p) 592 if (!w->pseudo_window_p)
@@ -608,9 +608,9 @@ ns_update_window_end (struct window *w, int cursor_on_p,
608 frame_up_to_date to redisplay the mouse highlight. */ 608 frame_up_to_date to redisplay the mouse highlight. */
609 if (mouse_face_overwritten_p) 609 if (mouse_face_overwritten_p)
610 { 610 {
611 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 611 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
612 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 612 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
613 dpyinfo->mouse_face_window = Qnil; 613 hlinfo->mouse_face_window = Qnil;
614 } 614 }
615 615
616 updated_window = NULL; 616 updated_window = NULL;
@@ -627,8 +627,8 @@ ns_update_end (struct frame *f)
627{ 627{
628 NSView *view = FRAME_NS_VIEW (f); 628 NSView *view = FRAME_NS_VIEW (f);
629 629
630/* if (f == FRAME_NS_DISPLAY_INFO (f)->mouse_face_mouse_frame) */ 630/* if (f == MOUSE_HL_INFO (f)->mouse_face_mouse_frame) */
631 FRAME_NS_DISPLAY_INFO (f)->mouse_face_defer = 0; 631 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
632 632
633 BLOCK_INPUT; 633 BLOCK_INPUT;
634 634
@@ -1032,6 +1032,7 @@ x_destroy_window (struct frame *f)
1032{ 1032{
1033 NSView *view = FRAME_NS_VIEW (f); 1033 NSView *view = FRAME_NS_VIEW (f);
1034 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1034 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
1035 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
1035 NSTRACE (x_destroy_window); 1036 NSTRACE (x_destroy_window);
1036 check_ns (); 1037 check_ns ();
1037 1038
@@ -1048,13 +1049,13 @@ x_destroy_window (struct frame *f)
1048 dpyinfo->x_focus_frame = 0; 1049 dpyinfo->x_focus_frame = 0;
1049 if (f == dpyinfo->x_highlight_frame) 1050 if (f == dpyinfo->x_highlight_frame)
1050 dpyinfo->x_highlight_frame = 0; 1051 dpyinfo->x_highlight_frame = 0;
1051 if (f == dpyinfo->mouse_face_mouse_frame) 1052 if (f == hlinfo->mouse_face_mouse_frame)
1052 { 1053 {
1053 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 1054 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
1054 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 1055 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
1055 dpyinfo->mouse_face_window = Qnil; 1056 hlinfo->mouse_face_window = Qnil;
1056 dpyinfo->mouse_face_deferred_gc = 0; 1057 hlinfo->mouse_face_deferred_gc = 0;
1057 dpyinfo->mouse_face_mouse_frame = 0; 1058 hlinfo->mouse_face_mouse_frame = 0;
1058 } 1059 }
1059 1060
1060 xfree (f->output_data.ns); 1061 xfree (f->output_data.ns);
@@ -1772,18 +1773,18 @@ ns_frame_up_to_date (struct frame *f)
1772 1773
1773 if (FRAME_NS_P (f)) 1774 if (FRAME_NS_P (f))
1774 { 1775 {
1775 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f); 1776 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
1776 if ((dpyinfo->mouse_face_deferred_gc||f ==dpyinfo->mouse_face_mouse_frame) 1777 if ((hlinfo->mouse_face_deferred_gc || f ==hlinfo->mouse_face_mouse_frame)
1777 /*&& dpyinfo->mouse_face_mouse_frame*/) 1778 /*&& hlinfo->mouse_face_mouse_frame*/)
1778 { 1779 {
1779 BLOCK_INPUT; 1780 BLOCK_INPUT;
1780 ns_update_begin(f); 1781 ns_update_begin(f);
1781 if (dpyinfo->mouse_face_mouse_frame) 1782 if (hlinfo->mouse_face_mouse_frame)
1782 note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, 1783 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
1783 dpyinfo->mouse_face_mouse_x, 1784 hlinfo->mouse_face_mouse_x,
1784 dpyinfo->mouse_face_mouse_y); 1785 hlinfo->mouse_face_mouse_y);
1785 dpyinfo->mouse_face_deferred_gc = 0; 1786 hlinfo->mouse_face_deferred_gc = 0;
1786 ns_update_end(f); 1787 ns_update_end(f);
1787 UNBLOCK_INPUT; 1788 UNBLOCK_INPUT;
1788 } 1789 }
1789 } 1790 }
@@ -2595,8 +2596,7 @@ ns_dumpglyphs_box_or_relief (struct glyph_string *s)
2595 2596
2596 if (s->hl == DRAW_MOUSE_FACE) 2597 if (s->hl == DRAW_MOUSE_FACE)
2597 { 2598 {
2598 face = FACE_FROM_ID 2599 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
2599 (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
2600 if (!face) 2600 if (!face)
2601 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 2601 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2602 } 2602 }
@@ -2663,8 +2663,8 @@ ns_maybe_dumpglyphs_background (struct glyph_string *s, char force_p)
2663 struct face *face; 2663 struct face *face;
2664 if (s->hl == DRAW_MOUSE_FACE) 2664 if (s->hl == DRAW_MOUSE_FACE)
2665 { 2665 {
2666 face = FACE_FROM_ID 2666 face = FACE_FROM_ID (s->f,
2667 (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id); 2667 MOUSE_HL_INFO (s->f)->mouse_face_face_id);
2668 if (!face) 2668 if (!face)
2669 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 2669 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2670 } 2670 }
@@ -2749,8 +2749,7 @@ ns_dumpglyphs_image (struct glyph_string *s, NSRect r)
2749 with its background color), we must clear just the image area. */ 2749 with its background color), we must clear just the image area. */
2750 if (s->hl == DRAW_MOUSE_FACE) 2750 if (s->hl == DRAW_MOUSE_FACE)
2751 { 2751 {
2752 face = FACE_FROM_ID 2752 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
2753 (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
2754 if (!face) 2753 if (!face)
2755 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 2754 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2756 } 2755 }
@@ -2873,8 +2872,7 @@ ns_dumpglyphs_stretch (struct glyph_string *s)
2873 2872
2874 if (s->hl == DRAW_MOUSE_FACE) 2873 if (s->hl == DRAW_MOUSE_FACE)
2875 { 2874 {
2876 face = FACE_FROM_ID 2875 face = FACE_FROM_ID (s->f, MOUSE_HL_INFO (s->f)->mouse_face_face_id);
2877 (s->f, FRAME_NS_DISPLAY_INFO (s->f)->mouse_face_face_id);
2878 if (!face) 2876 if (!face)
2879 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 2877 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
2880 } 2878 }
@@ -3545,6 +3543,7 @@ ns_initialize_display_info (struct ns_display_info *dpyinfo)
3545{ 3543{
3546 NSScreen *screen = [NSScreen mainScreen]; 3544 NSScreen *screen = [NSScreen mainScreen];
3547 NSWindowDepth depth = [screen depth]; 3545 NSWindowDepth depth = [screen depth];
3546 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
3548 3547
3549 dpyinfo->resx = 72.27; /* used 75.0, but this makes pt == pixel, expected */ 3548 dpyinfo->resx = 72.27; /* used 75.0, but this makes pt == pixel, expected */
3550 dpyinfo->resy = 72.27; 3549 dpyinfo->resy = 72.27;
@@ -3559,16 +3558,16 @@ ns_initialize_display_info (struct ns_display_info *dpyinfo)
3559 dpyinfo->color_table->colors = NULL; 3558 dpyinfo->color_table->colors = NULL;
3560 dpyinfo->root_window = 42; /* a placeholder.. */ 3559 dpyinfo->root_window = 42; /* a placeholder.. */
3561 3560
3562 dpyinfo->mouse_face_mouse_frame = NULL; 3561 hlinfo->mouse_face_mouse_frame = NULL;
3563 dpyinfo->mouse_face_deferred_gc = 0; 3562 hlinfo->mouse_face_deferred_gc = 0;
3564 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 3563 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
3565 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 3564 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
3566 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; 3565 hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
3567 dpyinfo->mouse_face_window = dpyinfo->mouse_face_overlay = Qnil; 3566 hlinfo->mouse_face_window = hlinfo->mouse_face_overlay = Qnil;
3568 dpyinfo->mouse_face_hidden = 0; 3567 hlinfo->mouse_face_hidden = 0;
3569 3568
3570 dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0; 3569 hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0;
3571 dpyinfo->mouse_face_defer = 0; 3570 hlinfo->mouse_face_defer = 0;
3572 3571
3573 dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame = NULL; 3572 dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame = NULL;
3574 3573
@@ -4351,7 +4350,7 @@ ns_term_shutdown (int sig)
4351 4350
4352- (void)keyDown: (NSEvent *)theEvent 4351- (void)keyDown: (NSEvent *)theEvent
4353{ 4352{
4354 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); 4353 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
4355 int code; 4354 int code;
4356 unsigned fnKeysym = 0; 4355 unsigned fnKeysym = 0;
4357 int flags; 4356 int flags;
@@ -4389,10 +4388,10 @@ ns_term_shutdown (int sig)
4389 4388
4390 [NSCursor setHiddenUntilMouseMoves: YES]; 4389 [NSCursor setHiddenUntilMouseMoves: YES];
4391 4390
4392 if (dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) 4391 if (hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
4393 { 4392 {
4394 clear_mouse_face (dpyinfo); 4393 clear_mouse_face (hlinfo);
4395 dpyinfo->mouse_face_hidden = 1; 4394 hlinfo->mouse_face_hidden = 1;
4396 } 4395 }
4397 4396
4398 if (!processingCompose) 4397 if (!processingCompose)
@@ -4829,7 +4828,7 @@ ns_term_shutdown (int sig)
4829/* Tell emacs the mouse has moved. */ 4828/* Tell emacs the mouse has moved. */
4830- (void)mouseMoved: (NSEvent *)e 4829- (void)mouseMoved: (NSEvent *)e
4831{ 4830{
4832 struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe); 4831 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
4833 Lisp_Object frame; 4832 Lisp_Object frame;
4834 4833
4835// NSTRACE (mouseMoved); 4834// NSTRACE (mouseMoved);
@@ -4839,10 +4838,10 @@ ns_term_shutdown (int sig)
4839 = [self convertPoint: [e locationInWindow] fromView: nil]; 4838 = [self convertPoint: [e locationInWindow] fromView: nil];
4840 4839
4841 /* update any mouse face */ 4840 /* update any mouse face */
4842 if (dpyinfo->mouse_face_hidden) 4841 if (hlinfo->mouse_face_hidden)
4843 { 4842 {
4844 dpyinfo->mouse_face_hidden = 0; 4843 hlinfo->mouse_face_hidden = 0;
4845 clear_mouse_face (dpyinfo); 4844 clear_mouse_face (hlinfo);
4846 } 4845 }
4847 4846
4848 /* tooltip handling */ 4847 /* tooltip handling */
@@ -5308,20 +5307,19 @@ ns_term_shutdown (int sig)
5308{ 5307{
5309 NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil]; 5308 NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
5310 NSRect r; 5309 NSRect r;
5311 struct ns_display_info *dpyinfo 5310 Mouse_HLInfo *hlinfo = emacsframe ? MOUSE_HL_INFO (emacsframe) : NULL;
5312 = emacsframe ? FRAME_NS_DISPLAY_INFO (emacsframe) : NULL;
5313 5311
5314 NSTRACE (mouseExited); 5312 NSTRACE (mouseExited);
5315 5313
5316 if (!dpyinfo) 5314 if (!hlinfo)
5317 return; 5315 return;
5318 5316
5319 last_mouse_movement_time = EV_TIMESTAMP (theEvent); 5317 last_mouse_movement_time = EV_TIMESTAMP (theEvent);
5320 5318
5321 if (emacsframe == dpyinfo->mouse_face_mouse_frame) 5319 if (emacsframe == hlinfo->mouse_face_mouse_frame)
5322 { 5320 {
5323 clear_mouse_face (dpyinfo); 5321 clear_mouse_face (hlinfo);
5324 dpyinfo->mouse_face_mouse_frame = 0; 5322 hlinfo->mouse_face_mouse_frame = 0;
5325 } 5323 }
5326} 5324}
5327 5325
diff --git a/src/term.c b/src/term.c
index 9bc980a4aa8..dbbdc03f190 100644
--- a/src/term.c
+++ b/src/term.c
@@ -184,24 +184,10 @@ extern char *tgetstr (char *, char **);
184#ifdef HAVE_GPM 184#ifdef HAVE_GPM
185#include <sys/fcntl.h> 185#include <sys/fcntl.h>
186 186
187static void term_clear_mouse_face (void);
188static void term_mouse_highlight (struct frame *f, int x, int y);
189
190/* The device for which we have enabled gpm support (or NULL). */ 187/* The device for which we have enabled gpm support (or NULL). */
191struct tty_display_info *gpm_tty = NULL; 188struct tty_display_info *gpm_tty = NULL;
192 189
193/* These variables describe the range of text currently shown in its 190/* Last recorded mouse coordinates. */
194 mouse-face, together with the window they apply to. As long as
195 the mouse stays within this range, we need not redraw anything on
196 its account. Rows and columns are glyph matrix positions in
197 MOUSE_FACE_WINDOW. */
198static int mouse_face_beg_row, mouse_face_beg_col;
199static int mouse_face_end_row, mouse_face_end_col;
200static int mouse_face_past_end;
201static Lisp_Object mouse_face_window;
202static int mouse_face_face_id;
203
204static int pos_x, pos_y;
205static int last_mouse_x, last_mouse_y; 191static int last_mouse_x, last_mouse_y;
206#endif /* HAVE_GPM */ 192#endif /* HAVE_GPM */
207 193
@@ -2686,416 +2672,36 @@ term_mouse_moveto (int x, int y)
2686 last_mouse_y = y; */ 2672 last_mouse_y = y; */
2687} 2673}
2688 2674
2689static void 2675/* Implementation of draw_row_with_mouse_face for TTY/GPM. */
2690term_show_mouse_face (enum draw_glyphs_face draw) 2676void
2677tty_draw_row_with_mouse_face (struct window *w, struct glyph_row *row,
2678 int start_hpos, int end_hpos,
2679 enum draw_glyphs_face draw)
2691{ 2680{
2692 struct window *w = XWINDOW (mouse_face_window); 2681 int nglyphs = end_hpos - start_hpos;
2693 int save_x, save_y; 2682 struct frame *f = XFRAME (WINDOW_FRAME (w));
2694 int i;
2695
2696 struct frame *f = XFRAME (w->frame);
2697 struct tty_display_info *tty = FRAME_TTY (f); 2683 struct tty_display_info *tty = FRAME_TTY (f);
2684 int face_id = tty->mouse_highlight.mouse_face_face_id;
2685 int save_x, save_y, pos_x, pos_y;
2698 2686
2699 if (/* If window is in the process of being destroyed, don't bother 2687 if (end_hpos >= row->used[TEXT_AREA])
2700 to do anything. */ 2688 nglyphs = row->used[TEXT_AREA] - start_hpos;
2701 w->current_matrix != NULL
2702 /* Recognize when we are called to operate on rows that don't exist
2703 anymore. This can happen when a window is split. */
2704 && mouse_face_end_row < w->current_matrix->nrows)
2705 {
2706 /* write_glyphs writes at cursor position, so we need to
2707 temporarily move cursor coordinates to the beginning of
2708 the highlight region. */
2709
2710 /* Save current cursor co-ordinates */
2711 save_y = curY (tty);
2712 save_x = curX (tty);
2713
2714 /* Note that mouse_face_beg_row etc. are window relative. */
2715 for (i = mouse_face_beg_row; i <= mouse_face_end_row; i++)
2716 {
2717 int start_hpos, end_hpos, nglyphs;
2718 struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
2719
2720 /* Don't do anything if row doesn't have valid contents. */
2721 if (!row->enabled_p)
2722 continue;
2723
2724 /* For all but the first row, the highlight starts at column 0. */
2725 if (i == mouse_face_beg_row)
2726 start_hpos = mouse_face_beg_col;
2727 else
2728 start_hpos = 0;
2729
2730 if (i == mouse_face_end_row)
2731 end_hpos = mouse_face_end_col;
2732 else
2733 {
2734 end_hpos = row->used[TEXT_AREA];
2735 if (draw == DRAW_NORMAL_TEXT)
2736 row->fill_line_p = 1; /* Clear to end of line */
2737 }
2738
2739 if (end_hpos <= start_hpos)
2740 continue;
2741 /* Record that some glyphs of this row are displayed in
2742 mouse-face. */
2743 row->mouse_face_p = draw > 0;
2744
2745 nglyphs = end_hpos - start_hpos;
2746 2689
2747 if (end_hpos >= row->used[TEXT_AREA]) 2690 pos_y = row->y + WINDOW_TOP_EDGE_Y (w);
2748 nglyphs = row->used[TEXT_AREA] - start_hpos; 2691 pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos + WINDOW_LEFT_EDGE_X (w);
2749 2692
2750 pos_y = row->y + WINDOW_TOP_EDGE_Y (w); 2693 /* Save current cursor co-ordinates. */
2751 pos_x = row->used[LEFT_MARGIN_AREA] + start_hpos 2694 save_y = curY (tty);
2752 + WINDOW_LEFT_EDGE_X (w); 2695 save_x = curX (tty);
2753 2696 cursor_to (f, pos_y, pos_x);
2754 cursor_to (f, pos_y, pos_x);
2755
2756 if (draw == DRAW_MOUSE_FACE)
2757 {
2758 tty_write_glyphs_with_face (f, row->glyphs[TEXT_AREA] + start_hpos,
2759 nglyphs, mouse_face_face_id);
2760 }
2761 else /* draw == DRAW_NORMAL_TEXT */
2762 write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
2763 }
2764 cursor_to (f, save_y, save_x);
2765 }
2766}
2767 2697
2768static void 2698 if (draw == DRAW_MOUSE_FACE)
2769term_clear_mouse_face (void) 2699 tty_write_glyphs_with_face (f, row->glyphs[TEXT_AREA] + start_hpos,
2770{ 2700 nglyphs, face_id);
2771 if (!NILP (mouse_face_window)) 2701 else if (draw == DRAW_NORMAL_TEXT)
2772 term_show_mouse_face (DRAW_NORMAL_TEXT); 2702 write_glyphs (f, row->glyphs[TEXT_AREA] + start_hpos, nglyphs);
2773 2703
2774 mouse_face_beg_row = mouse_face_beg_col = -1; 2704 cursor_to (f, save_y, save_x);
2775 mouse_face_end_row = mouse_face_end_col = -1;
2776 mouse_face_window = Qnil;
2777}
2778
2779/* Find the glyph matrix position of buffer position POS in window W.
2780 *HPOS and *VPOS are set to the positions found. W's current glyphs
2781 must be up to date. If POS is above window start return (0, 0).
2782 If POS is after end of W, return end of last line in W.
2783 - taken from msdos.c */
2784static int
2785fast_find_position (struct window *w, EMACS_INT pos, int *hpos, int *vpos)
2786{
2787 int i, lastcol, maybe_next_line_p = 0;
2788 EMACS_INT line_start_position;
2789 int yb = window_text_bottom_y (w);
2790 struct glyph_row *row = MATRIX_ROW (w->current_matrix, 0), *best_row = row;
2791
2792 while (row->y < yb)
2793 {
2794 if (row->used[TEXT_AREA])
2795 line_start_position = row->glyphs[TEXT_AREA]->charpos;
2796 else
2797 line_start_position = 0;
2798
2799 if (line_start_position > pos)
2800 break;
2801 /* If the position sought is the end of the buffer,
2802 don't include the blank lines at the bottom of the window. */
2803 else if (line_start_position == pos
2804 && pos == BUF_ZV (XBUFFER (w->buffer)))
2805 {
2806 maybe_next_line_p = 1;
2807 break;
2808 }
2809 else if (line_start_position > 0)
2810 best_row = row;
2811
2812 /* Don't overstep the last matrix row, lest we get into the
2813 never-never land... */
2814 if (row->y + 1 >= yb)
2815 break;
2816
2817 ++row;
2818 }
2819
2820 /* Find the right column within BEST_ROW. */
2821 lastcol = 0;
2822 row = best_row;
2823 for (i = 0; i < row->used[TEXT_AREA]; i++)
2824 {
2825 struct glyph *glyph = row->glyphs[TEXT_AREA] + i;
2826 EMACS_INT charpos;
2827
2828 charpos = glyph->charpos;
2829 if (charpos == pos)
2830 {
2831 *hpos = i;
2832 *vpos = row->y;
2833 return 1;
2834 }
2835 else if (charpos > pos)
2836 break;
2837 else if (charpos > 0)
2838 lastcol = i;
2839 }
2840
2841 /* If we're looking for the end of the buffer,
2842 and we didn't find it in the line we scanned,
2843 use the start of the following line. */
2844 if (maybe_next_line_p)
2845 {
2846 ++row;
2847 lastcol = 0;
2848 }
2849
2850 *vpos = row->y;
2851 *hpos = lastcol + 1;
2852 return 0;
2853}
2854
2855static void
2856term_mouse_highlight (struct frame *f, int x, int y)
2857{
2858 enum window_part part;
2859 Lisp_Object window;
2860 struct window *w;
2861 struct buffer *b;
2862
2863 if (NILP (Vmouse_highlight)
2864 || !f->glyphs_initialized_p)
2865 return;
2866
2867 /* Which window is that in? */
2868 window = window_from_coordinates (f, x, y, &part, &x, &y, 0);
2869
2870 /* Not on a window -> return. */
2871 if (!WINDOWP (window))
2872 return;
2873
2874 if (!EQ (window, mouse_face_window))
2875 term_clear_mouse_face ();
2876
2877 w = XWINDOW (window);
2878
2879 /* Are we in a window whose display is up to date?
2880 And verify the buffer's text has not changed. */
2881 b = XBUFFER (w->buffer);
2882 if (part == ON_TEXT
2883 && EQ (w->window_end_valid, w->buffer)
2884 && XFASTINT (w->last_modified) == BUF_MODIFF (b)
2885 && XFASTINT (w->last_overlay_modified) == BUF_OVERLAY_MODIFF (b))
2886 {
2887 int i, nrows = w->current_matrix->nrows;
2888 EMACS_INT pos;
2889 struct glyph_row *row;
2890 struct glyph *glyph;
2891
2892 /* Find the glyph under X/Y. */
2893 glyph = NULL;
2894 if (y >= 0 && y < nrows)
2895 {
2896 row = MATRIX_ROW (w->current_matrix, y);
2897 /* Give up if some row before the one we are looking for is
2898 not enabled. */
2899 for (i = 0; i <= y; i++)
2900 if (!MATRIX_ROW (w->current_matrix, i)->enabled_p)
2901 break;
2902 if (i > y /* all rows upto and including the one at Y are enabled */
2903 && row->displays_text_p
2904 && x < window_box_width (w, TEXT_AREA))
2905 {
2906 glyph = row->glyphs[TEXT_AREA];
2907 if (x >= row->used[TEXT_AREA])
2908 glyph = NULL;
2909 else
2910 {
2911 glyph += x;
2912 if (!BUFFERP (glyph->object))
2913 glyph = NULL;
2914 }
2915 }
2916 }
2917
2918 /* Clear mouse face if X/Y not over text. */
2919 if (glyph == NULL)
2920 {
2921 term_clear_mouse_face ();
2922 return;
2923 }
2924
2925 if (!BUFFERP (glyph->object))
2926 abort ();
2927 pos = glyph->charpos;
2928
2929 /* Check for mouse-face. */
2930 {
2931 Lisp_Object mouse_face, overlay, position, *overlay_vec;
2932 int noverlays;
2933 EMACS_INT obegv, ozv;
2934 struct buffer *obuf;
2935
2936 /* If we get an out-of-range value, return now; avoid an error. */
2937 if (pos > BUF_Z (b))
2938 return;
2939
2940 /* Make the window's buffer temporarily current for
2941 overlays_at and compute_char_face. */
2942 obuf = current_buffer;
2943 current_buffer = b;
2944 obegv = BEGV;
2945 ozv = ZV;
2946 BEGV = BEG;
2947 ZV = Z;
2948
2949 /* Is this char mouse-active? */
2950 XSETINT (position, pos);
2951
2952 /* Put all the overlays we want in a vector in overlay_vec. */
2953 GET_OVERLAYS_AT (pos, overlay_vec, noverlays, NULL, 0);
2954 /* Sort overlays into increasing priority order. */
2955 noverlays = sort_overlays (overlay_vec, noverlays, w);
2956
2957 /* Check mouse-face highlighting. */
2958 if (!(EQ (window, mouse_face_window)
2959 && y >= mouse_face_beg_row
2960 && y <= mouse_face_end_row
2961 && (y > mouse_face_beg_row
2962 || x >= mouse_face_beg_col)
2963 && (y < mouse_face_end_row
2964 || x < mouse_face_end_col
2965 || mouse_face_past_end)))
2966 {
2967 /* Clear the display of the old active region, if any. */
2968 term_clear_mouse_face ();
2969
2970 /* Find the highest priority overlay that has a mouse-face
2971 property. */
2972 overlay = Qnil;
2973 for (i = noverlays - 1; i >= 0; --i)
2974 {
2975 mouse_face = Foverlay_get (overlay_vec[i], Qmouse_face);
2976 if (!NILP (mouse_face))
2977 {
2978 overlay = overlay_vec[i];
2979 break;
2980 }
2981 }
2982
2983 /* If no overlay applies, get a text property. */
2984 if (NILP (overlay))
2985 mouse_face = Fget_text_property (position, Qmouse_face,
2986 w->buffer);
2987
2988 /* Handle the overlay case. */
2989 if (!NILP (overlay))
2990 {
2991 /* Find the range of text around this char that
2992 should be active. */
2993 Lisp_Object before, after;
2994 EMACS_INT ignore;
2995
2996
2997 before = Foverlay_start (overlay);
2998 after = Foverlay_end (overlay);
2999 /* Record this as the current active region. */
3000 fast_find_position (w, XFASTINT (before),
3001 &mouse_face_beg_col,
3002 &mouse_face_beg_row);
3003
3004 mouse_face_past_end
3005 = !fast_find_position (w, XFASTINT (after),
3006 &mouse_face_end_col,
3007 &mouse_face_end_row);
3008 mouse_face_window = window;
3009
3010 mouse_face_face_id
3011 = face_at_buffer_position (w, pos, 0, 0,
3012 &ignore, pos + 1, 1, -1);
3013
3014 /* Display it as active. */
3015 term_show_mouse_face (DRAW_MOUSE_FACE);
3016 }
3017 /* Handle the text property case. */
3018 else if (!NILP (mouse_face))
3019 {
3020 /* Find the range of text around this char that
3021 should be active. */
3022 Lisp_Object before, after, beginning, end;
3023 EMACS_INT ignore;
3024
3025 beginning = Fmarker_position (w->start);
3026 XSETINT (end, (BUF_Z (b) - XFASTINT (w->window_end_pos)));
3027 before
3028 = Fprevious_single_property_change (make_number (pos + 1),
3029 Qmouse_face,
3030 w->buffer, beginning);
3031 after
3032 = Fnext_single_property_change (position, Qmouse_face,
3033 w->buffer, end);
3034
3035 /* Record this as the current active region. */
3036 fast_find_position (w, XFASTINT (before),
3037 &mouse_face_beg_col,
3038 &mouse_face_beg_row);
3039 mouse_face_past_end
3040 = !fast_find_position (w, XFASTINT (after),
3041 &mouse_face_end_col,
3042 &mouse_face_end_row);
3043 mouse_face_window = window;
3044
3045 mouse_face_face_id
3046 = face_at_buffer_position (w, pos, 0, 0,
3047 &ignore, pos + 1, 1, -1);
3048
3049 /* Display it as active. */
3050 term_show_mouse_face (DRAW_MOUSE_FACE);
3051 }
3052 }
3053
3054 /* Look for a `help-echo' property. */
3055 {
3056 Lisp_Object help;
3057
3058 /* Check overlays first. */
3059 help = Qnil;
3060 for (i = noverlays - 1; i >= 0 && NILP (help); --i)
3061 {
3062 overlay = overlay_vec[i];
3063 help = Foverlay_get (overlay, Qhelp_echo);
3064 }
3065
3066 if (!NILP (help))
3067 {
3068 help_echo_string = help;
3069 help_echo_window = window;
3070 help_echo_object = overlay;
3071 help_echo_pos = pos;
3072 }
3073 /* Try text properties. */
3074 else if (NILP (help)
3075 && ((STRINGP (glyph->object)
3076 && glyph->charpos >= 0
3077 && glyph->charpos < SCHARS (glyph->object))
3078 || (BUFFERP (glyph->object)
3079 && glyph->charpos >= BEGV
3080 && glyph->charpos < ZV)))
3081 {
3082 help = Fget_text_property (make_number (glyph->charpos),
3083 Qhelp_echo, glyph->object);
3084 if (!NILP (help))
3085 {
3086 help_echo_string = help;
3087 help_echo_window = window;
3088 help_echo_object = glyph->object;
3089 help_echo_pos = glyph->charpos;
3090 }
3091 }
3092 }
3093
3094 BEGV = obegv;
3095 ZV = ozv;
3096 current_buffer = obuf;
3097 }
3098 }
3099} 2705}
3100 2706
3101static int 2707static int
@@ -3105,7 +2711,7 @@ term_mouse_movement (FRAME_PTR frame, Gpm_Event *event)
3105 if (event->x != last_mouse_x || event->y != last_mouse_y) 2711 if (event->x != last_mouse_x || event->y != last_mouse_y)
3106 { 2712 {
3107 frame->mouse_moved = 1; 2713 frame->mouse_moved = 1;
3108 term_mouse_highlight (frame, event->x, event->y); 2714 note_mouse_highlight (frame, event->x, event->y);
3109 /* Remember which glyph we're now on. */ 2715 /* Remember which glyph we're now on. */
3110 last_mouse_x = event->x; 2716 last_mouse_x = event->x;
3111 last_mouse_y = event->y; 2717 last_mouse_y = event->y;
@@ -3576,7 +3182,7 @@ init_tty (const char *name, const char *terminal_type, int must_succeed)
3576 3182
3577#ifdef HAVE_GPM 3183#ifdef HAVE_GPM
3578 terminal->mouse_position_hook = term_mouse_position; 3184 terminal->mouse_position_hook = term_mouse_position;
3579 mouse_face_window = Qnil; 3185 tty->mouse_highlight.mouse_face_window = Qnil;
3580#endif 3186#endif
3581 3187
3582 3188
@@ -4211,8 +3817,6 @@ bigger, or it may make it blink, or it may do nothing at all. */);
4211#ifdef HAVE_GPM 3817#ifdef HAVE_GPM
4212 defsubr (&Sgpm_mouse_start); 3818 defsubr (&Sgpm_mouse_start);
4213 defsubr (&Sgpm_mouse_stop); 3819 defsubr (&Sgpm_mouse_stop);
4214
4215 staticpro (&mouse_face_window);
4216#endif /* HAVE_GPM */ 3820#endif /* HAVE_GPM */
4217 3821
4218#ifndef DOS_NT 3822#ifndef DOS_NT
diff --git a/src/termchar.h b/src/termchar.h
index 8135ac723e5..ac652640b17 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -34,18 +34,18 @@ struct tty_output
34struct tty_display_info 34struct tty_display_info
35{ 35{
36 struct tty_display_info *next; /* Chain of all tty devices. */ 36 struct tty_display_info *next; /* Chain of all tty devices. */
37 37
38 char *name; /* The name of the device file or 0 if 38 char *name; /* The name of the device file or 0 if
39 stdin/stdout. */ 39 stdin/stdout. */
40 char *type; /* The type of the tty. */ 40 char *type; /* The type of the tty. */
41 41
42 /* Input/output */ 42 /* Input/output */
43 43
44 FILE *input; /* The stream to be used for terminal input. 44 FILE *input; /* The stream to be used for terminal input.
45 NULL if the terminal is suspended. */ 45 NULL if the terminal is suspended. */
46 FILE *output; /* The stream to be used for terminal output. 46 FILE *output; /* The stream to be used for terminal output.
47 NULL if the terminal is suspended. */ 47 NULL if the terminal is suspended. */
48 48
49 FILE *termscript; /* If nonzero, send all terminal output 49 FILE *termscript; /* If nonzero, send all terminal output
50 characters to this stream also. */ 50 characters to this stream also. */
51 51
@@ -65,38 +65,14 @@ struct tty_display_info
65 /* Redisplay. */ 65 /* Redisplay. */
66 66
67 Lisp_Object top_frame; /* The topmost frame on this tty. */ 67 Lisp_Object top_frame; /* The topmost frame on this tty. */
68 68
69 /* The previous frame we displayed on this tty. */ 69 /* The previous frame we displayed on this tty. */
70 struct frame *previous_frame; 70 struct frame *previous_frame;
71 int previous_color_mode; 71 int previous_color_mode;
72 72
73#ifdef MSDOS 73 /* Information about the range of text currently shown in
74 /* These variables describe the range of text currently shown in its 74 mouse-face. */
75 mouse-face, together with the window they apply to. As long as 75 Mouse_HLInfo mouse_highlight;
76 the mouse stays within this range, we need not redraw anything on
77 its account. Rows and columns are glyph matrix positions in
78 MOUSE_FACE_WINDOW. */
79 int mouse_face_beg_row, mouse_face_beg_col;
80 int mouse_face_end_row, mouse_face_end_col;
81 int mouse_face_past_end;
82 Lisp_Object mouse_face_window;
83 int mouse_face_face_id;
84
85 /* 1 if a mouse motion event came and we didn't handle it right away because
86 gc was in progress. */
87 int mouse_face_deferred_gc;
88
89 /* FRAME and X, Y position of mouse when last checked for
90 highlighting. X and Y can be negative or out of range for the frame. */
91 struct frame *mouse_face_mouse_frame;
92 int mouse_face_mouse_x, mouse_face_mouse_y;
93
94 /* Nonzero means defer mouse-motion highlighting. */
95 int mouse_face_defer;
96
97 /* Nonzero means that the mouse highlight should not be shown. */
98 int mouse_face_hidden;
99#endif /* !MSDOS */
100 76
101 /* Buffer used internally by termcap (see tgetent in the Termcap 77 /* Buffer used internally by termcap (see tgetent in the Termcap
102 manual). Only init_tty and delete_tty should change this. */ 78 manual). Only init_tty and delete_tty should change this. */
@@ -190,12 +166,12 @@ struct tty_display_info
190 int RPov; /* # chars to start a TS_repeat */ 166 int RPov; /* # chars to start a TS_repeat */
191 167
192 int delete_in_insert_mode; /* delete mode == insert mode */ 168 int delete_in_insert_mode; /* delete mode == insert mode */
193 169
194 int se_is_so; /* 1 if same string both enters and leaves 170 int se_is_so; /* 1 if same string both enters and leaves
195 standout mode */ 171 standout mode */
196 172
197 int costs_set; /* Nonzero if costs have been calculated. */ 173 int costs_set; /* Nonzero if costs have been calculated. */
198 174
199 int insert_mode; /* Nonzero when in insert mode. */ 175 int insert_mode; /* Nonzero when in insert mode. */
200 int standout_mode; /* Nonzero when in standout mode. */ 176 int standout_mode; /* Nonzero when in standout mode. */
201 177
@@ -214,7 +190,7 @@ struct tty_display_info
214 lines from those operations. */ 190 lines from those operations. */
215 191
216 int specified_window; 192 int specified_window;
217 193
218 /* Flag used in tty_show/hide_cursor. */ 194 /* Flag used in tty_show/hide_cursor. */
219 195
220 int cursor_hidden; 196 int cursor_hidden;
diff --git a/src/w32term.c b/src/w32term.c
index a491e0941db..a93bc064c39 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -505,7 +505,7 @@ static void
505x_update_window_begin (struct window *w) 505x_update_window_begin (struct window *w)
506{ 506{
507 struct frame *f = XFRAME (WINDOW_FRAME (w)); 507 struct frame *f = XFRAME (WINDOW_FRAME (w));
508 struct w32_display_info *display_info = FRAME_W32_DISPLAY_INFO (f); 508 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
509 509
510 /* Hide the system caret during an update. */ 510 /* Hide the system caret during an update. */
511 if (w32_use_visible_system_caret && w32_system_caret_hwnd) 511 if (w32_use_visible_system_caret && w32_system_caret_hwnd)
@@ -518,15 +518,15 @@ x_update_window_begin (struct window *w)
518 518
519 BLOCK_INPUT; 519 BLOCK_INPUT;
520 520
521 if (f == display_info->mouse_face_mouse_frame) 521 if (f == hlinfo->mouse_face_mouse_frame)
522 { 522 {
523 /* Don't do highlighting for mouse motion during the update. */ 523 /* Don't do highlighting for mouse motion during the update. */
524 display_info->mouse_face_defer = 1; 524 hlinfo->mouse_face_defer = 1;
525 525
526 /* If F needs to be redrawn, simply forget about any prior mouse 526 /* If F needs to be redrawn, simply forget about any prior mouse
527 highlighting. */ 527 highlighting. */
528 if (FRAME_GARBAGED_P (f)) 528 if (FRAME_GARBAGED_P (f))
529 display_info->mouse_face_window = Qnil; 529 hlinfo->mouse_face_window = Qnil;
530 530
531#if 0 /* Rows in a current matrix containing glyphs in mouse-face have 531#if 0 /* Rows in a current matrix containing glyphs in mouse-face have
532 their mouse_face_p flag set, which means that they are always 532 their mouse_face_p flag set, which means that they are always
@@ -540,8 +540,8 @@ x_update_window_begin (struct window *w)
540 Likewise, don't do anything if the frame is garbaged; 540 Likewise, don't do anything if the frame is garbaged;
541 in that case, the frame's current matrix that we would use 541 in that case, the frame's current matrix that we would use
542 is all wrong, and we will redisplay that line anyway. */ 542 is all wrong, and we will redisplay that line anyway. */
543 if (!NILP (display_info->mouse_face_window) 543 if (!NILP (hlinfo->mouse_face_window)
544 && w == XWINDOW (display_info->mouse_face_window)) 544 && w == XWINDOW (hlinfo->mouse_face_window))
545 { 545 {
546 int i; 546 int i;
547 547
@@ -550,7 +550,7 @@ x_update_window_begin (struct window *w)
550 break; 550 break;
551 551
552 if (i < w->desired_matrix->nrows) 552 if (i < w->desired_matrix->nrows)
553 clear_mouse_face (display_info); 553 clear_mouse_face (hlinfo);
554 } 554 }
555#endif /* 0 */ 555#endif /* 0 */
556 } 556 }
@@ -601,7 +601,7 @@ static void
601x_update_window_end (struct window *w, int cursor_on_p, 601x_update_window_end (struct window *w, int cursor_on_p,
602 int mouse_face_overwritten_p) 602 int mouse_face_overwritten_p)
603{ 603{
604 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (XFRAME (w->frame)); 604 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
605 605
606 if (!w->pseudo_window_p) 606 if (!w->pseudo_window_p)
607 { 607 {
@@ -622,9 +622,9 @@ x_update_window_end (struct window *w, int cursor_on_p,
622 XTframe_up_to_date to redisplay the mouse highlight. */ 622 XTframe_up_to_date to redisplay the mouse highlight. */
623 if (mouse_face_overwritten_p) 623 if (mouse_face_overwritten_p)
624 { 624 {
625 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 625 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
626 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 626 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
627 dpyinfo->mouse_face_window = Qnil; 627 hlinfo->mouse_face_window = Qnil;
628 } 628 }
629 629
630 /* Unhide the caret. This won't actually show the cursor, unless it 630 /* Unhide the caret. This won't actually show the cursor, unless it
@@ -649,7 +649,7 @@ x_update_end (struct frame *f)
649 return; 649 return;
650 650
651 /* Mouse highlight may be displayed again. */ 651 /* Mouse highlight may be displayed again. */
652 FRAME_W32_DISPLAY_INFO (f)->mouse_face_defer = 0; 652 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
653} 653}
654 654
655 655
@@ -662,17 +662,17 @@ w32_frame_up_to_date (struct frame *f)
662{ 662{
663 if (FRAME_W32_P (f)) 663 if (FRAME_W32_P (f))
664 { 664 {
665 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 665 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
666 666
667 if (dpyinfo->mouse_face_deferred_gc 667 if (hlinfo->mouse_face_deferred_gc
668 || f == dpyinfo->mouse_face_mouse_frame) 668 || f == hlinfo->mouse_face_mouse_frame)
669 { 669 {
670 BLOCK_INPUT; 670 BLOCK_INPUT;
671 if (dpyinfo->mouse_face_mouse_frame) 671 if (hlinfo->mouse_face_mouse_frame)
672 note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, 672 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
673 dpyinfo->mouse_face_mouse_x, 673 hlinfo->mouse_face_mouse_x,
674 dpyinfo->mouse_face_mouse_y); 674 hlinfo->mouse_face_mouse_y);
675 dpyinfo->mouse_face_deferred_gc = 0; 675 hlinfo->mouse_face_deferred_gc = 0;
676 UNBLOCK_INPUT; 676 UNBLOCK_INPUT;
677 } 677 }
678 } 678 }
@@ -999,7 +999,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
999 struct face *face; 999 struct face *face;
1000 1000
1001 /* What face has to be used last for the mouse face? */ 1001 /* What face has to be used last for the mouse face? */
1002 face_id = FRAME_W32_DISPLAY_INFO (s->f)->mouse_face_face_id; 1002 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
1003 face = FACE_FROM_ID (s->f, face_id); 1003 face = FACE_FROM_ID (s->f, face_id);
1004 if (face == NULL) 1004 if (face == NULL)
1005 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 1005 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
@@ -4060,6 +4060,7 @@ w32_read_socket (struct terminal *terminal, int expected,
4060 W32Msg msg; 4060 W32Msg msg;
4061 struct frame *f; 4061 struct frame *f;
4062 struct w32_display_info *dpyinfo = &one_w32_display_info; 4062 struct w32_display_info *dpyinfo = &one_w32_display_info;
4063 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
4063 4064
4064 if (interrupt_input_blocked) 4065 if (interrupt_input_blocked)
4065 { 4066 {
@@ -4160,11 +4161,11 @@ w32_read_socket (struct terminal *terminal, int expected,
4160 4161
4161 if (f && !f->iconified) 4162 if (f && !f->iconified)
4162 { 4163 {
4163 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 4164 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
4164 && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window)) 4165 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
4165 { 4166 {
4166 clear_mouse_face (dpyinfo); 4167 clear_mouse_face (hlinfo);
4167 dpyinfo->mouse_face_hidden = 1; 4168 hlinfo->mouse_face_hidden = 1;
4168 } 4169 }
4169 4170
4170 if (temp_index == sizeof temp_buffer / sizeof (short)) 4171 if (temp_index == sizeof temp_buffer / sizeof (short))
@@ -4185,11 +4186,11 @@ w32_read_socket (struct terminal *terminal, int expected,
4185 4186
4186 if (f && !f->iconified) 4187 if (f && !f->iconified)
4187 { 4188 {
4188 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 4189 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
4189 && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window)) 4190 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
4190 { 4191 {
4191 clear_mouse_face (dpyinfo); 4192 clear_mouse_face (hlinfo);
4192 dpyinfo->mouse_face_hidden = 1; 4193 hlinfo->mouse_face_hidden = 1;
4193 } 4194 }
4194 4195
4195 if (temp_index == sizeof temp_buffer / sizeof (short)) 4196 if (temp_index == sizeof temp_buffer / sizeof (short))
@@ -4263,11 +4264,11 @@ w32_read_socket (struct terminal *terminal, int expected,
4263 4264
4264 if (f && !f->iconified) 4265 if (f && !f->iconified)
4265 { 4266 {
4266 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 4267 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
4267 && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window)) 4268 && !EQ (f->tool_bar_window, hlinfo->mouse_face_window))
4268 { 4269 {
4269 clear_mouse_face (dpyinfo); 4270 clear_mouse_face (hlinfo);
4270 dpyinfo->mouse_face_hidden = 1; 4271 hlinfo->mouse_face_hidden = 1;
4271 } 4272 }
4272 4273
4273 if (temp_index == sizeof temp_buffer / sizeof (short)) 4274 if (temp_index == sizeof temp_buffer / sizeof (short))
@@ -4301,10 +4302,10 @@ w32_read_socket (struct terminal *terminal, int expected,
4301 else 4302 else
4302 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4303 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4303 4304
4304 if (dpyinfo->mouse_face_hidden) 4305 if (hlinfo->mouse_face_hidden)
4305 { 4306 {
4306 dpyinfo->mouse_face_hidden = 0; 4307 hlinfo->mouse_face_hidden = 0;
4307 clear_mouse_face (dpyinfo); 4308 clear_mouse_face (hlinfo);
4308 } 4309 }
4309 4310
4310 if (f) 4311 if (f)
@@ -4345,7 +4346,7 @@ w32_read_socket (struct terminal *terminal, int expected,
4345 { 4346 {
4346 /* If we move outside the frame, then we're 4347 /* If we move outside the frame, then we're
4347 certainly no longer on any text in the frame. */ 4348 certainly no longer on any text in the frame. */
4348 clear_mouse_face (dpyinfo); 4349 clear_mouse_face (hlinfo);
4349 } 4350 }
4350 4351
4351 /* If the contents of the global variable help_echo_string 4352 /* If the contents of the global variable help_echo_string
@@ -4634,12 +4635,12 @@ w32_read_socket (struct terminal *terminal, int expected,
4634 f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd); 4635 f = x_any_window_to_frame (dpyinfo, msg.msg.hwnd);
4635 if (f) 4636 if (f)
4636 { 4637 {
4637 if (f == dpyinfo->mouse_face_mouse_frame) 4638 if (f == hlinfo->mouse_face_mouse_frame)
4638 { 4639 {
4639 /* If we move outside the frame, then we're 4640 /* If we move outside the frame, then we're
4640 certainly no longer on any text in the frame. */ 4641 certainly no longer on any text in the frame. */
4641 clear_mouse_face (dpyinfo); 4642 clear_mouse_face (hlinfo);
4642 dpyinfo->mouse_face_mouse_frame = 0; 4643 hlinfo->mouse_face_mouse_frame = 0;
4643 } 4644 }
4644 4645
4645 /* Generate a nil HELP_EVENT to cancel a help-echo. 4646 /* Generate a nil HELP_EVENT to cancel a help-echo.
@@ -4669,12 +4670,12 @@ w32_read_socket (struct terminal *terminal, int expected,
4669 if (f == dpyinfo->w32_focus_frame) 4670 if (f == dpyinfo->w32_focus_frame)
4670 x_new_focus_frame (dpyinfo, 0); 4671 x_new_focus_frame (dpyinfo, 0);
4671 4672
4672 if (f == dpyinfo->mouse_face_mouse_frame) 4673 if (f == hlinfo->mouse_face_mouse_frame)
4673 { 4674 {
4674 /* If we move outside the frame, then we're 4675 /* If we move outside the frame, then we're
4675 certainly no longer on any text in the frame. */ 4676 certainly no longer on any text in the frame. */
4676 clear_mouse_face (dpyinfo); 4677 clear_mouse_face (hlinfo);
4677 dpyinfo->mouse_face_mouse_frame = 0; 4678 hlinfo->mouse_face_mouse_frame = 0;
4678 } 4679 }
4679 4680
4680 /* Generate a nil HELP_EVENT to cancel a help-echo. 4681 /* Generate a nil HELP_EVENT to cancel a help-echo.
@@ -5822,6 +5823,7 @@ void
5822x_free_frame_resources (struct frame *f) 5823x_free_frame_resources (struct frame *f)
5823{ 5824{
5824 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f); 5825 struct w32_display_info *dpyinfo = FRAME_W32_DISPLAY_INFO (f);
5826 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
5825 5827
5826 BLOCK_INPUT; 5828 BLOCK_INPUT;
5827 5829
@@ -5860,15 +5862,15 @@ x_free_frame_resources (struct frame *f)
5860 if (f == dpyinfo->x_highlight_frame) 5862 if (f == dpyinfo->x_highlight_frame)
5861 dpyinfo->x_highlight_frame = 0; 5863 dpyinfo->x_highlight_frame = 0;
5862 5864
5863 if (f == dpyinfo->mouse_face_mouse_frame) 5865 if (f == hlinfo->mouse_face_mouse_frame)
5864 { 5866 {
5865 dpyinfo->mouse_face_beg_row 5867 hlinfo->mouse_face_beg_row
5866 = dpyinfo->mouse_face_beg_col = -1; 5868 = hlinfo->mouse_face_beg_col = -1;
5867 dpyinfo->mouse_face_end_row 5869 hlinfo->mouse_face_end_row
5868 = dpyinfo->mouse_face_end_col = -1; 5870 = hlinfo->mouse_face_end_col = -1;
5869 dpyinfo->mouse_face_window = Qnil; 5871 hlinfo->mouse_face_window = Qnil;
5870 dpyinfo->mouse_face_deferred_gc = 0; 5872 hlinfo->mouse_face_deferred_gc = 0;
5871 dpyinfo->mouse_face_mouse_frame = 0; 5873 hlinfo->mouse_face_mouse_frame = 0;
5872 } 5874 }
5873 5875
5874 UNBLOCK_INPUT; 5876 UNBLOCK_INPUT;
@@ -5934,6 +5936,7 @@ void
5934w32_initialize_display_info (Lisp_Object display_name) 5936w32_initialize_display_info (Lisp_Object display_name)
5935{ 5937{
5936 struct w32_display_info *dpyinfo = &one_w32_display_info; 5938 struct w32_display_info *dpyinfo = &one_w32_display_info;
5939 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
5937 5940
5938 memset (dpyinfo, 0, sizeof (*dpyinfo)); 5941 memset (dpyinfo, 0, sizeof (*dpyinfo));
5939 5942
@@ -5959,12 +5962,12 @@ w32_initialize_display_info (Lisp_Object display_name)
5959 dpyinfo->smallest_font_height = 1; 5962 dpyinfo->smallest_font_height = 1;
5960 dpyinfo->smallest_char_width = 1; 5963 dpyinfo->smallest_char_width = 1;
5961 5964
5962 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 5965 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
5963 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 5966 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
5964 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; 5967 hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
5965 dpyinfo->mouse_face_window = Qnil; 5968 hlinfo->mouse_face_window = Qnil;
5966 dpyinfo->mouse_face_overlay = Qnil; 5969 hlinfo->mouse_face_overlay = Qnil;
5967 dpyinfo->mouse_face_hidden = 0; 5970 hlinfo->mouse_face_hidden = 0;
5968 5971
5969 dpyinfo->vertical_scroll_bar_cursor = w32_load_cursor (IDC_ARROW); 5972 dpyinfo->vertical_scroll_bar_cursor = w32_load_cursor (IDC_ARROW);
5970 /* TODO: dpyinfo->gray */ 5973 /* TODO: dpyinfo->gray */
diff --git a/src/w32term.h b/src/w32term.h
index ea245144ac3..bd535cae57a 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -143,36 +143,9 @@ struct w32_display_info
143 /* Reusable Graphics Context for drawing a cursor in a non-default face. */ 143 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
144 XGCValues *scratch_cursor_gc; 144 XGCValues *scratch_cursor_gc;
145 145
146 /* These variables describe the range of text currently shown in its 146 /* Information about the range of text currently shown in
147 mouse-face, together with the window they apply to. As long as 147 mouse-face. */
148 the mouse stays within this range, we need not redraw anything on 148 Mouse_HLInfo mouse_highlight;
149 its account. Rows and columns are glyph matrix positions in
150 MOUSE_FACE_WINDOW. */
151 int mouse_face_beg_row, mouse_face_beg_col;
152 int mouse_face_beg_x, mouse_face_beg_y;
153 int mouse_face_end_row, mouse_face_end_col;
154 int mouse_face_end_x, mouse_face_end_y;
155 int mouse_face_past_end;
156 Lisp_Object mouse_face_window;
157 int mouse_face_face_id;
158 Lisp_Object mouse_face_overlay;
159
160 /* 1 if a mouse motion event came and we didn't handle it right away because
161 gc was in progress. */
162 int mouse_face_deferred_gc;
163
164 /* FRAME and X, Y position of mouse when last checked for
165 highlighting. X and Y can be negative or out of range for the frame. */
166 struct frame *mouse_face_mouse_frame;
167 int mouse_face_mouse_x, mouse_face_mouse_y;
168
169 /* Nonzero means defer mouse-motion highlighting. */
170 int mouse_face_defer;
171
172 /* Nonzero means that the mouse highlight should not be shown. */
173 int mouse_face_hidden;
174
175 int mouse_face_image_state;
176 149
177 char *w32_id_name; 150 char *w32_id_name;
178 151
diff --git a/src/xdisp.c b/src/xdisp.c
index ad90d57865b..0fb480980cb 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -888,6 +888,9 @@ static int clear_face_cache_count;
888#ifdef HAVE_WINDOW_SYSTEM 888#ifdef HAVE_WINDOW_SYSTEM
889#define CLEAR_IMAGE_CACHE_COUNT 101 889#define CLEAR_IMAGE_CACHE_COUNT 101
890static int clear_image_cache_count; 890static int clear_image_cache_count;
891
892/* Null glyph slice */
893static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
891#endif 894#endif
892 895
893/* Non-zero while redisplay_internal is in progress. */ 896/* Non-zero while redisplay_internal is in progress. */
@@ -913,10 +916,6 @@ EMACS_INT help_echo_pos;
913 916
914Lisp_Object previous_help_echo_string; 917Lisp_Object previous_help_echo_string;
915 918
916/* Null glyph slice */
917
918static struct glyph_slice null_glyph_slice = { 0, 0, 0, 0 };
919
920/* Platform-independent portion of hourglass implementation. */ 919/* Platform-independent portion of hourglass implementation. */
921 920
922/* Non-zero means we're allowed to display a hourglass pointer. */ 921/* Non-zero means we're allowed to display a hourglass pointer. */
@@ -975,10 +974,8 @@ static int text_outside_line_unchanged_p (struct window *,
975 EMACS_INT, EMACS_INT); 974 EMACS_INT, EMACS_INT);
976static void store_mode_line_noprop_char (char); 975static void store_mode_line_noprop_char (char);
977static int store_mode_line_noprop (const unsigned char *, int, int); 976static int store_mode_line_noprop (const unsigned char *, int, int);
978static void x_consider_frame_title (Lisp_Object);
979static void handle_stop (struct it *); 977static void handle_stop (struct it *);
980static void handle_stop_backwards (struct it *, EMACS_INT); 978static void handle_stop_backwards (struct it *, EMACS_INT);
981static int tool_bar_lines_needed (struct frame *, int *);
982static int single_display_spec_intangible_p (Lisp_Object); 979static int single_display_spec_intangible_p (Lisp_Object);
983static void ensure_echo_area_buffers (void); 980static void ensure_echo_area_buffers (void);
984static Lisp_Object unwind_with_echo_area_buffer (Lisp_Object); 981static Lisp_Object unwind_with_echo_area_buffer (Lisp_Object);
@@ -1091,6 +1088,8 @@ static int in_ellipses_for_invisible_text_p (struct display_pos *,
1091 1088
1092#ifdef HAVE_WINDOW_SYSTEM 1089#ifdef HAVE_WINDOW_SYSTEM
1093 1090
1091static void x_consider_frame_title (Lisp_Object);
1092static int tool_bar_lines_needed (struct frame *, int *);
1094static void update_tool_bar (struct frame *, int); 1093static void update_tool_bar (struct frame *, int);
1095static void build_desired_tool_bar_string (struct frame *f); 1094static void build_desired_tool_bar_string (struct frame *f);
1096static int redisplay_tool_bar (struct frame *); 1095static int redisplay_tool_bar (struct frame *);
@@ -1100,12 +1099,13 @@ static void notice_overwritten_cursor (struct window *,
1100 int, int, int, int); 1099 int, int, int, int);
1101static void append_stretch_glyph (struct it *, Lisp_Object, 1100static void append_stretch_glyph (struct it *, Lisp_Object,
1102 int, int, int); 1101 int, int, int);
1103static int coords_in_mouse_face_p (struct window *, int, int);
1104
1105 1102
1106 1103
1107#endif /* HAVE_WINDOW_SYSTEM */ 1104#endif /* HAVE_WINDOW_SYSTEM */
1108 1105
1106static int coords_in_mouse_face_p (struct window *, int, int);
1107
1108
1109 1109
1110/*********************************************************************** 1110/***********************************************************************
1111 Window display dimensions 1111 Window display dimensions
@@ -1797,8 +1797,6 @@ glyph_to_pixel_coords (struct window *w, int hpos, int vpos,
1797} 1797}
1798 1798
1799 1799
1800#ifdef HAVE_WINDOW_SYSTEM
1801
1802/* Find the glyph under window-relative coordinates X/Y in window W. 1800/* Find the glyph under window-relative coordinates X/Y in window W.
1803 Consider only glyphs from buffer text, i.e. no glyphs from overlay 1801 Consider only glyphs from buffer text, i.e. no glyphs from overlay
1804 strings. Return in *HPOS and *VPOS the row and column number of 1802 strings. Return in *HPOS and *VPOS the row and column number of
@@ -1881,7 +1879,6 @@ x_y_to_hpos_vpos (struct window *w, int x, int y, int *hpos, int *vpos,
1881 return glyph; 1879 return glyph;
1882} 1880}
1883 1881
1884
1885/* EXPORT: 1882/* EXPORT:
1886 Convert frame-relative x/y to coordinates relative to window W. 1883 Convert frame-relative x/y to coordinates relative to window W.
1887 Takes pseudo-windows into account. */ 1884 Takes pseudo-windows into account. */
@@ -1904,6 +1901,8 @@ frame_to_window_pixel_xy (struct window *w, int *x, int *y)
1904 } 1901 }
1905} 1902}
1906 1903
1904#ifdef HAVE_WINDOW_SYSTEM
1905
1907/* EXPORT: 1906/* EXPORT:
1908 Return in RECTS[] at most N clipping rectangles for glyph string S. 1907 Return in RECTS[] at most N clipping rectangles for glyph string S.
1909 Return the number of stored rectangles. */ 1908 Return the number of stored rectangles. */
@@ -10818,7 +10817,7 @@ static int
10818get_tool_bar_item (struct frame *f, int x, int y, struct glyph **glyph, 10817get_tool_bar_item (struct frame *f, int x, int y, struct glyph **glyph,
10819 int *hpos, int *vpos, int *prop_idx) 10818 int *hpos, int *vpos, int *prop_idx)
10820{ 10819{
10821 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 10820 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
10822 struct window *w = XWINDOW (f->tool_bar_window); 10821 struct window *w = XWINDOW (f->tool_bar_window);
10823 int area; 10822 int area;
10824 10823
@@ -10833,14 +10832,14 @@ get_tool_bar_item (struct frame *f, int x, int y, struct glyph **glyph,
10833 return -1; 10832 return -1;
10834 10833
10835 /* Is mouse on the highlighted item? */ 10834 /* Is mouse on the highlighted item? */
10836 if (EQ (f->tool_bar_window, dpyinfo->mouse_face_window) 10835 if (EQ (f->tool_bar_window, hlinfo->mouse_face_window)
10837 && *vpos >= dpyinfo->mouse_face_beg_row 10836 && *vpos >= hlinfo->mouse_face_beg_row
10838 && *vpos <= dpyinfo->mouse_face_end_row 10837 && *vpos <= hlinfo->mouse_face_end_row
10839 && (*vpos > dpyinfo->mouse_face_beg_row 10838 && (*vpos > hlinfo->mouse_face_beg_row
10840 || *hpos >= dpyinfo->mouse_face_beg_col) 10839 || *hpos >= hlinfo->mouse_face_beg_col)
10841 && (*vpos < dpyinfo->mouse_face_end_row 10840 && (*vpos < hlinfo->mouse_face_end_row
10842 || *hpos < dpyinfo->mouse_face_end_col 10841 || *hpos < hlinfo->mouse_face_end_col
10843 || dpyinfo->mouse_face_past_end)) 10842 || hlinfo->mouse_face_past_end))
10844 return 0; 10843 return 0;
10845 10844
10846 return 1; 10845 return 1;
@@ -10857,7 +10856,7 @@ void
10857handle_tool_bar_click (struct frame *f, int x, int y, int down_p, 10856handle_tool_bar_click (struct frame *f, int x, int y, int down_p,
10858 unsigned int modifiers) 10857 unsigned int modifiers)
10859{ 10858{
10860 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 10859 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
10861 struct window *w = XWINDOW (f->tool_bar_window); 10860 struct window *w = XWINDOW (f->tool_bar_window);
10862 int hpos, vpos, prop_idx; 10861 int hpos, vpos, prop_idx;
10863 struct glyph *glyph; 10862 struct glyph *glyph;
@@ -10876,8 +10875,8 @@ handle_tool_bar_click (struct frame *f, int x, int y, int down_p,
10876 if (down_p) 10875 if (down_p)
10877 { 10876 {
10878 /* Show item in pressed state. */ 10877 /* Show item in pressed state. */
10879 show_mouse_face (dpyinfo, DRAW_IMAGE_SUNKEN); 10878 show_mouse_face (hlinfo, DRAW_IMAGE_SUNKEN);
10880 dpyinfo->mouse_face_image_state = DRAW_IMAGE_SUNKEN; 10879 hlinfo->mouse_face_image_state = DRAW_IMAGE_SUNKEN;
10881 last_tool_bar_item = prop_idx; 10880 last_tool_bar_item = prop_idx;
10882 } 10881 }
10883 else 10882 else
@@ -10887,8 +10886,8 @@ handle_tool_bar_click (struct frame *f, int x, int y, int down_p,
10887 EVENT_INIT (event); 10886 EVENT_INIT (event);
10888 10887
10889 /* Show item in released state. */ 10888 /* Show item in released state. */
10890 show_mouse_face (dpyinfo, DRAW_IMAGE_RAISED); 10889 show_mouse_face (hlinfo, DRAW_IMAGE_RAISED);
10891 dpyinfo->mouse_face_image_state = DRAW_IMAGE_RAISED; 10890 hlinfo->mouse_face_image_state = DRAW_IMAGE_RAISED;
10892 10891
10893 key = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_KEY); 10892 key = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_KEY);
10894 10893
@@ -10918,6 +10917,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
10918 Lisp_Object window = f->tool_bar_window; 10917 Lisp_Object window = f->tool_bar_window;
10919 struct window *w = XWINDOW (window); 10918 struct window *w = XWINDOW (window);
10920 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 10919 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
10920 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
10921 int hpos, vpos; 10921 int hpos, vpos;
10922 struct glyph *glyph; 10922 struct glyph *glyph;
10923 struct glyph_row *row; 10923 struct glyph_row *row;
@@ -10931,7 +10931,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
10931 values when mouse moves outside of the frame. */ 10931 values when mouse moves outside of the frame. */
10932 if (x <= 0 || y <= 0) 10932 if (x <= 0 || y <= 0)
10933 { 10933 {
10934 clear_mouse_face (dpyinfo); 10934 clear_mouse_face (hlinfo);
10935 return; 10935 return;
10936 } 10936 }
10937 10937
@@ -10939,14 +10939,14 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
10939 if (rc < 0) 10939 if (rc < 0)
10940 { 10940 {
10941 /* Not on tool-bar item. */ 10941 /* Not on tool-bar item. */
10942 clear_mouse_face (dpyinfo); 10942 clear_mouse_face (hlinfo);
10943 return; 10943 return;
10944 } 10944 }
10945 else if (rc == 0) 10945 else if (rc == 0)
10946 /* On same tool-bar item as before. */ 10946 /* On same tool-bar item as before. */
10947 goto set_help_echo; 10947 goto set_help_echo;
10948 10948
10949 clear_mouse_face (dpyinfo); 10949 clear_mouse_face (hlinfo);
10950 10950
10951 /* Mouse is down, but on different tool-bar item? */ 10951 /* Mouse is down, but on different tool-bar item? */
10952 mouse_down_p = (dpyinfo->grabbed 10952 mouse_down_p = (dpyinfo->grabbed
@@ -10956,7 +10956,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
10956 && last_tool_bar_item != prop_idx) 10956 && last_tool_bar_item != prop_idx)
10957 return; 10957 return;
10958 10958
10959 dpyinfo->mouse_face_image_state = DRAW_NORMAL_TEXT; 10959 hlinfo->mouse_face_image_state = DRAW_NORMAL_TEXT;
10960 draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED; 10960 draw = mouse_down_p ? DRAW_IMAGE_SUNKEN : DRAW_IMAGE_RAISED;
10961 10961
10962 /* If tool-bar item is not enabled, don't highlight it. */ 10962 /* If tool-bar item is not enabled, don't highlight it. */
@@ -10970,22 +10970,22 @@ note_tool_bar_highlight (struct frame *f, int x, int y)
10970 x += row->glyphs[TEXT_AREA][i].pixel_width; 10970 x += row->glyphs[TEXT_AREA][i].pixel_width;
10971 10971
10972 /* Record this as the current active region. */ 10972 /* Record this as the current active region. */
10973 dpyinfo->mouse_face_beg_col = hpos; 10973 hlinfo->mouse_face_beg_col = hpos;
10974 dpyinfo->mouse_face_beg_row = vpos; 10974 hlinfo->mouse_face_beg_row = vpos;
10975 dpyinfo->mouse_face_beg_x = x; 10975 hlinfo->mouse_face_beg_x = x;
10976 dpyinfo->mouse_face_beg_y = row->y; 10976 hlinfo->mouse_face_beg_y = row->y;
10977 dpyinfo->mouse_face_past_end = 0; 10977 hlinfo->mouse_face_past_end = 0;
10978 10978
10979 dpyinfo->mouse_face_end_col = hpos + 1; 10979 hlinfo->mouse_face_end_col = hpos + 1;
10980 dpyinfo->mouse_face_end_row = vpos; 10980 hlinfo->mouse_face_end_row = vpos;
10981 dpyinfo->mouse_face_end_x = x + glyph->pixel_width; 10981 hlinfo->mouse_face_end_x = x + glyph->pixel_width;
10982 dpyinfo->mouse_face_end_y = row->y; 10982 hlinfo->mouse_face_end_y = row->y;
10983 dpyinfo->mouse_face_window = window; 10983 hlinfo->mouse_face_window = window;
10984 dpyinfo->mouse_face_face_id = TOOL_BAR_FACE_ID; 10984 hlinfo->mouse_face_face_id = TOOL_BAR_FACE_ID;
10985 10985
10986 /* Display it as active. */ 10986 /* Display it as active. */
10987 show_mouse_face (dpyinfo, draw); 10987 show_mouse_face (hlinfo, draw);
10988 dpyinfo->mouse_face_image_state = draw; 10988 hlinfo->mouse_face_image_state = draw;
10989 } 10989 }
10990 10990
10991 set_help_echo: 10991 set_help_echo:
@@ -15985,6 +15985,9 @@ try_window_id (struct window *w)
15985 + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0) 15985 + (WINDOW_WANTS_HEADER_LINE_P (w) ? 1 : 0)
15986 + window_internal_height (w)); 15986 + window_internal_height (w));
15987 15987
15988#if defined (HAVE_GPM) || defined (MSDOS)
15989 x_clear_window_mouse_face (w);
15990#endif
15988 /* Perform the operation on the screen. */ 15991 /* Perform the operation on the screen. */
15989 if (dvpos > 0) 15992 if (dvpos > 0)
15990 { 15993 {
@@ -21442,7 +21445,7 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
21442 if (head && !overlaps && row->contains_overlapping_glyphs_p) 21445 if (head && !overlaps && row->contains_overlapping_glyphs_p)
21443 { 21446 {
21444 struct glyph_string *h, *t; 21447 struct glyph_string *h, *t;
21445 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 21448 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
21446 int mouse_beg_col, mouse_end_col, check_mouse_face = 0; 21449 int mouse_beg_col, mouse_end_col, check_mouse_face = 0;
21447 int dummy_x = 0; 21450 int dummy_x = 0;
21448 21451
@@ -21452,16 +21455,16 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
21452 { 21455 {
21453 struct glyph_row *mouse_beg_row, *mouse_end_row; 21456 struct glyph_row *mouse_beg_row, *mouse_end_row;
21454 21457
21455 mouse_beg_row = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row); 21458 mouse_beg_row = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_beg_row);
21456 mouse_end_row = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row); 21459 mouse_end_row = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_end_row);
21457 21460
21458 if (row >= mouse_beg_row && row <= mouse_end_row) 21461 if (row >= mouse_beg_row && row <= mouse_end_row)
21459 { 21462 {
21460 check_mouse_face = 1; 21463 check_mouse_face = 1;
21461 mouse_beg_col = (row == mouse_beg_row) 21464 mouse_beg_col = (row == mouse_beg_row)
21462 ? dpyinfo->mouse_face_beg_col : 0; 21465 ? hlinfo->mouse_face_beg_col : 0;
21463 mouse_end_col = (row == mouse_end_row) 21466 mouse_end_col = (row == mouse_end_row)
21464 ? dpyinfo->mouse_face_end_col 21467 ? hlinfo->mouse_face_end_col
21465 : row->used[TEXT_AREA]; 21468 : row->used[TEXT_AREA];
21466 } 21469 }
21467 } 21470 }
@@ -23400,6 +23403,8 @@ set_frame_cursor_types (struct frame *f, Lisp_Object arg)
23400} 23403}
23401 23404
23402 23405
23406#ifdef HAVE_WINDOW_SYSTEM
23407
23403/* Return the cursor we want to be displayed in window W. Return 23408/* Return the cursor we want to be displayed in window W. Return
23404 width of bar/hbar cursor through WIDTH arg. Return with 23409 width of bar/hbar cursor through WIDTH arg. Return with
23405 ACTIVE_CURSOR arg set to 1 if cursor in window W is `active' 23410 ACTIVE_CURSOR arg set to 1 if cursor in window W is `active'
@@ -23445,10 +23450,7 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
23445 23450
23446 /* Detect a nonselected window or nonselected frame. */ 23451 /* Detect a nonselected window or nonselected frame. */
23447 else if (w != XWINDOW (f->selected_window) 23452 else if (w != XWINDOW (f->selected_window)
23448#ifdef HAVE_WINDOW_SYSTEM 23453 || f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame)
23449 || f != FRAME_X_DISPLAY_INFO (f)->x_highlight_frame
23450#endif
23451 )
23452 { 23454 {
23453 *active_cursor = 0; 23455 *active_cursor = 0;
23454 23456
@@ -23489,7 +23491,6 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
23489 /* Use normal cursor if not blinked off. */ 23491 /* Use normal cursor if not blinked off. */
23490 if (!w->cursor_off_p) 23492 if (!w->cursor_off_p)
23491 { 23493 {
23492#ifdef HAVE_WINDOW_SYSTEM
23493 if (glyph != NULL && glyph->type == IMAGE_GLYPH) 23494 if (glyph != NULL && glyph->type == IMAGE_GLYPH)
23494 { 23495 {
23495 if (cursor_type == FILLED_BOX_CURSOR) 23496 if (cursor_type == FILLED_BOX_CURSOR)
@@ -23517,7 +23518,6 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
23517 cursor_type = HOLLOW_BOX_CURSOR; 23518 cursor_type = HOLLOW_BOX_CURSOR;
23518 } 23519 }
23519 } 23520 }
23520#endif
23521 return cursor_type; 23521 return cursor_type;
23522 } 23522 }
23523 23523
@@ -23559,8 +23559,6 @@ get_window_cursor_type (struct window *w, struct glyph *glyph, int *width,
23559} 23559}
23560 23560
23561 23561
23562#ifdef HAVE_WINDOW_SYSTEM
23563
23564/* Notice when the text cursor of window W has been completely 23562/* Notice when the text cursor of window W has been completely
23565 overwritten by a drawing operation that outputs glyphs in AREA 23563 overwritten by a drawing operation that outputs glyphs in AREA
23566 starting at X0 and ending at X1 in the line starting at Y0 and 23564 starting at X0 and ending at X1 in the line starting at Y0 and
@@ -23726,7 +23724,7 @@ void
23726erase_phys_cursor (struct window *w) 23724erase_phys_cursor (struct window *w)
23727{ 23725{
23728 struct frame *f = XFRAME (w->frame); 23726 struct frame *f = XFRAME (w->frame);
23729 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 23727 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
23730 int hpos = w->phys_cursor.hpos; 23728 int hpos = w->phys_cursor.hpos;
23731 int vpos = w->phys_cursor.vpos; 23729 int vpos = w->phys_cursor.vpos;
23732 int mouse_face_here_p = 0; 23730 int mouse_face_here_p = 0;
@@ -23782,7 +23780,7 @@ erase_phys_cursor (struct window *w)
23782 23780
23783 /* If the cursor is in the mouse face area, redisplay that when 23781 /* If the cursor is in the mouse face area, redisplay that when
23784 we clear the cursor. */ 23782 we clear the cursor. */
23785 if (! NILP (dpyinfo->mouse_face_window) 23783 if (! NILP (hlinfo->mouse_face_window)
23786 && coords_in_mouse_face_p (w, hpos, vpos) 23784 && coords_in_mouse_face_p (w, hpos, vpos)
23787 /* Don't redraw the cursor's spot in mouse face if it is at the 23785 /* Don't redraw the cursor's spot in mouse face if it is at the
23788 end of a line (on a newline). The cursor appears there, but 23786 end of a line (on a newline). The cursor appears there, but
@@ -23974,30 +23972,50 @@ x_clear_cursor (struct window *w)
23974 update_window_cursor (w, 0); 23972 update_window_cursor (w, 0);
23975} 23973}
23976 23974
23975#endif /* HAVE_WINDOW_SYSTEM */
23976
23977/* Implementation of draw_row_with_mouse_face for GUI sessions, GPM,
23978 and MSDOS. */
23979void
23980draw_row_with_mouse_face (struct window *w, int start_x, struct glyph_row *row,
23981 int start_hpos, int end_hpos,
23982 enum draw_glyphs_face draw)
23983{
23984#ifdef HAVE_WINDOW_SYSTEM
23985 if (FRAME_WINDOW_P (XFRAME (w->frame)))
23986 {
23987 draw_glyphs (w, start_x, row, TEXT_AREA, start_hpos, end_hpos, draw, 0);
23988 return;
23989 }
23990#endif
23991#if defined (HAVE_GPM) || defined (MSDOS)
23992 tty_draw_row_with_mouse_face (w, row, start_hpos, end_hpos, draw);
23993#endif
23994}
23977 23995
23978/* EXPORT: 23996/* EXPORT:
23979 Display the active region described by mouse_face_* according to DRAW. */ 23997 Display the active region described by mouse_face_* according to DRAW. */
23980 23998
23981void 23999void
23982show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw) 24000show_mouse_face (Mouse_HLInfo *hlinfo, enum draw_glyphs_face draw)
23983{ 24001{
23984 struct window *w = XWINDOW (dpyinfo->mouse_face_window); 24002 struct window *w = XWINDOW (hlinfo->mouse_face_window);
23985 struct frame *f = XFRAME (WINDOW_FRAME (w)); 24003 struct frame *f = XFRAME (WINDOW_FRAME (w));
23986 24004
23987 if (/* If window is in the process of being destroyed, don't bother 24005 if (/* If window is in the process of being destroyed, don't bother
23988 to do anything. */ 24006 to do anything. */
23989 w->current_matrix != NULL 24007 w->current_matrix != NULL
23990 /* Don't update mouse highlight if hidden */ 24008 /* Don't update mouse highlight if hidden */
23991 && (draw != DRAW_MOUSE_FACE || !dpyinfo->mouse_face_hidden) 24009 && (draw != DRAW_MOUSE_FACE || !hlinfo->mouse_face_hidden)
23992 /* Recognize when we are called to operate on rows that don't exist 24010 /* Recognize when we are called to operate on rows that don't exist
23993 anymore. This can happen when a window is split. */ 24011 anymore. This can happen when a window is split. */
23994 && dpyinfo->mouse_face_end_row < w->current_matrix->nrows) 24012 && hlinfo->mouse_face_end_row < w->current_matrix->nrows)
23995 { 24013 {
23996 int phys_cursor_on_p = w->phys_cursor_on_p; 24014 int phys_cursor_on_p = w->phys_cursor_on_p;
23997 struct glyph_row *row, *first, *last; 24015 struct glyph_row *row, *first, *last;
23998 24016
23999 first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row); 24017 first = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_beg_row);
24000 last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row); 24018 last = MATRIX_ROW (w->current_matrix, hlinfo->mouse_face_end_row);
24001 24019
24002 for (row = first; row <= last && row->enabled_p; ++row) 24020 for (row = first; row <= last && row->enabled_p; ++row)
24003 { 24021 {
@@ -24012,13 +24030,13 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24012 highlighted area in R2L rows. */ 24030 highlighted area in R2L rows. */
24013 if (!row->reversed_p) 24031 if (!row->reversed_p)
24014 { 24032 {
24015 start_hpos = dpyinfo->mouse_face_beg_col; 24033 start_hpos = hlinfo->mouse_face_beg_col;
24016 start_x = dpyinfo->mouse_face_beg_x; 24034 start_x = hlinfo->mouse_face_beg_x;
24017 } 24035 }
24018 else if (row == last) 24036 else if (row == last)
24019 { 24037 {
24020 start_hpos = dpyinfo->mouse_face_end_col; 24038 start_hpos = hlinfo->mouse_face_end_col;
24021 start_x = dpyinfo->mouse_face_end_x; 24039 start_x = hlinfo->mouse_face_end_x;
24022 } 24040 }
24023 else 24041 else
24024 { 24042 {
@@ -24028,8 +24046,8 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24028 } 24046 }
24029 else if (row->reversed_p && row == last) 24047 else if (row->reversed_p && row == last)
24030 { 24048 {
24031 start_hpos = dpyinfo->mouse_face_end_col; 24049 start_hpos = hlinfo->mouse_face_end_col;
24032 start_x = dpyinfo->mouse_face_end_x; 24050 start_x = hlinfo->mouse_face_end_x;
24033 } 24051 }
24034 else 24052 else
24035 { 24053 {
@@ -24040,9 +24058,9 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24040 if (row == last) 24058 if (row == last)
24041 { 24059 {
24042 if (!row->reversed_p) 24060 if (!row->reversed_p)
24043 end_hpos = dpyinfo->mouse_face_end_col; 24061 end_hpos = hlinfo->mouse_face_end_col;
24044 else if (row == first) 24062 else if (row == first)
24045 end_hpos = dpyinfo->mouse_face_beg_col; 24063 end_hpos = hlinfo->mouse_face_beg_col;
24046 else 24064 else
24047 { 24065 {
24048 end_hpos = row->used[TEXT_AREA]; 24066 end_hpos = row->used[TEXT_AREA];
@@ -24051,7 +24069,7 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24051 } 24069 }
24052 } 24070 }
24053 else if (row->reversed_p && row == first) 24071 else if (row->reversed_p && row == first)
24054 end_hpos = dpyinfo->mouse_face_beg_col; 24072 end_hpos = hlinfo->mouse_face_beg_col;
24055 else 24073 else
24056 { 24074 {
24057 end_hpos = row->used[TEXT_AREA]; 24075 end_hpos = row->used[TEXT_AREA];
@@ -24061,18 +24079,19 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24061 24079
24062 if (end_hpos > start_hpos) 24080 if (end_hpos > start_hpos)
24063 { 24081 {
24064 draw_glyphs (w, start_x, row, TEXT_AREA, 24082 draw_row_with_mouse_face (w, start_x, row,
24065 start_hpos, end_hpos, 24083 start_hpos, end_hpos, draw);
24066 draw, 0);
24067 24084
24068 row->mouse_face_p 24085 row->mouse_face_p
24069 = draw == DRAW_MOUSE_FACE || draw == DRAW_IMAGE_RAISED; 24086 = draw == DRAW_MOUSE_FACE || draw == DRAW_IMAGE_RAISED;
24070 } 24087 }
24071 } 24088 }
24072 24089
24090#ifdef HAVE_WINDOW_SYSTEM
24073 /* When we've written over the cursor, arrange for it to 24091 /* When we've written over the cursor, arrange for it to
24074 be displayed again. */ 24092 be displayed again. */
24075 if (phys_cursor_on_p && !w->phys_cursor_on_p) 24093 if (FRAME_WINDOW_P (f)
24094 && phys_cursor_on_p && !w->phys_cursor_on_p)
24076 { 24095 {
24077 BLOCK_INPUT; 24096 BLOCK_INPUT;
24078 display_and_set_cursor (w, 1, 24097 display_and_set_cursor (w, 1,
@@ -24080,15 +24099,22 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24080 w->phys_cursor.x, w->phys_cursor.y); 24099 w->phys_cursor.x, w->phys_cursor.y);
24081 UNBLOCK_INPUT; 24100 UNBLOCK_INPUT;
24082 } 24101 }
24102#endif /* HAVE_WINDOW_SYSTEM */
24083 } 24103 }
24084 24104
24105#ifdef HAVE_WINDOW_SYSTEM
24085 /* Change the mouse cursor. */ 24106 /* Change the mouse cursor. */
24086 if (draw == DRAW_NORMAL_TEXT && !EQ (dpyinfo->mouse_face_window, f->tool_bar_window)) 24107 if (FRAME_WINDOW_P (f))
24087 FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor); 24108 {
24088 else if (draw == DRAW_MOUSE_FACE) 24109 if (draw == DRAW_NORMAL_TEXT
24089 FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor); 24110 && !EQ (hlinfo->mouse_face_window, f->tool_bar_window))
24090 else 24111 FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->text_cursor);
24091 FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor); 24112 else if (draw == DRAW_MOUSE_FACE)
24113 FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->hand_cursor);
24114 else
24115 FRAME_RIF (f)->define_frame_cursor (f, FRAME_X_OUTPUT (f)->nontext_cursor);
24116 }
24117#endif /* HAVE_WINDOW_SYSTEM */
24092} 24118}
24093 24119
24094/* EXPORT: 24120/* EXPORT:
@@ -24097,20 +24123,20 @@ show_mouse_face (Display_Info *dpyinfo, enum draw_glyphs_face draw)
24097 face was actually drawn unhighlighted. */ 24123 face was actually drawn unhighlighted. */
24098 24124
24099int 24125int
24100clear_mouse_face (Display_Info *dpyinfo) 24126clear_mouse_face (Mouse_HLInfo *hlinfo)
24101{ 24127{
24102 int cleared = 0; 24128 int cleared = 0;
24103 24129
24104 if (!dpyinfo->mouse_face_hidden && !NILP (dpyinfo->mouse_face_window)) 24130 if (!hlinfo->mouse_face_hidden && !NILP (hlinfo->mouse_face_window))
24105 { 24131 {
24106 show_mouse_face (dpyinfo, DRAW_NORMAL_TEXT); 24132 show_mouse_face (hlinfo, DRAW_NORMAL_TEXT);
24107 cleared = 1; 24133 cleared = 1;
24108 } 24134 }
24109 24135
24110 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 24136 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
24111 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 24137 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
24112 dpyinfo->mouse_face_window = Qnil; 24138 hlinfo->mouse_face_window = Qnil;
24113 dpyinfo->mouse_face_overlay = Qnil; 24139 hlinfo->mouse_face_overlay = Qnil;
24114 return cleared; 24140 return cleared;
24115} 24141}
24116 24142
@@ -24119,43 +24145,43 @@ clear_mouse_face (Display_Info *dpyinfo)
24119static int 24145static int
24120coords_in_mouse_face_p (struct window *w, int hpos, int vpos) 24146coords_in_mouse_face_p (struct window *w, int hpos, int vpos)
24121{ 24147{
24122 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); 24148 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
24123 24149
24124 /* Quickly resolve the easy cases. */ 24150 /* Quickly resolve the easy cases. */
24125 if (!(WINDOWP (dpyinfo->mouse_face_window) 24151 if (!(WINDOWP (hlinfo->mouse_face_window)
24126 && XWINDOW (dpyinfo->mouse_face_window) == w)) 24152 && XWINDOW (hlinfo->mouse_face_window) == w))
24127 return 0; 24153 return 0;
24128 if (vpos < dpyinfo->mouse_face_beg_row 24154 if (vpos < hlinfo->mouse_face_beg_row
24129 || vpos > dpyinfo->mouse_face_end_row) 24155 || vpos > hlinfo->mouse_face_end_row)
24130 return 0; 24156 return 0;
24131 if (vpos > dpyinfo->mouse_face_beg_row 24157 if (vpos > hlinfo->mouse_face_beg_row
24132 && vpos < dpyinfo->mouse_face_end_row) 24158 && vpos < hlinfo->mouse_face_end_row)
24133 return 1; 24159 return 1;
24134 24160
24135 if (!MATRIX_ROW (w->current_matrix, vpos)->reversed_p) 24161 if (!MATRIX_ROW (w->current_matrix, vpos)->reversed_p)
24136 { 24162 {
24137 if (dpyinfo->mouse_face_beg_row == dpyinfo->mouse_face_end_row) 24163 if (hlinfo->mouse_face_beg_row == hlinfo->mouse_face_end_row)
24138 { 24164 {
24139 if (dpyinfo->mouse_face_beg_col <= hpos && hpos < dpyinfo->mouse_face_end_col) 24165 if (hlinfo->mouse_face_beg_col <= hpos && hpos < hlinfo->mouse_face_end_col)
24140 return 1; 24166 return 1;
24141 } 24167 }
24142 else if ((vpos == dpyinfo->mouse_face_beg_row 24168 else if ((vpos == hlinfo->mouse_face_beg_row
24143 && hpos >= dpyinfo->mouse_face_beg_col) 24169 && hpos >= hlinfo->mouse_face_beg_col)
24144 || (vpos == dpyinfo->mouse_face_end_row 24170 || (vpos == hlinfo->mouse_face_end_row
24145 && hpos < dpyinfo->mouse_face_end_col)) 24171 && hpos < hlinfo->mouse_face_end_col))
24146 return 1; 24172 return 1;
24147 } 24173 }
24148 else 24174 else
24149 { 24175 {
24150 if (dpyinfo->mouse_face_beg_row == dpyinfo->mouse_face_end_row) 24176 if (hlinfo->mouse_face_beg_row == hlinfo->mouse_face_end_row)
24151 { 24177 {
24152 if (dpyinfo->mouse_face_end_col < hpos && hpos <= dpyinfo->mouse_face_beg_col) 24178 if (hlinfo->mouse_face_end_col < hpos && hpos <= hlinfo->mouse_face_beg_col)
24153 return 1; 24179 return 1;
24154 } 24180 }
24155 else if ((vpos == dpyinfo->mouse_face_beg_row 24181 else if ((vpos == hlinfo->mouse_face_beg_row
24156 && hpos <= dpyinfo->mouse_face_beg_col) 24182 && hpos <= hlinfo->mouse_face_beg_col)
24157 || (vpos == dpyinfo->mouse_face_end_row 24183 || (vpos == hlinfo->mouse_face_end_row
24158 && hpos > dpyinfo->mouse_face_end_col)) 24184 && hpos > hlinfo->mouse_face_end_col))
24159 return 1; 24185 return 1;
24160 } 24186 }
24161 return 0; 24187 return 0;
@@ -24296,7 +24322,7 @@ rows_from_pos_range (struct window *w,
24296 } 24322 }
24297} 24323}
24298 24324
24299/* This function sets the mouse_face_* elements of DPYINFO, assuming 24325/* This function sets the mouse_face_* elements of HLINFO, assuming
24300 the mouse cursor is on a glyph with buffer charpos MOUSE_CHARPOS in 24326 the mouse cursor is on a glyph with buffer charpos MOUSE_CHARPOS in
24301 window WINDOW. START_CHARPOS and END_CHARPOS are buffer positions 24327 window WINDOW. START_CHARPOS and END_CHARPOS are buffer positions
24302 for the overlay or run of text properties specifying the mouse 24328 for the overlay or run of text properties specifying the mouse
@@ -24307,7 +24333,7 @@ rows_from_pos_range (struct window *w,
24307 24333
24308static void 24334static void
24309mouse_face_from_buffer_pos (Lisp_Object window, 24335mouse_face_from_buffer_pos (Lisp_Object window,
24310 Display_Info *dpyinfo, 24336 Mouse_HLInfo *hlinfo,
24311 EMACS_INT mouse_charpos, 24337 EMACS_INT mouse_charpos,
24312 EMACS_INT start_charpos, 24338 EMACS_INT start_charpos,
24313 EMACS_INT end_charpos, 24339 EMACS_INT end_charpos,
@@ -24352,7 +24378,7 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24352 if (r2 == NULL) 24378 if (r2 == NULL)
24353 { 24379 {
24354 r2 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos)); 24380 r2 = MATRIX_ROW (w->current_matrix, XFASTINT (w->window_end_vpos));
24355 dpyinfo->mouse_face_past_end = 1; 24381 hlinfo->mouse_face_past_end = 1;
24356 } 24382 }
24357 else if (!NILP (after_string)) 24383 else if (!NILP (after_string))
24358 { 24384 {
@@ -24381,10 +24407,10 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24381 r1 = tem; 24407 r1 = tem;
24382 } 24408 }
24383 24409
24384 dpyinfo->mouse_face_beg_y = r1->y; 24410 hlinfo->mouse_face_beg_y = r1->y;
24385 dpyinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (r1, w->current_matrix); 24411 hlinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (r1, w->current_matrix);
24386 dpyinfo->mouse_face_end_y = r2->y; 24412 hlinfo->mouse_face_end_y = r2->y;
24387 dpyinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r2, w->current_matrix); 24413 hlinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r2, w->current_matrix);
24388 24414
24389 /* For a bidi-reordered row, the positions of BEFORE_STRING, 24415 /* For a bidi-reordered row, the positions of BEFORE_STRING,
24390 AFTER_STRING, DISPLAY_STRING, START_CHARPOS, and END_CHARPOS 24416 AFTER_STRING, DISPLAY_STRING, START_CHARPOS, and END_CHARPOS
@@ -24432,19 +24458,19 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24432 start_charpos); 24458 start_charpos);
24433 /* If pos == 0, it means before_string came from an 24459 /* If pos == 0, it means before_string came from an
24434 overlay, not from a buffer position. */ 24460 overlay, not from a buffer position. */
24435 if (!pos || pos >= start_charpos && pos < end_charpos) 24461 if (!pos || (pos >= start_charpos && pos < end_charpos))
24436 break; 24462 break;
24437 } 24463 }
24438 else if (EQ (glyph->object, after_string)) 24464 else if (EQ (glyph->object, after_string))
24439 { 24465 {
24440 pos = string_buffer_position (w, after_string, end_charpos); 24466 pos = string_buffer_position (w, after_string, end_charpos);
24441 if (!pos || pos >= start_charpos && pos < end_charpos) 24467 if (!pos || (pos >= start_charpos && pos < end_charpos))
24442 break; 24468 break;
24443 } 24469 }
24444 x += glyph->pixel_width; 24470 x += glyph->pixel_width;
24445 } 24471 }
24446 dpyinfo->mouse_face_beg_x = x; 24472 hlinfo->mouse_face_beg_x = x;
24447 dpyinfo->mouse_face_beg_col = glyph - r1->glyphs[TEXT_AREA]; 24473 hlinfo->mouse_face_beg_col = glyph - r1->glyphs[TEXT_AREA];
24448 } 24474 }
24449 else 24475 else
24450 { 24476 {
@@ -24482,13 +24508,13 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24482 pos = string_buffer_position (w, before_string, start_charpos); 24508 pos = string_buffer_position (w, before_string, start_charpos);
24483 /* If pos == 0, it means before_string came from an 24509 /* If pos == 0, it means before_string came from an
24484 overlay, not from a buffer position. */ 24510 overlay, not from a buffer position. */
24485 if (!pos || pos >= start_charpos && pos < end_charpos) 24511 if (!pos || (pos >= start_charpos && pos < end_charpos))
24486 break; 24512 break;
24487 } 24513 }
24488 else if (EQ (glyph->object, after_string)) 24514 else if (EQ (glyph->object, after_string))
24489 { 24515 {
24490 pos = string_buffer_position (w, after_string, end_charpos); 24516 pos = string_buffer_position (w, after_string, end_charpos);
24491 if (!pos || pos >= start_charpos && pos < end_charpos) 24517 if (!pos || (pos >= start_charpos && pos < end_charpos))
24492 break; 24518 break;
24493 } 24519 }
24494 } 24520 }
@@ -24496,8 +24522,8 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24496 glyph++; /* first glyph to the right of the highlighted area */ 24522 glyph++; /* first glyph to the right of the highlighted area */
24497 for (g = r1->glyphs[TEXT_AREA], x = r1->x; g < glyph; g++) 24523 for (g = r1->glyphs[TEXT_AREA], x = r1->x; g < glyph; g++)
24498 x += g->pixel_width; 24524 x += g->pixel_width;
24499 dpyinfo->mouse_face_beg_x = x; 24525 hlinfo->mouse_face_beg_x = x;
24500 dpyinfo->mouse_face_beg_col = glyph - r1->glyphs[TEXT_AREA]; 24526 hlinfo->mouse_face_beg_col = glyph - r1->glyphs[TEXT_AREA];
24501 } 24527 }
24502 24528
24503 /* If the highlight ends in a different row, compute GLYPH and END 24529 /* If the highlight ends in a different row, compute GLYPH and END
@@ -24546,13 +24572,13 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24546 if (EQ (end->object, before_string)) 24572 if (EQ (end->object, before_string))
24547 { 24573 {
24548 pos = string_buffer_position (w, before_string, start_charpos); 24574 pos = string_buffer_position (w, before_string, start_charpos);
24549 if (!pos || pos >= start_charpos && pos < end_charpos) 24575 if (!pos || (pos >= start_charpos && pos < end_charpos))
24550 break; 24576 break;
24551 } 24577 }
24552 else if (EQ (end->object, after_string)) 24578 else if (EQ (end->object, after_string))
24553 { 24579 {
24554 pos = string_buffer_position (w, after_string, end_charpos); 24580 pos = string_buffer_position (w, after_string, end_charpos);
24555 if (!pos || pos >= start_charpos && pos < end_charpos) 24581 if (!pos || (pos >= start_charpos && pos < end_charpos))
24556 break; 24582 break;
24557 } 24583 }
24558 } 24584 }
@@ -24560,8 +24586,8 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24560 for (; glyph <= end; ++glyph) 24586 for (; glyph <= end; ++glyph)
24561 x += glyph->pixel_width; 24587 x += glyph->pixel_width;
24562 24588
24563 dpyinfo->mouse_face_end_x = x; 24589 hlinfo->mouse_face_end_x = x;
24564 dpyinfo->mouse_face_end_col = glyph - r2->glyphs[TEXT_AREA]; 24590 hlinfo->mouse_face_end_col = glyph - r2->glyphs[TEXT_AREA];
24565 } 24591 }
24566 else 24592 else
24567 { 24593 {
@@ -24596,27 +24622,27 @@ mouse_face_from_buffer_pos (Lisp_Object window,
24596 if (EQ (end->object, before_string)) 24622 if (EQ (end->object, before_string))
24597 { 24623 {
24598 pos = string_buffer_position (w, before_string, start_charpos); 24624 pos = string_buffer_position (w, before_string, start_charpos);
24599 if (!pos || pos >= start_charpos && pos < end_charpos) 24625 if (!pos || (pos >= start_charpos && pos < end_charpos))
24600 break; 24626 break;
24601 } 24627 }
24602 else if (EQ (end->object, after_string)) 24628 else if (EQ (end->object, after_string))
24603 { 24629 {
24604 pos = string_buffer_position (w, after_string, end_charpos); 24630 pos = string_buffer_position (w, after_string, end_charpos);
24605 if (!pos || pos >= start_charpos && pos < end_charpos) 24631 if (!pos || (pos >= start_charpos && pos < end_charpos))
24606 break; 24632 break;
24607 } 24633 }
24608 x += end->pixel_width; 24634 x += end->pixel_width;
24609 } 24635 }
24610 dpyinfo->mouse_face_end_x = x; 24636 hlinfo->mouse_face_end_x = x;
24611 dpyinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA]; 24637 hlinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA];
24612 } 24638 }
24613 24639
24614 dpyinfo->mouse_face_window = window; 24640 hlinfo->mouse_face_window = window;
24615 dpyinfo->mouse_face_face_id 24641 hlinfo->mouse_face_face_id
24616 = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore, 24642 = face_at_buffer_position (w, mouse_charpos, 0, 0, &ignore,
24617 mouse_charpos + 1, 24643 mouse_charpos + 1,
24618 !dpyinfo->mouse_face_hidden, -1); 24644 !hlinfo->mouse_face_hidden, -1);
24619 show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); 24645 show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
24620} 24646}
24621 24647
24622/* The following function is not used anymore (replaced with 24648/* The following function is not used anymore (replaced with
@@ -24705,11 +24731,11 @@ fast_find_string_pos (struct window *w, EMACS_INT pos, Lisp_Object object,
24705 24731
24706/* Find the positions of the first and the last glyphs in window W's 24732/* Find the positions of the first and the last glyphs in window W's
24707 current matrix that occlude positions [STARTPOS..ENDPOS] in OBJECT 24733 current matrix that occlude positions [STARTPOS..ENDPOS] in OBJECT
24708 (assumed to be a string), and return in DPYINFO's mouse_face 24734 (assumed to be a string), and return in HLINFO's mouse_face_*
24709 members the pixel and column/row coordinates of those glyphs. */ 24735 members the pixel and column/row coordinates of those glyphs. */
24710 24736
24711static void 24737static void
24712mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo, 24738mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo,
24713 Lisp_Object object, 24739 Lisp_Object object,
24714 EMACS_INT startpos, EMACS_INT endpos) 24740 EMACS_INT startpos, EMACS_INT endpos)
24715{ 24741{
@@ -24734,10 +24760,10 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24734 if (EQ (g->object, object) 24760 if (EQ (g->object, object)
24735 && startpos <= g->charpos && g->charpos <= endpos) 24761 && startpos <= g->charpos && g->charpos <= endpos)
24736 { 24762 {
24737 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows; 24763 hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
24738 dpyinfo->mouse_face_beg_y = r->y; 24764 hlinfo->mouse_face_beg_y = r->y;
24739 dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA]; 24765 hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
24740 dpyinfo->mouse_face_beg_x = gx; 24766 hlinfo->mouse_face_beg_x = gx;
24741 found = 1; 24767 found = 1;
24742 break; 24768 break;
24743 } 24769 }
@@ -24752,12 +24778,12 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24752 if (EQ ((g-1)->object, object) 24778 if (EQ ((g-1)->object, object)
24753 && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos) 24779 && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
24754 { 24780 {
24755 dpyinfo->mouse_face_beg_row = r - w->current_matrix->rows; 24781 hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
24756 dpyinfo->mouse_face_beg_y = r->y; 24782 hlinfo->mouse_face_beg_y = r->y;
24757 dpyinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA]; 24783 hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
24758 for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1) 24784 for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
24759 gx += g1->pixel_width; 24785 gx += g1->pixel_width;
24760 dpyinfo->mouse_face_beg_x = gx; 24786 hlinfo->mouse_face_beg_x = gx;
24761 found = 1; 24787 found = 1;
24762 break; 24788 break;
24763 } 24789 }
@@ -24791,8 +24817,8 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24791 r--; 24817 r--;
24792 24818
24793 /* Set the end row and its vertical pixel coordinate. */ 24819 /* Set the end row and its vertical pixel coordinate. */
24794 dpyinfo->mouse_face_end_row = r - w->current_matrix->rows; 24820 hlinfo->mouse_face_end_row = r - w->current_matrix->rows;
24795 dpyinfo->mouse_face_end_y = r->y; 24821 hlinfo->mouse_face_end_y = r->y;
24796 24822
24797 /* Compute and set the end column and the end column's horizontal 24823 /* Compute and set the end column and the end column's horizontal
24798 pixel coordinate. */ 24824 pixel coordinate. */
@@ -24804,11 +24830,11 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24804 if (EQ ((e-1)->object, object) 24830 if (EQ ((e-1)->object, object)
24805 && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos) 24831 && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos)
24806 break; 24832 break;
24807 dpyinfo->mouse_face_end_col = e - g; 24833 hlinfo->mouse_face_end_col = e - g;
24808 24834
24809 for (gx = r->x; g < e; ++g) 24835 for (gx = r->x; g < e; ++g)
24810 gx += g->pixel_width; 24836 gx += g->pixel_width;
24811 dpyinfo->mouse_face_end_x = gx; 24837 hlinfo->mouse_face_end_x = gx;
24812 } 24838 }
24813 else 24839 else
24814 { 24840 {
@@ -24821,11 +24847,13 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo,
24821 break; 24847 break;
24822 gx += e->pixel_width; 24848 gx += e->pixel_width;
24823 } 24849 }
24824 dpyinfo->mouse_face_end_col = e - r->glyphs[TEXT_AREA]; 24850 hlinfo->mouse_face_end_col = e - r->glyphs[TEXT_AREA];
24825 dpyinfo->mouse_face_end_x = gx; 24851 hlinfo->mouse_face_end_x = gx;
24826 } 24852 }
24827} 24853}
24828 24854
24855#ifdef HAVE_WINDOW_SYSTEM
24856
24829/* See if position X, Y is within a hot-spot of an image. */ 24857/* See if position X, Y is within a hot-spot of an image. */
24830 24858
24831static int 24859static int
@@ -24996,6 +25024,8 @@ define_frame_cursor1 (struct frame *f, Cursor cursor, Lisp_Object pointer)
24996 FRAME_RIF (f)->define_frame_cursor (f, cursor); 25024 FRAME_RIF (f)->define_frame_cursor (f, cursor);
24997} 25025}
24998 25026
25027#endif /* HAVE_WINDOW_SYSTEM */
25028
24999/* Take proper action when mouse has moved to the mode or header line 25029/* Take proper action when mouse has moved to the mode or header line
25000 or marginal area AREA of window W, x-position X and y-position Y. 25030 or marginal area AREA of window W, x-position X and y-position Y.
25001 X is relative to the start of the text display area of W, so the 25031 X is relative to the start of the text display area of W, so the
@@ -25008,8 +25038,13 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
25008{ 25038{
25009 struct window *w = XWINDOW (window); 25039 struct window *w = XWINDOW (window);
25010 struct frame *f = XFRAME (w->frame); 25040 struct frame *f = XFRAME (w->frame);
25011 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 25041 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
25012 Cursor cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 25042#ifdef HAVE_WINDOW_SYSTEM
25043 Display_Info *dpyinfo;
25044 Cursor cursor;
25045#else
25046 Cursor cursor = No_Cursor;
25047#endif
25013 Lisp_Object pointer = Qnil; 25048 Lisp_Object pointer = Qnil;
25014 int dx, dy, width, height; 25049 int dx, dy, width, height;
25015 EMACS_INT charpos; 25050 EMACS_INT charpos;
@@ -25061,6 +25096,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
25061 25096
25062 help = Qnil; 25097 help = Qnil;
25063 25098
25099#ifdef HAVE_WINDOW_SYSTEM
25064 if (IMAGEP (object)) 25100 if (IMAGEP (object))
25065 { 25101 {
25066 Lisp_Object image_map, hotspot; 25102 Lisp_Object image_map, hotspot;
@@ -25097,6 +25133,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
25097 if (NILP (pointer)) 25133 if (NILP (pointer))
25098 pointer = Fplist_get (XCDR (object), QCpointer); 25134 pointer = Fplist_get (XCDR (object), QCpointer);
25099 } 25135 }
25136#endif /* HAVE_WINDOW_SYSTEM */
25100 25137
25101 if (STRINGP (string)) 25138 if (STRINGP (string))
25102 { 25139 {
@@ -25116,19 +25153,27 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
25116 } 25153 }
25117 } 25154 }
25118 25155
25119 if (NILP (pointer)) 25156#ifdef HAVE_WINDOW_SYSTEM
25120 pointer = Fget_text_property (pos, Qpointer, string); 25157 if (FRAME_WINDOW_P (f))
25121
25122 /* Change the mouse pointer according to what is under X/Y. */
25123 if (NILP (pointer) && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)))
25124 { 25158 {
25125 Lisp_Object map; 25159 dpyinfo = FRAME_X_DISPLAY_INFO (f);
25126 map = Fget_text_property (pos, Qlocal_map, string); 25160 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
25127 if (!KEYMAPP (map)) 25161 if (NILP (pointer))
25128 map = Fget_text_property (pos, Qkeymap, string); 25162 pointer = Fget_text_property (pos, Qpointer, string);
25129 if (!KEYMAPP (map)) 25163
25130 cursor = dpyinfo->vertical_scroll_bar_cursor; 25164 /* Change the mouse pointer according to what is under X/Y. */
25165 if (NILP (pointer)
25166 && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)))
25167 {
25168 Lisp_Object map;
25169 map = Fget_text_property (pos, Qlocal_map, string);
25170 if (!KEYMAPP (map))
25171 map = Fget_text_property (pos, Qkeymap, string);
25172 if (!KEYMAPP (map))
25173 cursor = dpyinfo->vertical_scroll_bar_cursor;
25174 }
25131 } 25175 }
25176#endif
25132 25177
25133 /* Change the mouse face according to what is under X/Y. */ 25178 /* Change the mouse face according to what is under X/Y. */
25134 mouse_face = Fget_text_property (pos, Qmouse_face, string); 25179 mouse_face = Fget_text_property (pos, Qmouse_face, string);
@@ -25208,60 +25253,63 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
25208 25253
25209 /* If GLYPH's position is included in the region that is 25254 /* If GLYPH's position is included in the region that is
25210 already drawn in mouse face, we have nothing to do. */ 25255 already drawn in mouse face, we have nothing to do. */
25211 if ( EQ (window, dpyinfo->mouse_face_window) 25256 if ( EQ (window, hlinfo->mouse_face_window)
25212 && (!row->reversed_p 25257 && (!row->reversed_p
25213 ? (dpyinfo->mouse_face_beg_col <= hpos 25258 ? (hlinfo->mouse_face_beg_col <= hpos
25214 && hpos < dpyinfo->mouse_face_end_col) 25259 && hpos < hlinfo->mouse_face_end_col)
25215 /* In R2L rows we swap BEG and END, see below. */ 25260 /* In R2L rows we swap BEG and END, see below. */
25216 : (dpyinfo->mouse_face_end_col <= hpos 25261 : (hlinfo->mouse_face_end_col <= hpos
25217 && hpos < dpyinfo->mouse_face_beg_col)) 25262 && hpos < hlinfo->mouse_face_beg_col))
25218 && dpyinfo->mouse_face_beg_row == vpos ) 25263 && hlinfo->mouse_face_beg_row == vpos )
25219 return; 25264 return;
25220 25265
25221 if (clear_mouse_face (dpyinfo)) 25266 if (clear_mouse_face (hlinfo))
25222 cursor = No_Cursor; 25267 cursor = No_Cursor;
25223 25268
25224 if (!row->reversed_p) 25269 if (!row->reversed_p)
25225 { 25270 {
25226 dpyinfo->mouse_face_beg_col = hpos; 25271 hlinfo->mouse_face_beg_col = hpos;
25227 dpyinfo->mouse_face_beg_x = original_x_pixel 25272 hlinfo->mouse_face_beg_x = original_x_pixel
25228 - (total_pixel_width + dx); 25273 - (total_pixel_width + dx);
25229 dpyinfo->mouse_face_end_col = hpos + gseq_length; 25274 hlinfo->mouse_face_end_col = hpos + gseq_length;
25230 dpyinfo->mouse_face_end_x = 0; 25275 hlinfo->mouse_face_end_x = 0;
25231 } 25276 }
25232 else 25277 else
25233 { 25278 {
25234 /* In R2L rows, show_mouse_face expects BEG and END 25279 /* In R2L rows, show_mouse_face expects BEG and END
25235 coordinates to be swapped. */ 25280 coordinates to be swapped. */
25236 dpyinfo->mouse_face_end_col = hpos; 25281 hlinfo->mouse_face_end_col = hpos;
25237 dpyinfo->mouse_face_end_x = original_x_pixel 25282 hlinfo->mouse_face_end_x = original_x_pixel
25238 - (total_pixel_width + dx); 25283 - (total_pixel_width + dx);
25239 dpyinfo->mouse_face_beg_col = hpos + gseq_length; 25284 hlinfo->mouse_face_beg_col = hpos + gseq_length;
25240 dpyinfo->mouse_face_beg_x = 0; 25285 hlinfo->mouse_face_beg_x = 0;
25241 } 25286 }
25242 25287
25243 dpyinfo->mouse_face_beg_row = vpos; 25288 hlinfo->mouse_face_beg_row = vpos;
25244 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row; 25289 hlinfo->mouse_face_end_row = hlinfo->mouse_face_beg_row;
25245 dpyinfo->mouse_face_beg_y = 0; 25290 hlinfo->mouse_face_beg_y = 0;
25246 dpyinfo->mouse_face_end_y = 0; 25291 hlinfo->mouse_face_end_y = 0;
25247 dpyinfo->mouse_face_past_end = 0; 25292 hlinfo->mouse_face_past_end = 0;
25248 dpyinfo->mouse_face_window = window; 25293 hlinfo->mouse_face_window = window;
25249 25294
25250 dpyinfo->mouse_face_face_id = face_at_string_position (w, string, 25295 hlinfo->mouse_face_face_id = face_at_string_position (w, string,
25251 charpos, 25296 charpos,
25252 0, 0, 0, 25297 0, 0, 0,
25253 &ignore, 25298 &ignore,
25254 glyph->face_id, 25299 glyph->face_id,
25255 1); 25300 1);
25256 show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); 25301 show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
25257 25302
25258 if (NILP (pointer)) 25303 if (NILP (pointer))
25259 pointer = Qhand; 25304 pointer = Qhand;
25260 } 25305 }
25261 else if ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)) 25306 else if ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE))
25262 clear_mouse_face (dpyinfo); 25307 clear_mouse_face (hlinfo);
25263 } 25308 }
25264 define_frame_cursor1 (f, cursor, pointer); 25309#ifdef HAVE_WINDOW_SYSTEM
25310 if (FRAME_WINDOW_P (f))
25311 define_frame_cursor1 (f, cursor, pointer);
25312#endif
25265} 25313}
25266 25314
25267 25315
@@ -25274,7 +25322,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
25274void 25322void
25275note_mouse_highlight (struct frame *f, int x, int y) 25323note_mouse_highlight (struct frame *f, int x, int y)
25276{ 25324{
25277 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 25325 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
25278 enum window_part part; 25326 enum window_part part;
25279 Lisp_Object window; 25327 Lisp_Object window;
25280 struct window *w; 25328 struct window *w;
@@ -25283,7 +25331,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25283 struct buffer *b; 25331 struct buffer *b;
25284 25332
25285 /* When a menu is active, don't highlight because this looks odd. */ 25333 /* When a menu is active, don't highlight because this looks odd. */
25286#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) 25334#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) || defined (MSDOS)
25287 if (popup_activated ()) 25335 if (popup_activated ())
25288 return; 25336 return;
25289#endif 25337#endif
@@ -25293,16 +25341,16 @@ note_mouse_highlight (struct frame *f, int x, int y)
25293 || f->pointer_invisible) 25341 || f->pointer_invisible)
25294 return; 25342 return;
25295 25343
25296 dpyinfo->mouse_face_mouse_x = x; 25344 hlinfo->mouse_face_mouse_x = x;
25297 dpyinfo->mouse_face_mouse_y = y; 25345 hlinfo->mouse_face_mouse_y = y;
25298 dpyinfo->mouse_face_mouse_frame = f; 25346 hlinfo->mouse_face_mouse_frame = f;
25299 25347
25300 if (dpyinfo->mouse_face_defer) 25348 if (hlinfo->mouse_face_defer)
25301 return; 25349 return;
25302 25350
25303 if (gc_in_progress) 25351 if (gc_in_progress)
25304 { 25352 {
25305 dpyinfo->mouse_face_deferred_gc = 1; 25353 hlinfo->mouse_face_deferred_gc = 1;
25306 return; 25354 return;
25307 } 25355 }
25308 25356
@@ -25311,10 +25359,10 @@ note_mouse_highlight (struct frame *f, int x, int y)
25311 25359
25312 /* If we were displaying active text in another window, clear that. 25360 /* If we were displaying active text in another window, clear that.
25313 Also clear if we move out of text area in same window. */ 25361 Also clear if we move out of text area in same window. */
25314 if (! EQ (window, dpyinfo->mouse_face_window) 25362 if (! EQ (window, hlinfo->mouse_face_window)
25315 || (part != ON_TEXT && part != ON_MODE_LINE && part != ON_HEADER_LINE 25363 || (part != ON_TEXT && part != ON_MODE_LINE && part != ON_HEADER_LINE
25316 && !NILP (dpyinfo->mouse_face_window))) 25364 && !NILP (hlinfo->mouse_face_window)))
25317 clear_mouse_face (dpyinfo); 25365 clear_mouse_face (hlinfo);
25318 25366
25319 /* Not on a window -> return. */ 25367 /* Not on a window -> return. */
25320 if (!WINDOWP (window)) 25368 if (!WINDOWP (window))
@@ -25327,6 +25375,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25327 w = XWINDOW (window); 25375 w = XWINDOW (window);
25328 frame_to_window_pixel_xy (w, &x, &y); 25376 frame_to_window_pixel_xy (w, &x, &y);
25329 25377
25378#ifdef HAVE_WINDOW_SYSTEM
25330 /* Handle tool-bar window differently since it doesn't display a 25379 /* Handle tool-bar window differently since it doesn't display a
25331 buffer. */ 25380 buffer. */
25332 if (EQ (window, f->tool_bar_window)) 25381 if (EQ (window, f->tool_bar_window))
@@ -25334,6 +25383,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25334 note_tool_bar_highlight (f, x, y); 25383 note_tool_bar_highlight (f, x, y);
25335 return; 25384 return;
25336 } 25385 }
25386#endif
25337 25387
25338 /* Mouse is on the mode, header line or margin? */ 25388 /* Mouse is on the mode, header line or margin? */
25339 if (part == ON_MODE_LINE || part == ON_HEADER_LINE 25389 if (part == ON_MODE_LINE || part == ON_HEADER_LINE
@@ -25343,6 +25393,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25343 return; 25393 return;
25344 } 25394 }
25345 25395
25396#ifdef HAVE_WINDOW_SYSTEM
25346 if (part == ON_VERTICAL_BORDER) 25397 if (part == ON_VERTICAL_BORDER)
25347 { 25398 {
25348 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor; 25399 cursor = FRAME_X_OUTPUT (f)->horizontal_drag_cursor;
@@ -25353,6 +25404,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25353 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 25404 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
25354 else 25405 else
25355 cursor = FRAME_X_OUTPUT (f)->text_cursor; 25406 cursor = FRAME_X_OUTPUT (f)->text_cursor;
25407#endif
25356 25408
25357 /* Are we in a window whose display is up to date? 25409 /* Are we in a window whose display is up to date?
25358 And verify the buffer's text has not changed. */ 25410 And verify the buffer's text has not changed. */
@@ -25376,6 +25428,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25376 /* Find the glyph under X/Y. */ 25428 /* Find the glyph under X/Y. */
25377 glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area); 25429 glyph = x_y_to_hpos_vpos (w, x, y, &hpos, &vpos, &dx, &dy, &area);
25378 25430
25431#ifdef HAVE_WINDOW_SYSTEM
25379 /* Look for :pointer property on image. */ 25432 /* Look for :pointer property on image. */
25380 if (glyph != NULL && glyph->type == IMAGE_GLYPH) 25433 if (glyph != NULL && glyph->type == IMAGE_GLYPH)
25381 { 25434 {
@@ -25417,11 +25470,18 @@ note_mouse_highlight (struct frame *f, int x, int y)
25417 pointer = Fplist_get (XCDR (img->spec), QCpointer); 25470 pointer = Fplist_get (XCDR (img->spec), QCpointer);
25418 } 25471 }
25419 } 25472 }
25473#endif /* HAVE_WINDOW_SYSTEM */
25420 25474
25421 /* Clear mouse face if X/Y not over text. */ 25475 /* Clear mouse face if X/Y not over text. */
25422 if (glyph == NULL 25476 if (glyph == NULL
25423 || area != TEXT_AREA 25477 || area != TEXT_AREA
25424 || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p 25478 || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p
25479 /* Glyph's OBJECT is an integer for glyphs inserted by the
25480 display engine for its internal purposes, like truncation
25481 and continuation glyphs and blanks beyond the end of
25482 line's text on text terminals. If we are over such a
25483 glyph, we are not over any text. */
25484 || INTEGERP (glyph->object)
25425 /* R2L rows have a stretch glyph at their front, which 25485 /* R2L rows have a stretch glyph at their front, which
25426 stands for no text, whereas L2R rows have no glyphs at 25486 stands for no text, whereas L2R rows have no glyphs at
25427 all beyond the end of text. Treat such stretch glyphs 25487 all beyond the end of text. Treat such stretch glyphs
@@ -25431,15 +25491,17 @@ note_mouse_highlight (struct frame *f, int x, int y)
25431 && glyph->type == STRETCH_GLYPH 25491 && glyph->type == STRETCH_GLYPH
25432 && glyph->avoid_cursor_p)) 25492 && glyph->avoid_cursor_p))
25433 { 25493 {
25434 if (clear_mouse_face (dpyinfo)) 25494 if (clear_mouse_face (hlinfo))
25435 cursor = No_Cursor; 25495 cursor = No_Cursor;
25436 if (NILP (pointer)) 25496#ifdef HAVE_WINDOW_SYSTEM
25497 if (FRAME_WINDOW_P (f) && NILP (pointer))
25437 { 25498 {
25438 if (area != TEXT_AREA) 25499 if (area != TEXT_AREA)
25439 cursor = FRAME_X_OUTPUT (f)->nontext_cursor; 25500 cursor = FRAME_X_OUTPUT (f)->nontext_cursor;
25440 else 25501 else
25441 pointer = Vvoid_text_area_pointer; 25502 pointer = Vvoid_text_area_pointer;
25442 } 25503 }
25504#endif
25443 goto set_cursor; 25505 goto set_cursor;
25444 } 25506 }
25445 25507
@@ -25485,8 +25547,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
25485 the one we are currently highlighting, we have to 25547 the one we are currently highlighting, we have to
25486 check if we enter the overlapping overlay, and then 25548 check if we enter the overlapping overlay, and then
25487 highlight only that. */ 25549 highlight only that. */
25488 || (OVERLAYP (dpyinfo->mouse_face_overlay) 25550 || (OVERLAYP (hlinfo->mouse_face_overlay)
25489 && mouse_face_overlay_overlaps (dpyinfo->mouse_face_overlay))) 25551 && mouse_face_overlay_overlaps (hlinfo->mouse_face_overlay)))
25490 { 25552 {
25491 /* Find the highest priority overlay with a mouse-face. */ 25553 /* Find the highest priority overlay with a mouse-face. */
25492 overlay = Qnil; 25554 overlay = Qnil;
@@ -25499,12 +25561,12 @@ note_mouse_highlight (struct frame *f, int x, int y)
25499 25561
25500 /* If we're highlighting the same overlay as before, there's 25562 /* If we're highlighting the same overlay as before, there's
25501 no need to do that again. */ 25563 no need to do that again. */
25502 if (!NILP (overlay) && EQ (overlay, dpyinfo->mouse_face_overlay)) 25564 if (!NILP (overlay) && EQ (overlay, hlinfo->mouse_face_overlay))
25503 goto check_help_echo; 25565 goto check_help_echo;
25504 dpyinfo->mouse_face_overlay = overlay; 25566 hlinfo->mouse_face_overlay = overlay;
25505 25567
25506 /* Clear the display of the old active region, if any. */ 25568 /* Clear the display of the old active region, if any. */
25507 if (clear_mouse_face (dpyinfo)) 25569 if (clear_mouse_face (hlinfo))
25508 cursor = No_Cursor; 25570 cursor = No_Cursor;
25509 25571
25510 /* If no overlay applies, get a text property. */ 25572 /* If no overlay applies, get a text property. */
@@ -25528,14 +25590,14 @@ note_mouse_highlight (struct frame *f, int x, int y)
25528 b = make_number (0); 25590 b = make_number (0);
25529 if (NILP (e)) 25591 if (NILP (e))
25530 e = make_number (SCHARS (object) - 1); 25592 e = make_number (SCHARS (object) - 1);
25531 mouse_face_from_string_pos (w, dpyinfo, object, 25593 mouse_face_from_string_pos (w, hlinfo, object,
25532 XINT (b), XINT (e)); 25594 XINT (b), XINT (e));
25533 dpyinfo->mouse_face_past_end = 0; 25595 hlinfo->mouse_face_past_end = 0;
25534 dpyinfo->mouse_face_window = window; 25596 hlinfo->mouse_face_window = window;
25535 dpyinfo->mouse_face_face_id 25597 hlinfo->mouse_face_face_id
25536 = face_at_string_position (w, object, pos, 0, 0, 0, &ignore, 25598 = face_at_string_position (w, object, pos, 0, 0, 0, &ignore,
25537 glyph->face_id, 1); 25599 glyph->face_id, 1);
25538 show_mouse_face (dpyinfo, DRAW_MOUSE_FACE); 25600 show_mouse_face (hlinfo, DRAW_MOUSE_FACE);
25539 cursor = No_Cursor; 25601 cursor = No_Cursor;
25540 } 25602 }
25541 else 25603 else
@@ -25610,7 +25672,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25610 if (!STRINGP (after_string)) after_string = Qnil; 25672 if (!STRINGP (after_string)) after_string = Qnil;
25611 } 25673 }
25612 25674
25613 mouse_face_from_buffer_pos (window, dpyinfo, pos, 25675 mouse_face_from_buffer_pos (window, hlinfo, pos,
25614 XFASTINT (before), 25676 XFASTINT (before),
25615 XFASTINT (after), 25677 XFASTINT (after),
25616 before_string, after_string, 25678 before_string, after_string,
@@ -25689,8 +25751,9 @@ note_mouse_highlight (struct frame *f, int x, int y)
25689 } 25751 }
25690 } 25752 }
25691 25753
25754#ifdef HAVE_WINDOW_SYSTEM
25692 /* Look for a `pointer' property. */ 25755 /* Look for a `pointer' property. */
25693 if (NILP (pointer)) 25756 if (FRAME_WINDOW_P (f) && NILP (pointer))
25694 { 25757 {
25695 /* Check overlays first. */ 25758 /* Check overlays first. */
25696 for (i = noverlays - 1; i >= 0 && NILP (pointer); --i) 25759 for (i = noverlays - 1; i >= 0 && NILP (pointer); --i)
@@ -25729,6 +25792,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
25729 Qpointer, object); 25792 Qpointer, object);
25730 } 25793 }
25731 } 25794 }
25795#endif /* HAVE_WINDOW_SYSTEM */
25732 25796
25733 BEGV = obegv; 25797 BEGV = obegv;
25734 ZV = ozv; 25798 ZV = ozv;
@@ -25737,7 +25801,14 @@ note_mouse_highlight (struct frame *f, int x, int y)
25737 25801
25738 set_cursor: 25802 set_cursor:
25739 25803
25740 define_frame_cursor1 (f, cursor, pointer); 25804#ifdef HAVE_WINDOW_SYSTEM
25805 if (FRAME_WINDOW_P (f))
25806 define_frame_cursor1 (f, cursor, pointer);
25807#else
25808 /* This is here to prevent a compiler error, about "label at end of
25809 compound statement". */
25810 return;
25811#endif
25741} 25812}
25742 25813
25743 25814
@@ -25749,13 +25820,13 @@ note_mouse_highlight (struct frame *f, int x, int y)
25749void 25820void
25750x_clear_window_mouse_face (struct window *w) 25821x_clear_window_mouse_face (struct window *w)
25751{ 25822{
25752 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); 25823 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
25753 Lisp_Object window; 25824 Lisp_Object window;
25754 25825
25755 BLOCK_INPUT; 25826 BLOCK_INPUT;
25756 XSETWINDOW (window, w); 25827 XSETWINDOW (window, w);
25757 if (EQ (window, dpyinfo->mouse_face_window)) 25828 if (EQ (window, hlinfo->mouse_face_window))
25758 clear_mouse_face (dpyinfo); 25829 clear_mouse_face (hlinfo);
25759 UNBLOCK_INPUT; 25830 UNBLOCK_INPUT;
25760} 25831}
25761 25832
@@ -25768,20 +25839,18 @@ void
25768cancel_mouse_face (struct frame *f) 25839cancel_mouse_face (struct frame *f)
25769{ 25840{
25770 Lisp_Object window; 25841 Lisp_Object window;
25771 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 25842 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
25772 25843
25773 window = dpyinfo->mouse_face_window; 25844 window = hlinfo->mouse_face_window;
25774 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f) 25845 if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f)
25775 { 25846 {
25776 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 25847 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
25777 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 25848 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
25778 dpyinfo->mouse_face_window = Qnil; 25849 hlinfo->mouse_face_window = Qnil;
25779 } 25850 }
25780} 25851}
25781 25852
25782 25853
25783#endif /* HAVE_WINDOW_SYSTEM */
25784
25785 25854
25786/*********************************************************************** 25855/***********************************************************************
25787 Exposure Events 25856 Exposure Events
@@ -26238,12 +26307,12 @@ expose_frame (struct frame *f, int x, int y, int w, int h)
26238 focus-follows-mouse with delayed raise. --jason 2001-10-12 */ 26307 focus-follows-mouse with delayed raise. --jason 2001-10-12 */
26239 if (mouse_face_overwritten_p && !FRAME_GARBAGED_P (f)) 26308 if (mouse_face_overwritten_p && !FRAME_GARBAGED_P (f))
26240 { 26309 {
26241 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 26310 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
26242 if (f == dpyinfo->mouse_face_mouse_frame) 26311 if (f == hlinfo->mouse_face_mouse_frame)
26243 { 26312 {
26244 int x = dpyinfo->mouse_face_mouse_x; 26313 int x = hlinfo->mouse_face_mouse_x;
26245 int y = dpyinfo->mouse_face_mouse_y; 26314 int y = hlinfo->mouse_face_mouse_y;
26246 clear_mouse_face (dpyinfo); 26315 clear_mouse_face (hlinfo);
26247 note_mouse_highlight (f, x, y); 26316 note_mouse_highlight (f, x, y);
26248 } 26317 }
26249 } 26318 }
diff --git a/src/xmenu.c b/src/xmenu.c
index 60b1c2b4595..44f1721d65e 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -2533,13 +2533,16 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
2533 2533
2534#endif /* HAVE_MENUS */ 2534#endif /* HAVE_MENUS */
2535 2535
2536/* Detect if a dialog or menu has been posted. */ 2536#ifndef MSDOS
2537/* Detect if a dialog or menu has been posted. MSDOS has its own
2538 implementation on msdos.c. */
2537 2539
2538int 2540int
2539popup_activated (void) 2541popup_activated (void)
2540{ 2542{
2541 return popup_activated_flag; 2543 return popup_activated_flag;
2542} 2544}
2545#endif /* not MSDOS */
2543 2546
2544/* The following is used by delayed window autoselection. */ 2547/* The following is used by delayed window autoselection. */
2545 2548
diff --git a/src/xterm.c b/src/xterm.c
index 463ea8b7dc2..7297ee71f0f 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -548,22 +548,22 @@ static void
548x_update_window_begin (struct window *w) 548x_update_window_begin (struct window *w)
549{ 549{
550 struct frame *f = XFRAME (WINDOW_FRAME (w)); 550 struct frame *f = XFRAME (WINDOW_FRAME (w));
551 struct x_display_info *display_info = FRAME_X_DISPLAY_INFO (f); 551 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
552 552
553 updated_window = w; 553 updated_window = w;
554 set_output_cursor (&w->cursor); 554 set_output_cursor (&w->cursor);
555 555
556 BLOCK_INPUT; 556 BLOCK_INPUT;
557 557
558 if (f == display_info->mouse_face_mouse_frame) 558 if (f == hlinfo->mouse_face_mouse_frame)
559 { 559 {
560 /* Don't do highlighting for mouse motion during the update. */ 560 /* Don't do highlighting for mouse motion during the update. */
561 display_info->mouse_face_defer = 1; 561 hlinfo->mouse_face_defer = 1;
562 562
563 /* If F needs to be redrawn, simply forget about any prior mouse 563 /* If F needs to be redrawn, simply forget about any prior mouse
564 highlighting. */ 564 highlighting. */
565 if (FRAME_GARBAGED_P (f)) 565 if (FRAME_GARBAGED_P (f))
566 display_info->mouse_face_window = Qnil; 566 hlinfo->mouse_face_window = Qnil;
567 } 567 }
568 568
569 UNBLOCK_INPUT; 569 UNBLOCK_INPUT;
@@ -603,7 +603,7 @@ x_draw_vertical_window_border (struct window *w, int x, int y0, int y1)
603static void 603static void
604x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p) 604x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritten_p)
605{ 605{
606 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); 606 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
607 607
608 if (!w->pseudo_window_p) 608 if (!w->pseudo_window_p)
609 { 609 {
@@ -624,9 +624,9 @@ x_update_window_end (struct window *w, int cursor_on_p, int mouse_face_overwritt
624 XTframe_up_to_date to redisplay the mouse highlight. */ 624 XTframe_up_to_date to redisplay the mouse highlight. */
625 if (mouse_face_overwritten_p) 625 if (mouse_face_overwritten_p)
626 { 626 {
627 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 627 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
628 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 628 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
629 dpyinfo->mouse_face_window = Qnil; 629 hlinfo->mouse_face_window = Qnil;
630 } 630 }
631 631
632 updated_window = NULL; 632 updated_window = NULL;
@@ -640,7 +640,7 @@ static void
640x_update_end (struct frame *f) 640x_update_end (struct frame *f)
641{ 641{
642 /* Mouse highlight may be displayed again. */ 642 /* Mouse highlight may be displayed again. */
643 FRAME_X_DISPLAY_INFO (f)->mouse_face_defer = 0; 643 MOUSE_HL_INFO (f)->mouse_face_defer = 0;
644 644
645#ifndef XFlush 645#ifndef XFlush
646 BLOCK_INPUT; 646 BLOCK_INPUT;
@@ -659,17 +659,17 @@ XTframe_up_to_date (struct frame *f)
659{ 659{
660 if (FRAME_X_P (f)) 660 if (FRAME_X_P (f))
661 { 661 {
662 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 662 Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
663 663
664 if (dpyinfo->mouse_face_deferred_gc 664 if (hlinfo->mouse_face_deferred_gc
665 || f == dpyinfo->mouse_face_mouse_frame) 665 || f == hlinfo->mouse_face_mouse_frame)
666 { 666 {
667 BLOCK_INPUT; 667 BLOCK_INPUT;
668 if (dpyinfo->mouse_face_mouse_frame) 668 if (hlinfo->mouse_face_mouse_frame)
669 note_mouse_highlight (dpyinfo->mouse_face_mouse_frame, 669 note_mouse_highlight (hlinfo->mouse_face_mouse_frame,
670 dpyinfo->mouse_face_mouse_x, 670 hlinfo->mouse_face_mouse_x,
671 dpyinfo->mouse_face_mouse_y); 671 hlinfo->mouse_face_mouse_y);
672 dpyinfo->mouse_face_deferred_gc = 0; 672 hlinfo->mouse_face_deferred_gc = 0;
673 UNBLOCK_INPUT; 673 UNBLOCK_INPUT;
674 } 674 }
675 } 675 }
@@ -970,7 +970,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
970 struct face *face; 970 struct face *face;
971 971
972 /* What face has to be used last for the mouse face? */ 972 /* What face has to be used last for the mouse face? */
973 face_id = FRAME_X_DISPLAY_INFO (s->f)->mouse_face_face_id; 973 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
974 face = FACE_FROM_ID (s->f, face_id); 974 face = FACE_FROM_ID (s->f, face_id);
975 if (face == NULL) 975 if (face == NULL)
976 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID); 976 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
@@ -5788,6 +5788,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
5788 struct frame *f = NULL; 5788 struct frame *f = NULL;
5789 struct coding_system coding; 5789 struct coding_system coding;
5790 XEvent event = *eventp; 5790 XEvent event = *eventp;
5791 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
5791 5792
5792 *finish = X_EVENT_NORMAL; 5793 *finish = X_EVENT_NORMAL;
5793 5794
@@ -6237,12 +6238,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6237 6238
6238 /* If mouse-highlight is an integer, input clears out 6239 /* If mouse-highlight is an integer, input clears out
6239 mouse highlighting. */ 6240 mouse highlighting. */
6240 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight) 6241 if (!hlinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
6241 && (f == 0 6242 && (f == 0
6242 || !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))) 6243 || !EQ (f->tool_bar_window, hlinfo->mouse_face_window)))
6243 { 6244 {
6244 clear_mouse_face (dpyinfo); 6245 clear_mouse_face (hlinfo);
6245 dpyinfo->mouse_face_hidden = 1; 6246 hlinfo->mouse_face_hidden = 1;
6246 } 6247 }
6247 6248
6248#if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS 6249#if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS
@@ -6599,12 +6600,12 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6599 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window); 6600 f = x_top_window_to_frame (dpyinfo, event.xcrossing.window);
6600 if (f) 6601 if (f)
6601 { 6602 {
6602 if (f == dpyinfo->mouse_face_mouse_frame) 6603 if (f == hlinfo->mouse_face_mouse_frame)
6603 { 6604 {
6604 /* If we move outside the frame, then we're 6605 /* If we move outside the frame, then we're
6605 certainly no longer on any text in the frame. */ 6606 certainly no longer on any text in the frame. */
6606 clear_mouse_face (dpyinfo); 6607 clear_mouse_face (hlinfo);
6607 dpyinfo->mouse_face_mouse_frame = 0; 6608 hlinfo->mouse_face_mouse_frame = 0;
6608 } 6609 }
6609 6610
6610 /* Generate a nil HELP_EVENT to cancel a help-echo. 6611 /* Generate a nil HELP_EVENT to cancel a help-echo.
@@ -6637,10 +6638,10 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6637 else 6638 else
6638 f = x_window_to_frame (dpyinfo, event.xmotion.window); 6639 f = x_window_to_frame (dpyinfo, event.xmotion.window);
6639 6640
6640 if (dpyinfo->mouse_face_hidden) 6641 if (hlinfo->mouse_face_hidden)
6641 { 6642 {
6642 dpyinfo->mouse_face_hidden = 0; 6643 hlinfo->mouse_face_hidden = 0;
6643 clear_mouse_face (dpyinfo); 6644 clear_mouse_face (hlinfo);
6644 } 6645 }
6645 6646
6646#ifdef USE_GTK 6647#ifdef USE_GTK
@@ -6695,7 +6696,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, XEvent *eventp, int *finish,
6695 6696
6696 /* If we move outside the frame, then we're 6697 /* If we move outside the frame, then we're
6697 certainly no longer on any text in the frame. */ 6698 certainly no longer on any text in the frame. */
6698 clear_mouse_face (dpyinfo); 6699 clear_mouse_face (hlinfo);
6699 } 6700 }
6700 6701
6701 /* If the contents of the global variable help_echo_string 6702 /* If the contents of the global variable help_echo_string
@@ -9385,6 +9386,7 @@ x_free_frame_resources (struct frame *f)
9385 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f); 9386 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
9386 Lisp_Object bar; 9387 Lisp_Object bar;
9387 struct scroll_bar *b; 9388 struct scroll_bar *b;
9389 Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight;
9388 9390
9389 BLOCK_INPUT; 9391 BLOCK_INPUT;
9390 9392
@@ -9478,15 +9480,15 @@ x_free_frame_resources (struct frame *f)
9478 if (f == dpyinfo->x_highlight_frame) 9480 if (f == dpyinfo->x_highlight_frame)
9479 dpyinfo->x_highlight_frame = 0; 9481 dpyinfo->x_highlight_frame = 0;
9480 9482
9481 if (f == dpyinfo->mouse_face_mouse_frame) 9483 if (f == hlinfo->mouse_face_mouse_frame)
9482 { 9484 {
9483 dpyinfo->mouse_face_beg_row 9485 hlinfo->mouse_face_beg_row
9484 = dpyinfo->mouse_face_beg_col = -1; 9486 = hlinfo->mouse_face_beg_col = -1;
9485 dpyinfo->mouse_face_end_row 9487 hlinfo->mouse_face_end_row
9486 = dpyinfo->mouse_face_end_col = -1; 9488 = hlinfo->mouse_face_end_col = -1;
9487 dpyinfo->mouse_face_window = Qnil; 9489 hlinfo->mouse_face_window = Qnil;
9488 dpyinfo->mouse_face_deferred_gc = 0; 9490 hlinfo->mouse_face_deferred_gc = 0;
9489 dpyinfo->mouse_face_mouse_frame = 0; 9491 hlinfo->mouse_face_mouse_frame = 0;
9490 } 9492 }
9491 9493
9492 UNBLOCK_INPUT; 9494 UNBLOCK_INPUT;
@@ -9863,6 +9865,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9863 struct terminal *terminal; 9865 struct terminal *terminal;
9864 struct x_display_info *dpyinfo; 9866 struct x_display_info *dpyinfo;
9865 XrmDatabase xrdb; 9867 XrmDatabase xrdb;
9868 Mouse_HLInfo *hlinfo;
9866 9869
9867 BLOCK_INPUT; 9870 BLOCK_INPUT;
9868 9871
@@ -9993,6 +9996,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9993 9996
9994 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info)); 9997 dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
9995 memset (dpyinfo, 0, sizeof *dpyinfo); 9998 memset (dpyinfo, 0, sizeof *dpyinfo);
9999 hlinfo = &dpyinfo->mouse_highlight;
9996 10000
9997 terminal = x_create_terminal (dpyinfo); 10001 terminal = x_create_terminal (dpyinfo);
9998 10002
@@ -10115,16 +10119,16 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
10115 dpyinfo->bitmaps_size = 0; 10119 dpyinfo->bitmaps_size = 0;
10116 dpyinfo->bitmaps_last = 0; 10120 dpyinfo->bitmaps_last = 0;
10117 dpyinfo->scratch_cursor_gc = 0; 10121 dpyinfo->scratch_cursor_gc = 0;
10118 dpyinfo->mouse_face_mouse_frame = 0; 10122 hlinfo->mouse_face_mouse_frame = 0;
10119 dpyinfo->mouse_face_deferred_gc = 0; 10123 hlinfo->mouse_face_deferred_gc = 0;
10120 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 10124 hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
10121 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 10125 hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
10122 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; 10126 hlinfo->mouse_face_face_id = DEFAULT_FACE_ID;
10123 dpyinfo->mouse_face_window = Qnil; 10127 hlinfo->mouse_face_window = Qnil;
10124 dpyinfo->mouse_face_overlay = Qnil; 10128 hlinfo->mouse_face_overlay = Qnil;
10125 dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0; 10129 hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0;
10126 dpyinfo->mouse_face_defer = 0; 10130 hlinfo->mouse_face_defer = 0;
10127 dpyinfo->mouse_face_hidden = 0; 10131 hlinfo->mouse_face_hidden = 0;
10128 dpyinfo->x_focus_frame = 0; 10132 dpyinfo->x_focus_frame = 0;
10129 dpyinfo->x_focus_event_frame = 0; 10133 dpyinfo->x_focus_event_frame = 0;
10130 dpyinfo->x_highlight_frame = 0; 10134 dpyinfo->x_highlight_frame = 0;
diff --git a/src/xterm.h b/src/xterm.h
index d884945f985..ec99a659b8e 100644
--- a/src/xterm.h
+++ b/src/xterm.h
@@ -190,36 +190,9 @@ struct x_display_info
190 /* Reusable Graphics Context for drawing a cursor in a non-default face. */ 190 /* Reusable Graphics Context for drawing a cursor in a non-default face. */
191 GC scratch_cursor_gc; 191 GC scratch_cursor_gc;
192 192
193 /* These variables describe the range of text currently shown in its 193 /* Information about the range of text currently shown in
194 mouse-face, together with the window they apply to. As long as 194 mouse-face. */
195 the mouse stays within this range, we need not redraw anything on 195 Mouse_HLInfo mouse_highlight;
196 its account. Rows and columns are glyph matrix positions in
197 MOUSE_FACE_WINDOW. */
198 int mouse_face_beg_row, mouse_face_beg_col;
199 int mouse_face_beg_x, mouse_face_beg_y;
200 int mouse_face_end_row, mouse_face_end_col;
201 int mouse_face_end_x, mouse_face_end_y;
202 int mouse_face_past_end;
203 Lisp_Object mouse_face_window;
204 int mouse_face_face_id;
205 Lisp_Object mouse_face_overlay;
206
207 /* 1 if a mouse motion event came and we didn't handle it right away because
208 gc was in progress. */
209 int mouse_face_deferred_gc;
210
211 /* FRAME and X, Y position of mouse when last checked for
212 highlighting. X and Y can be negative or out of range for the frame. */
213 struct frame *mouse_face_mouse_frame;
214 int mouse_face_mouse_x, mouse_face_mouse_y;
215
216 /* Nonzero means defer mouse-motion highlighting. */
217 int mouse_face_defer;
218
219 /* Nonzero means that the mouse highlight should not be shown. */
220 int mouse_face_hidden;
221
222 int mouse_face_image_state;
223 196
224 char *x_id_name; 197 char *x_id_name;
225 198