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.
This commit is contained in:
parent
4f50d964e5
commit
77c3d41adc
1 changed files with 23 additions and 10 deletions
33
src/xterm.c
33
src/xterm.c
|
@ -3945,7 +3945,7 @@ x_get_scale_factor(Display *disp, int *scale_x, int *scale_y)
|
|||
|
||||
*/
|
||||
static void
|
||||
x_draw_underwave (struct glyph_string *s)
|
||||
x_draw_underwave (struct glyph_string *s, int decoration_width)
|
||||
{
|
||||
Display *display = FRAME_X_DISPLAY (s->f);
|
||||
|
||||
|
@ -3958,7 +3958,7 @@ x_draw_underwave (struct glyph_string *s)
|
|||
|
||||
#ifdef USE_CAIRO
|
||||
x_draw_horizontal_wave (s->f, s->gc, s->x, s->ybase - wave_height + 3,
|
||||
s->width, wave_height, wave_length);
|
||||
decoration_width, wave_height, wave_length);
|
||||
#else /* not USE_CAIRO */
|
||||
int dx, dy, x0, y0, width, x1, y1, x2, y2, xmax, thickness = scale_y;;
|
||||
bool odd;
|
||||
|
@ -3968,7 +3968,7 @@ x_draw_underwave (struct glyph_string *s)
|
|||
dy = wave_height - 1;
|
||||
x0 = s->x;
|
||||
y0 = s->ybase + wave_height / 2 - scale_y;
|
||||
width = s->width;
|
||||
width = decoration_width;
|
||||
xmax = x0 + width;
|
||||
|
||||
/* Find and set clipping rectangle */
|
||||
|
@ -4118,6 +4118,19 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
|
||||
if (!s->for_overlaps)
|
||||
{
|
||||
int area_x, area_y, area_width, area_height;
|
||||
int area_max_x, decoration_width;
|
||||
|
||||
/* Prevent the underline from overwriting surrounding areas
|
||||
and the fringe. */
|
||||
window_box (s->w, s->area, &area_x, &area_y,
|
||||
&area_width, &area_height);
|
||||
area_max_x = area_x + area_width - 1;
|
||||
|
||||
decoration_width = s->width;
|
||||
if (area_max_x < (s->x + decoration_width - 1))
|
||||
decoration_width -= (s->x + decoration_width - 1) - area_max_x;
|
||||
|
||||
/* Draw relief if not yet drawn. */
|
||||
if (!relief_drawn_p && s->face->box != FACE_NO_BOX)
|
||||
x_draw_glyph_string_box (s);
|
||||
|
@ -4128,14 +4141,14 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
if (s->face->underline == FACE_UNDER_WAVE)
|
||||
{
|
||||
if (s->face->underline_defaulted_p)
|
||||
x_draw_underwave (s);
|
||||
x_draw_underwave (s, decoration_width);
|
||||
else
|
||||
{
|
||||
Display *display = FRAME_X_DISPLAY (s->f);
|
||||
XGCValues xgcv;
|
||||
XGetGCValues (display, s->gc, GCForeground, &xgcv);
|
||||
XSetForeground (display, s->gc, s->face->underline_color);
|
||||
x_draw_underwave (s);
|
||||
x_draw_underwave (s, decoration_width);
|
||||
XSetForeground (display, s->gc, xgcv.foreground);
|
||||
}
|
||||
}
|
||||
|
@ -4225,7 +4238,7 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
y = s->ybase + position;
|
||||
if (s->face->underline_defaulted_p)
|
||||
x_fill_rectangle (s->f, s->gc,
|
||||
s->x, y, s->width, thickness);
|
||||
s->x, y, decoration_width, thickness);
|
||||
else
|
||||
{
|
||||
Display *display = FRAME_X_DISPLAY (s->f);
|
||||
|
@ -4233,7 +4246,7 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
XGetGCValues (display, s->gc, GCForeground, &xgcv);
|
||||
XSetForeground (display, s->gc, s->face->underline_color);
|
||||
x_fill_rectangle (s->f, s->gc,
|
||||
s->x, y, s->width, thickness);
|
||||
s->x, y, decoration_width, thickness);
|
||||
XSetForeground (display, s->gc, xgcv.foreground);
|
||||
}
|
||||
}
|
||||
|
@ -4245,7 +4258,7 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
|
||||
if (s->face->overline_color_defaulted_p)
|
||||
x_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
|
||||
s->width, h);
|
||||
decoration_width, h);
|
||||
else
|
||||
{
|
||||
Display *display = FRAME_X_DISPLAY (s->f);
|
||||
|
@ -4253,7 +4266,7 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
XGetGCValues (display, s->gc, GCForeground, &xgcv);
|
||||
XSetForeground (display, s->gc, s->face->overline_color);
|
||||
x_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
|
||||
s->width, h);
|
||||
decoration_width, h);
|
||||
XSetForeground (display, s->gc, xgcv.foreground);
|
||||
}
|
||||
}
|
||||
|
@ -4283,7 +4296,7 @@ x_draw_glyph_string (struct glyph_string *s)
|
|||
XGetGCValues (display, s->gc, GCForeground, &xgcv);
|
||||
XSetForeground (display, s->gc, s->face->strike_through_color);
|
||||
x_fill_rectangle (s->f, s->gc, s->x, glyph_y + dy,
|
||||
s->width, h);
|
||||
decoration_width, h);
|
||||
XSetForeground (display, s->gc, xgcv.foreground);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue