aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-01-10 19:54:36 +0800
committerPo Lu2022-01-10 19:54:36 +0800
commit77c3d41adc9cc0fabdf607cb899d0181b0ccb1e4 (patch)
tree680134af667a99d969d3a8346a6d4a2656f7c10c /src
parent4f50d964e51bbe5219f40df4353f4314c7ade985 (diff)
downloademacs-77c3d41adc9cc0fabdf607cb899d0181b0ccb1e4.tar.gz
emacs-77c3d41adc9cc0fabdf607cb899d0181b0ccb1e4.zip
Prevent text decorations from overwriting surrounding areas on X
* src/xterm.c (x_draw_underwave): New parameter `decoration_width'. (x_draw_glyph_string): Constrain decoration width to current text area.
Diffstat (limited to 'src')
-rw-r--r--src/xterm.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/xterm.c b/src/xterm.c
index e2b09938a27..cca57952ba0 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -3945,7 +3945,7 @@ x_get_scale_factor(Display *disp, int *scale_x, int *scale_y)
3945 3945
3946*/ 3946*/
3947static void 3947static void
3948x_draw_underwave (struct glyph_string *s) 3948x_draw_underwave (struct glyph_string *s, int decoration_width)
3949{ 3949{
3950 Display *display = FRAME_X_DISPLAY (s->f); 3950 Display *display = FRAME_X_DISPLAY (s->f);
3951 3951
@@ -3958,7 +3958,7 @@ x_draw_underwave (struct glyph_string *s)
3958 3958
3959#ifdef USE_CAIRO 3959#ifdef USE_CAIRO
3960 x_draw_horizontal_wave (s->f, s->gc, s->x, s->ybase - wave_height + 3, 3960 x_draw_horizontal_wave (s->f, s->gc, s->x, s->ybase - wave_height + 3,
3961 s->width, wave_height, wave_length); 3961 decoration_width, wave_height, wave_length);
3962#else /* not USE_CAIRO */ 3962#else /* not USE_CAIRO */
3963 int dx, dy, x0, y0, width, x1, y1, x2, y2, xmax, thickness = scale_y;; 3963 int dx, dy, x0, y0, width, x1, y1, x2, y2, xmax, thickness = scale_y;;
3964 bool odd; 3964 bool odd;
@@ -3968,7 +3968,7 @@ x_draw_underwave (struct glyph_string *s)
3968 dy = wave_height - 1; 3968 dy = wave_height - 1;
3969 x0 = s->x; 3969 x0 = s->x;
3970 y0 = s->ybase + wave_height / 2 - scale_y; 3970 y0 = s->ybase + wave_height / 2 - scale_y;
3971 width = s->width; 3971 width = decoration_width;
3972 xmax = x0 + width; 3972 xmax = x0 + width;
3973 3973
3974 /* Find and set clipping rectangle */ 3974 /* Find and set clipping rectangle */
@@ -4118,6 +4118,19 @@ x_draw_glyph_string (struct glyph_string *s)
4118 4118
4119 if (!s->for_overlaps) 4119 if (!s->for_overlaps)
4120 { 4120 {
4121 int area_x, area_y, area_width, area_height;
4122 int area_max_x, decoration_width;
4123
4124 /* Prevent the underline from overwriting surrounding areas
4125 and the fringe. */
4126 window_box (s->w, s->area, &area_x, &area_y,
4127 &area_width, &area_height);
4128 area_max_x = area_x + area_width - 1;
4129
4130 decoration_width = s->width;
4131 if (area_max_x < (s->x + decoration_width - 1))
4132 decoration_width -= (s->x + decoration_width - 1) - area_max_x;
4133
4121 /* Draw relief if not yet drawn. */ 4134 /* Draw relief if not yet drawn. */
4122 if (!relief_drawn_p && s->face->box != FACE_NO_BOX) 4135 if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
4123 x_draw_glyph_string_box (s); 4136 x_draw_glyph_string_box (s);
@@ -4128,14 +4141,14 @@ x_draw_glyph_string (struct glyph_string *s)
4128 if (s->face->underline == FACE_UNDER_WAVE) 4141 if (s->face->underline == FACE_UNDER_WAVE)
4129 { 4142 {
4130 if (s->face->underline_defaulted_p) 4143 if (s->face->underline_defaulted_p)
4131 x_draw_underwave (s); 4144 x_draw_underwave (s, decoration_width);
4132 else 4145 else
4133 { 4146 {
4134 Display *display = FRAME_X_DISPLAY (s->f); 4147 Display *display = FRAME_X_DISPLAY (s->f);
4135 XGCValues xgcv; 4148 XGCValues xgcv;
4136 XGetGCValues (display, s->gc, GCForeground, &xgcv); 4149 XGetGCValues (display, s->gc, GCForeground, &xgcv);
4137 XSetForeground (display, s->gc, s->face->underline_color); 4150 XSetForeground (display, s->gc, s->face->underline_color);
4138 x_draw_underwave (s); 4151 x_draw_underwave (s, decoration_width);
4139 XSetForeground (display, s->gc, xgcv.foreground); 4152 XSetForeground (display, s->gc, xgcv.foreground);
4140 } 4153 }
4141 } 4154 }
@@ -4225,7 +4238,7 @@ x_draw_glyph_string (struct glyph_string *s)
4225 y = s->ybase + position; 4238 y = s->ybase + position;
4226 if (s->face->underline_defaulted_p) 4239 if (s->face->underline_defaulted_p)
4227 x_fill_rectangle (s->f, s->gc, 4240 x_fill_rectangle (s->f, s->gc,
4228 s->x, y, s->width, thickness); 4241 s->x, y, decoration_width, thickness);
4229 else 4242 else
4230 { 4243 {
4231 Display *display = FRAME_X_DISPLAY (s->f); 4244 Display *display = FRAME_X_DISPLAY (s->f);
@@ -4233,7 +4246,7 @@ x_draw_glyph_string (struct glyph_string *s)
4233 XGetGCValues (display, s->gc, GCForeground, &xgcv); 4246 XGetGCValues (display, s->gc, GCForeground, &xgcv);
4234 XSetForeground (display, s->gc, s->face->underline_color); 4247 XSetForeground (display, s->gc, s->face->underline_color);
4235 x_fill_rectangle (s->f, s->gc, 4248 x_fill_rectangle (s->f, s->gc,
4236 s->x, y, s->width, thickness); 4249 s->x, y, decoration_width, thickness);
4237 XSetForeground (display, s->gc, xgcv.foreground); 4250 XSetForeground (display, s->gc, xgcv.foreground);
4238 } 4251 }
4239 } 4252 }
@@ -4245,7 +4258,7 @@ x_draw_glyph_string (struct glyph_string *s)
4245 4258
4246 if (s->face->overline_color_defaulted_p) 4259 if (s->face->overline_color_defaulted_p)
4247 x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 4260 x_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
4248 s->width, h); 4261 decoration_width, h);
4249 else 4262 else
4250 { 4263 {
4251 Display *display = FRAME_X_DISPLAY (s->f); 4264 Display *display = FRAME_X_DISPLAY (s->f);
@@ -4253,7 +4266,7 @@ x_draw_glyph_string (struct glyph_string *s)
4253 XGetGCValues (display, s->gc, GCForeground, &xgcv); 4266 XGetGCValues (display, s->gc, GCForeground, &xgcv);
4254 XSetForeground (display, s->gc, s->face->overline_color); 4267 XSetForeground (display, s->gc, s->face->overline_color);
4255 x_fill_rectangle (s->f, s->gc, s->x, s->y + dy, 4268 x_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
4256 s->width, h); 4269 decoration_width, h);
4257 XSetForeground (display, s->gc, xgcv.foreground); 4270 XSetForeground (display, s->gc, xgcv.foreground);
4258 } 4271 }
4259 } 4272 }
@@ -4283,7 +4296,7 @@ x_draw_glyph_string (struct glyph_string *s)
4283 XGetGCValues (display, s->gc, GCForeground, &xgcv); 4296 XGetGCValues (display, s->gc, GCForeground, &xgcv);
4284 XSetForeground (display, s->gc, s->face->strike_through_color); 4297 XSetForeground (display, s->gc, s->face->strike_through_color);
4285 x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy, 4298 x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy,
4286 s->width, h); 4299 decoration_width, h);
4287 XSetForeground (display, s->gc, xgcv.foreground); 4300 XSetForeground (display, s->gc, xgcv.foreground);
4288 } 4301 }
4289 } 4302 }