Mercurial > emacs
comparison src/xterm.c @ 37922:fcd11c3e6341
(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.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Mon, 28 May 2001 13:42:21 +0000 |
parents | 1d2bd2c606e8 |
children | b64d19038fca |
comparison
equal
deleted
inserted
replaced
37921:682de754cdf0 | 37922:fcd11c3e6341 |
---|---|
397 DRAW_MOUSE_FACE, | 397 DRAW_MOUSE_FACE, |
398 DRAW_IMAGE_RAISED, | 398 DRAW_IMAGE_RAISED, |
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)); |
405 static const XColor *x_color_cells P_ ((Display *, int *)); | 406 static const XColor *x_color_cells P_ ((Display *, int *)); |
406 static void x_update_window_end P_ ((struct window *, int, int)); | 407 static void x_update_window_end P_ ((struct window *, int, int)); |
4382 x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height); | 4383 x_draw_glyph_string_bg_rect (s, s->x, s->y, width, s->height); |
4383 | 4384 |
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 | 4391 GC gc; |
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. */ |
4398 XSetFillStyle (s->display, gc, FillOpaqueStippled); | 4408 XSetFillStyle (s->display, gc, FillOpaqueStippled); |
4399 XFillRectangle (s->display, s->window, gc, x, y, w, h); | 4409 XFillRectangle (s->display, s->window, gc, x, y, w, h); |
11199 w->phys_cursor_on_p = 0; | 11209 w->phys_cursor_on_p = 0; |
11200 w->phys_cursor_type = NO_CURSOR; | 11210 w->phys_cursor_type = NO_CURSOR; |
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. */ |
11207 | 11246 |
11208 void | 11247 void |