aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChong Yidong2008-05-27 03:11:39 +0000
committerChong Yidong2008-05-27 03:11:39 +0000
commit44acf81e889fdd29bd3665c08c311a74244dcda3 (patch)
tree27ed454f54250dd41e94075608f4d3c7b771635b /src
parent7385fe74a1bf48ca92d97762a861c762ef8e1125 (diff)
downloademacs-44acf81e889fdd29bd3665c08c311a74244dcda3.tar.gz
emacs-44acf81e889fdd29bd3665c08c311a74244dcda3.zip
(draw_glyphs): If mouse-highlighting is on, attempt to draw overlap
glyphs with appropriate highlighting.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c92
1 files changed, 73 insertions, 19 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 83e84861425..39940ec3f56 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -19887,9 +19887,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19887 struct glyph_string *head, *tail; 19887 struct glyph_string *head, *tail;
19888 struct glyph_string *s; 19888 struct glyph_string *s;
19889 struct glyph_string *clip_head = NULL, *clip_tail = NULL; 19889 struct glyph_string *clip_head = NULL, *clip_tail = NULL;
19890 int last_x, area_width; 19890 int i, j, x_reached, last_x, area_left = 0;
19891 int x_reached;
19892 int i, j;
19893 struct frame *f = XFRAME (WINDOW_FRAME (w)); 19891 struct frame *f = XFRAME (WINDOW_FRAME (w));
19894 DECLARE_HDC (hdc); 19892 DECLARE_HDC (hdc);
19895 19893
@@ -19906,16 +19904,15 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19906 { 19904 {
19907 /* X is relative to the left edge of W, without scroll bars 19905 /* X is relative to the left edge of W, without scroll bars
19908 or fringes. */ 19906 or fringes. */
19909 x += WINDOW_LEFT_EDGE_X (w); 19907 area_left = WINDOW_LEFT_EDGE_X (w);
19910 last_x = WINDOW_LEFT_EDGE_X (w) + WINDOW_TOTAL_WIDTH (w); 19908 last_x = WINDOW_LEFT_EDGE_X (w) + WINDOW_TOTAL_WIDTH (w);
19911 } 19909 }
19912 else 19910 else
19913 { 19911 {
19914 int area_left = window_box_left (w, area); 19912 area_left = window_box_left (w, area);
19915 x += area_left; 19913 last_x = area_left + window_box_width (w, area);
19916 area_width = window_box_width (w, area);
19917 last_x = area_left + area_width;
19918 } 19914 }
19915 x += area_left;
19919 19916
19920 /* Build a doubly-linked list of glyph_string structures between 19917 /* Build a doubly-linked list of glyph_string structures between
19921 head and tail from what we have to draw. Note that the macro 19918 head and tail from what we have to draw. Note that the macro
@@ -19933,8 +19930,30 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19933 strings built above. */ 19930 strings built above. */
19934 if (head && !overlaps && row->contains_overlapping_glyphs_p) 19931 if (head && !overlaps && row->contains_overlapping_glyphs_p)
19935 { 19932 {
19936 int dummy_x = 0;
19937 struct glyph_string *h, *t; 19933 struct glyph_string *h, *t;
19934 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
19935 int mouse_beg_col, mouse_end_col, check_mouse_face = 0;
19936 int dummy_x = 0;
19937
19938 /* If mouse highlighting is on, we may need to draw adjacent
19939 glyphs using mouse-face highlighting. */
19940 if (area == TEXT_AREA && row->mouse_face_p)
19941 {
19942 struct glyph_row *mouse_beg_row, *mouse_end_row;
19943
19944 mouse_beg_row = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
19945 mouse_end_row = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
19946
19947 if (row >= mouse_beg_row && row <= mouse_end_row)
19948 {
19949 check_mouse_face = 1;
19950 mouse_beg_col = (row == mouse_beg_row)
19951 ? dpyinfo->mouse_face_beg_col : 0;
19952 mouse_end_col = (row == mouse_end_row)
19953 ? dpyinfo->mouse_face_end_col
19954 : row->used[TEXT_AREA];
19955 }
19956 }
19938 19957
19939 /* Compute overhangs for all glyph strings. */ 19958 /* Compute overhangs for all glyph strings. */
19940 if (FRAME_RIF (f)->compute_glyph_string_overhangs) 19959 if (FRAME_RIF (f)->compute_glyph_string_overhangs)
@@ -19949,10 +19968,24 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19949 i = left_overwritten (head); 19968 i = left_overwritten (head);
19950 if (i >= 0) 19969 if (i >= 0)
19951 { 19970 {
19971 enum draw_glyphs_face overlap_hl;
19972
19973 /* If this row contains mouse highlighting, attempt to draw
19974 the overlapped glyphs with the correct highlight. This
19975 code fails if the overlap encompasses more than one glyph
19976 and mouse-highlight spans only some of these glyphs.
19977 However, making it work perfectly involves a lot more
19978 code, and I don't know if the pathological case occurs in
19979 practice, so we'll stick to this for now. --- cyd */
19980 if (check_mouse_face
19981 && mouse_beg_col < start && mouse_end_col > i)
19982 overlap_hl = DRAW_MOUSE_FACE;
19983 else
19984 overlap_hl = DRAW_NORMAL_TEXT;
19985
19952 j = i; 19986 j = i;
19953 BUILD_GLYPH_STRINGS (j, start, h, t, 19987 BUILD_GLYPH_STRINGS (j, start, h, t,
19954 DRAW_NORMAL_TEXT, dummy_x, last_x); 19988 overlap_hl, dummy_x, last_x);
19955 start = i;
19956 compute_overhangs_and_x (t, head->x, 1); 19989 compute_overhangs_and_x (t, head->x, 1);
19957 prepend_glyph_string_lists (&head, &tail, h, t); 19990 prepend_glyph_string_lists (&head, &tail, h, t);
19958 clip_head = head; 19991 clip_head = head;
@@ -19968,9 +20001,17 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19968 i = left_overwriting (head); 20001 i = left_overwriting (head);
19969 if (i >= 0) 20002 if (i >= 0)
19970 { 20003 {
20004 enum draw_glyphs_face overlap_hl;
20005
20006 if (check_mouse_face
20007 && mouse_beg_col < start && mouse_end_col > i)
20008 overlap_hl = DRAW_MOUSE_FACE;
20009 else
20010 overlap_hl = DRAW_NORMAL_TEXT;
20011
19971 clip_head = head; 20012 clip_head = head;
19972 BUILD_GLYPH_STRINGS (i, start, h, t, 20013 BUILD_GLYPH_STRINGS (i, start, h, t,
19973 DRAW_NORMAL_TEXT, dummy_x, last_x); 20014 overlap_hl, dummy_x, last_x);
19974 for (s = h; s; s = s->next) 20015 for (s = h; s; s = s->next)
19975 s->background_filled_p = 1; 20016 s->background_filled_p = 1;
19976 compute_overhangs_and_x (t, head->x, 1); 20017 compute_overhangs_and_x (t, head->x, 1);
@@ -19984,8 +20025,16 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19984 i = right_overwritten (tail); 20025 i = right_overwritten (tail);
19985 if (i >= 0) 20026 if (i >= 0)
19986 { 20027 {
20028 enum draw_glyphs_face overlap_hl;
20029
20030 if (check_mouse_face
20031 && mouse_beg_col < i && mouse_end_col > end)
20032 overlap_hl = DRAW_MOUSE_FACE;
20033 else
20034 overlap_hl = DRAW_NORMAL_TEXT;
20035
19987 BUILD_GLYPH_STRINGS (end, i, h, t, 20036 BUILD_GLYPH_STRINGS (end, i, h, t,
19988 DRAW_NORMAL_TEXT, x, last_x); 20037 overlap_hl, x, last_x);
19989 compute_overhangs_and_x (h, tail->x + tail->width, 0); 20038 compute_overhangs_and_x (h, tail->x + tail->width, 0);
19990 append_glyph_string_lists (&head, &tail, h, t); 20039 append_glyph_string_lists (&head, &tail, h, t);
19991 clip_tail = tail; 20040 clip_tail = tail;
@@ -19999,10 +20048,17 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
19999 i = right_overwriting (tail); 20048 i = right_overwriting (tail);
20000 if (i >= 0) 20049 if (i >= 0)
20001 { 20050 {
20051 enum draw_glyphs_face overlap_hl;
20052 if (check_mouse_face
20053 && mouse_beg_col < i && mouse_end_col > end)
20054 overlap_hl = DRAW_MOUSE_FACE;
20055 else
20056 overlap_hl = DRAW_NORMAL_TEXT;
20057
20002 clip_tail = tail; 20058 clip_tail = tail;
20003 i++; /* We must include the Ith glyph. */ 20059 i++; /* We must include the Ith glyph. */
20004 BUILD_GLYPH_STRINGS (end, i, h, t, 20060 BUILD_GLYPH_STRINGS (end, i, h, t,
20005 DRAW_NORMAL_TEXT, x, last_x); 20061 overlap_hl, x, last_x);
20006 for (s = h; s; s = s->next) 20062 for (s = h; s; s = s->next)
20007 s->background_filled_p = 1; 20063 s->background_filled_p = 1;
20008 compute_overhangs_and_x (h, tail->x + tail->width, 0); 20064 compute_overhangs_and_x (h, tail->x + tail->width, 0);
@@ -20030,10 +20086,8 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
20030 int x0 = clip_head ? clip_head->x : (head ? head->x : x); 20086 int x0 = clip_head ? clip_head->x : (head ? head->x : x);
20031 int x1 = (clip_tail ? clip_tail->x + clip_tail->background_width 20087 int x1 = (clip_tail ? clip_tail->x + clip_tail->background_width
20032 : (tail ? tail->x + tail->background_width : x)); 20088 : (tail ? tail->x + tail->background_width : x));
20033 20089 x0 -= area_left;
20034 int text_left = window_box_left (w, TEXT_AREA); 20090 x1 -= area_left;
20035 x0 -= text_left;
20036 x1 -= text_left;
20037 20091
20038 notice_overwritten_cursor (w, TEXT_AREA, x0, x1, 20092 notice_overwritten_cursor (w, TEXT_AREA, x0, x1,
20039 row->y, MATRIX_ROW_BOTTOM_Y (row)); 20093 row->y, MATRIX_ROW_BOTTOM_Y (row));
@@ -20044,7 +20098,7 @@ draw_glyphs (w, x, row, area, start, end, hl, overlaps)
20044 if (row->full_width_p) 20098 if (row->full_width_p)
20045 x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached); 20099 x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached);
20046 else 20100 else
20047 x_reached -= window_box_left (w, area); 20101 x_reached -= area_left;
20048 20102
20049 RELEASE_HDC (hdc, f); 20103 RELEASE_HDC (hdc, f);
20050 20104