aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2010-08-28 18:23:10 +0300
committerEli Zaretskii2010-08-28 18:23:10 +0300
commit1b5a721bd5135792fface8df3849c3c42d4ca2c5 (patch)
tree5d7fd26cdc3318f85125581215c4c6eb2e019ecf /src
parent1554d88e5ba8f6365f38bc2a2e4f7ca778c54868 (diff)
downloademacs-1b5a721bd5135792fface8df3849c3c42d4ca2c5.tar.gz
emacs-1b5a721bd5135792fface8df3849c3c42d4ca2c5.zip
Clean up mouse highlight in R2L lines.
xdisp.c (coords_in_mouse_face_p): New function, bidi-aware. (cursor_in_mouse_face_p, note_mouse_highlight, erase_phys_cursor): Call it instead of comparing with mouse-face members of dpyinfo. (note_mode_line_or_margin_highlight): Fix confusingly swapped usage of hpos and vpos.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/xdisp.c93
2 files changed, 54 insertions, 44 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index ee13b6a4b35..b846070b922 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -4,6 +4,11 @@
4 test case. Implement highlight for R2L rows. Fix the case of 4 test case. Implement highlight for R2L rows. Fix the case of
5 continued L2R lines. 5 continued L2R lines.
6 (show_mouse_face): Support drawing highlighted R2L lines. 6 (show_mouse_face): Support drawing highlighted R2L lines.
7 (coords_in_mouse_face_p): New function, bidi-aware.
8 (cursor_in_mouse_face_p, note_mouse_highlight, erase_phys_cursor):
9 Call it instead of comparing with mouse-face members of dpyinfo.
10 (note_mode_line_or_margin_highlight): Fix confusingly swapped
11 usage of hpos and vpos.
7 12
82010-08-21 Eli Zaretskii <eliz@gnu.org> 132010-08-21 Eli Zaretskii <eliz@gnu.org>
9 14
diff --git a/src/xdisp.c b/src/xdisp.c
index 3a99435123a..40ba72a18bc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1082,6 +1082,7 @@ static void notice_overwritten_cursor (struct window *,
1082 int, int, int, int); 1082 int, int, int, int);
1083static void append_stretch_glyph (struct it *, Lisp_Object, 1083static void append_stretch_glyph (struct it *, Lisp_Object,
1084 int, int, int); 1084 int, int, int);
1085static int coords_in_mouse_face_p (struct window *, int, int);
1085 1086
1086 1087
1087 1088
@@ -23482,13 +23483,7 @@ erase_phys_cursor (struct window *w)
23482 /* If the cursor is in the mouse face area, redisplay that when 23483 /* If the cursor is in the mouse face area, redisplay that when
23483 we clear the cursor. */ 23484 we clear the cursor. */
23484 if (! NILP (dpyinfo->mouse_face_window) 23485 if (! NILP (dpyinfo->mouse_face_window)
23485 && w == XWINDOW (dpyinfo->mouse_face_window) 23486 && coords_in_mouse_face_p (w, hpos, vpos)
23486 && (vpos > dpyinfo->mouse_face_beg_row
23487 || (vpos == dpyinfo->mouse_face_beg_row
23488 && hpos >= dpyinfo->mouse_face_beg_col))
23489 && (vpos < dpyinfo->mouse_face_end_row
23490 || (vpos == dpyinfo->mouse_face_end_row
23491 && hpos < dpyinfo->mouse_face_end_col))
23492 /* Don't redraw the cursor's spot in mouse face if it is at the 23487 /* Don't redraw the cursor's spot in mouse face if it is at the
23493 end of a line (on a newline). The cursor appears there, but 23488 end of a line (on a newline). The cursor appears there, but
23494 mouse highlighting does not. */ 23489 mouse highlighting does not. */
@@ -23819,6 +23814,43 @@ clear_mouse_face (Display_Info *dpyinfo)
23819 return cleared; 23814 return cleared;
23820} 23815}
23821 23816
23817/* Return non-zero if the coordinates HPOS and VPOS on windows W are
23818 within the mouse face on that window. */
23819static int
23820coords_in_mouse_face_p (struct window *w, int hpos, int vpos)
23821{
23822 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame));
23823
23824 /* Quickly resolve the easy cases. */
23825 if (!(WINDOWP (dpyinfo->mouse_face_window)
23826 && XWINDOW (dpyinfo->mouse_face_window) == w))
23827 return 0;
23828 if (vpos < dpyinfo->mouse_face_beg_row
23829 || vpos > dpyinfo->mouse_face_end_row)
23830 return 0;
23831 if (vpos > dpyinfo->mouse_face_beg_row
23832 && vpos < dpyinfo->mouse_face_end_row)
23833 return 1;
23834
23835 if (MATRIX_ROW (w->current_matrix, vpos)->reversed_p)
23836 {
23837 if ((vpos == dpyinfo->mouse_face_beg_row
23838 && hpos <= dpyinfo->mouse_face_beg_col)
23839 || (vpos == dpyinfo->mouse_face_end_row
23840 && hpos > dpyinfo->mouse_face_end_col))
23841 return 1;
23842 }
23843 else
23844 {
23845 if ((vpos == dpyinfo->mouse_face_beg_row
23846 && hpos >= dpyinfo->mouse_face_beg_col)
23847 || (vpos == dpyinfo->mouse_face_end_row
23848 && hpos < dpyinfo->mouse_face_end_col))
23849 return 1;
23850 }
23851 return 0;
23852}
23853
23822 23854
23823/* EXPORT: 23855/* EXPORT:
23824 Non-zero if physical cursor of window W is within mouse face. */ 23856 Non-zero if physical cursor of window W is within mouse face. */
@@ -23826,30 +23858,10 @@ clear_mouse_face (Display_Info *dpyinfo)
23826int 23858int
23827cursor_in_mouse_face_p (struct window *w) 23859cursor_in_mouse_face_p (struct window *w)
23828{ 23860{
23829 Display_Info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); 23861 return coords_in_mouse_face_p (w, w->phys_cursor.hpos, w->phys_cursor.vpos);
23830 int in_mouse_face = 0;
23831
23832 if (WINDOWP (dpyinfo->mouse_face_window)
23833 && XWINDOW (dpyinfo->mouse_face_window) == w)
23834 {
23835 int hpos = w->phys_cursor.hpos;
23836 int vpos = w->phys_cursor.vpos;
23837
23838 if (vpos >= dpyinfo->mouse_face_beg_row
23839 && vpos <= dpyinfo->mouse_face_end_row
23840 && (vpos > dpyinfo->mouse_face_beg_row
23841 || hpos >= dpyinfo->mouse_face_beg_col)
23842 && (vpos < dpyinfo->mouse_face_end_row
23843 || hpos < dpyinfo->mouse_face_end_col
23844 || dpyinfo->mouse_face_past_end))
23845 in_mouse_face = 1;
23846 }
23847
23848 return in_mouse_face;
23849} 23862}
23850 23863
23851 23864
23852
23853 23865
23854/* This function sets the mouse_face_* elements of DPYINFO, assuming 23866/* This function sets the mouse_face_* elements of DPYINFO, assuming
23855 the mouse cursor is on a glyph with buffer charpos MOUSE_CHARPOS in 23867 the mouse cursor is on a glyph with buffer charpos MOUSE_CHARPOS in
@@ -24632,29 +24644,29 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y,
24632 total_pixel_width += tmp_glyph->pixel_width; 24644 total_pixel_width += tmp_glyph->pixel_width;
24633 24645
24634 /* Pre calculation of re-rendering position */ 24646 /* Pre calculation of re-rendering position */
24635 vpos = (x - gpos); 24647 hpos = (x - gpos);
24636 hpos = (area == ON_MODE_LINE 24648 vpos = (area == ON_MODE_LINE
24637 ? (w->current_matrix)->nrows - 1 24649 ? (w->current_matrix)->nrows - 1
24638 : 0); 24650 : 0);
24639 24651
24640 /* If the re-rendering position is included in the last 24652 /* If the re-rendering position is included in the last
24641 re-rendering area, we should do nothing. */ 24653 re-rendering area, we should do nothing. */
24642 if ( EQ (window, dpyinfo->mouse_face_window) 24654 if ( EQ (window, dpyinfo->mouse_face_window)
24643 && dpyinfo->mouse_face_beg_col <= vpos 24655 && dpyinfo->mouse_face_beg_col <= hpos
24644 && vpos < dpyinfo->mouse_face_end_col 24656 && hpos < dpyinfo->mouse_face_end_col
24645 && dpyinfo->mouse_face_beg_row == hpos ) 24657 && dpyinfo->mouse_face_beg_row == vpos )
24646 return; 24658 return;
24647 24659
24648 if (clear_mouse_face (dpyinfo)) 24660 if (clear_mouse_face (dpyinfo))
24649 cursor = No_Cursor; 24661 cursor = No_Cursor;
24650 24662
24651 dpyinfo->mouse_face_beg_col = vpos; 24663 dpyinfo->mouse_face_beg_col = hpos;
24652 dpyinfo->mouse_face_beg_row = hpos; 24664 dpyinfo->mouse_face_beg_row = vpos;
24653 24665
24654 dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx); 24666 dpyinfo->mouse_face_beg_x = original_x_pixel - (total_pixel_width + dx);
24655 dpyinfo->mouse_face_beg_y = 0; 24667 dpyinfo->mouse_face_beg_y = 0;
24656 24668
24657 dpyinfo->mouse_face_end_col = vpos + gseq_length; 24669 dpyinfo->mouse_face_end_col = hpos + gseq_length;
24658 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row; 24670 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_beg_row;
24659 24671
24660 dpyinfo->mouse_face_end_x = 0; 24672 dpyinfo->mouse_face_end_x = 0;
@@ -24879,14 +24891,7 @@ note_mouse_highlight (struct frame *f, int x, int y)
24879 else 24891 else
24880 noverlays = 0; 24892 noverlays = 0;
24881 24893
24882 same_region = (EQ (window, dpyinfo->mouse_face_window) 24894 same_region = coords_in_mouse_face_p (w, hpos, vpos);
24883 && vpos >= dpyinfo->mouse_face_beg_row
24884 && vpos <= dpyinfo->mouse_face_end_row
24885 && (vpos > dpyinfo->mouse_face_beg_row
24886 || hpos >= dpyinfo->mouse_face_beg_col)
24887 && (vpos < dpyinfo->mouse_face_end_row
24888 || hpos < dpyinfo->mouse_face_end_col
24889 || dpyinfo->mouse_face_past_end));
24890 24895
24891 if (same_region) 24896 if (same_region)
24892 cursor = No_Cursor; 24897 cursor = No_Cursor;