*/
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);
#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;
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 */
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);
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);
}
}
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);
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);
}
}
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);
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);
}
}
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);
}
}