diff options
| author | Gerd Moellmann | 2001-05-28 13:42:21 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-05-28 13:42:21 +0000 |
| commit | b7f83f9ed3d1857b25aabb6ed0ea542c24dbce01 (patch) | |
| tree | d1de6cc0620416bc3f74db380a9b725f54eaa39d /src | |
| parent | 3db6f8cad4d4dc0fc29662ed86f806e56429597e (diff) | |
| download | emacs-b7f83f9ed3d1857b25aabb6ed0ea542c24dbce01.tar.gz emacs-b7f83f9ed3d1857b25aabb6ed0ea542c24dbce01.zip | |
(cursor_in_mouse_face_p): New function.
(x_draw_stretch_glyph_string): Use it to choose a different GC
when drawing a cursor within highlighted text.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xterm.c | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/xterm.c b/src/xterm.c index 3dfe0fac2aa..394b75cfe6c 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -399,6 +399,7 @@ enum draw_glyphs_face | |||
| 399 | DRAW_IMAGE_SUNKEN | 399 | DRAW_IMAGE_SUNKEN |
| 400 | }; | 400 | }; |
| 401 | 401 | ||
| 402 | static int cursor_in_mouse_face_p P_ ((struct window *)); | ||
| 402 | static int clear_mouse_face P_ ((struct x_display_info *)); | 403 | static int clear_mouse_face P_ ((struct x_display_info *)); |
| 403 | static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *)); | 404 | static int x_alloc_nearest_color_1 P_ ((Display *, Colormap, XColor *)); |
| 404 | static void x_set_window_size_1 P_ ((struct frame *, int, int, int)); | 405 | static void x_set_window_size_1 P_ ((struct frame *, int, int, int)); |
| @@ -4384,14 +4385,23 @@ x_draw_stretch_glyph_string (s) | |||
| 4384 | /* Clear rest using the GC of the original non-cursor face. */ | 4385 | /* Clear rest using the GC of the original non-cursor face. */ |
| 4385 | if (width < s->background_width) | 4386 | if (width < s->background_width) |
| 4386 | { | 4387 | { |
| 4387 | GC gc = s->face->gc; | ||
| 4388 | int x = s->x + width, y = s->y; | 4388 | int x = s->x + width, y = s->y; |
| 4389 | int w = s->background_width - width, h = s->height; | 4389 | int w = s->background_width - width, h = s->height; |
| 4390 | XRectangle r; | 4390 | XRectangle r; |
| 4391 | GC gc; | ||
| 4391 | 4392 | ||
| 4393 | if (s->row->mouse_face_p | ||
| 4394 | && cursor_in_mouse_face_p (s->w)) | ||
| 4395 | { | ||
| 4396 | x_set_mouse_face_gc (s); | ||
| 4397 | gc = s->gc; | ||
| 4398 | } | ||
| 4399 | else | ||
| 4400 | gc = s->face->gc; | ||
| 4401 | |||
| 4392 | x_get_glyph_string_clip_rect (s, &r); | 4402 | x_get_glyph_string_clip_rect (s, &r); |
| 4393 | XSetClipRectangles (s->display, gc, 0, 0, &r, 1, Unsorted); | 4403 | XSetClipRectangles (s->display, gc, 0, 0, &r, 1, Unsorted); |
| 4394 | 4404 | ||
| 4395 | if (s->face->stipple) | 4405 | if (s->face->stipple) |
| 4396 | { | 4406 | { |
| 4397 | /* Fill background with a stipple pattern. */ | 4407 | /* Fill background with a stipple pattern. */ |
| @@ -11201,6 +11211,35 @@ x_erase_phys_cursor (w) | |||
| 11201 | } | 11211 | } |
| 11202 | 11212 | ||
| 11203 | 11213 | ||
| 11214 | /* Non-zero if physical cursor of window W is within mouse face. */ | ||
| 11215 | |||
| 11216 | static int | ||
| 11217 | cursor_in_mouse_face_p (w) | ||
| 11218 | struct window *w; | ||
| 11219 | { | ||
| 11220 | struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (XFRAME (w->frame)); | ||
| 11221 | int in_mouse_face = 0; | ||
| 11222 | |||
| 11223 | if (WINDOWP (dpyinfo->mouse_face_window) | ||
| 11224 | && XWINDOW (dpyinfo->mouse_face_window) == w) | ||
| 11225 | { | ||
| 11226 | int hpos = w->phys_cursor.hpos; | ||
| 11227 | int vpos = w->phys_cursor.vpos; | ||
| 11228 | |||
| 11229 | if (vpos >= dpyinfo->mouse_face_beg_row | ||
| 11230 | && vpos <= dpyinfo->mouse_face_end_row | ||
| 11231 | && (vpos > dpyinfo->mouse_face_beg_row | ||
| 11232 | || hpos >= dpyinfo->mouse_face_beg_col) | ||
| 11233 | && (vpos < dpyinfo->mouse_face_end_row | ||
| 11234 | || hpos < dpyinfo->mouse_face_end_col | ||
| 11235 | || dpyinfo->mouse_face_past_end)) | ||
| 11236 | in_mouse_face = 1; | ||
| 11237 | } | ||
| 11238 | |||
| 11239 | return in_mouse_face; | ||
| 11240 | } | ||
| 11241 | |||
| 11242 | |||
| 11204 | /* Display or clear cursor of window W. If ON is zero, clear the | 11243 | /* Display or clear cursor of window W. If ON is zero, clear the |
| 11205 | cursor. If it is non-zero, display the cursor. If ON is nonzero, | 11244 | cursor. If it is non-zero, display the cursor. If ON is nonzero, |
| 11206 | where to put the cursor is specified by HPOS, VPOS, X and Y. */ | 11245 | where to put the cursor is specified by HPOS, VPOS, X and Y. */ |