static void pgtk_clear_frame_area (struct frame *f, int x, int y, int width,
int height);
static void pgtk_fill_rectangle (struct frame *f, unsigned long color, int x,
- int y, int width, int height);
+ int y, int width, int height,
+ bool respect_alpha_background);
static void pgtk_clip_to_row (struct window *w, struct glyph_row *row,
enum glyph_row_area area, cairo_t * cr);
static struct frame *pgtk_any_window_to_frame (GdkWindow * window);
static void
x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h)
{
- pgtk_fill_rectangle (s->f, s->xgcv.background, x, y, w, h);
+ pgtk_fill_rectangle (s->f, s->xgcv.background, x, y, w, h, true);
}
static void
pgtk_draw_rectangle (struct frame *f, unsigned long color, int x, int y,
- int width, int height)
+ int width, int height, bool respect_alpha_background)
{
cairo_t *cr;
cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, color);
- cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
+ pgtk_set_cr_source_with_color (f, color, true);
+ cairo_rectangle (cr, x + 0.5, y + 0.5, width, respect_alpha_background);
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
pgtk_end_cr_clip (f);
struct glyph *g = s->first_glyph + i;
pgtk_draw_rectangle (s->f,
s->face->foreground, x, s->y,
- g->pixel_width - 1, s->height - 1);
+ g->pixel_width - 1, s->height - 1,
+ false);
x += g->pixel_width;
}
}
{
if (s->cmp_from == 0)
pgtk_draw_rectangle (s->f, s->face->foreground, x, s->y,
- s->width - 1, s->height - 1);
+ s->width - 1, s->height - 1, false);
}
else if (!s->first_glyph->u.cmp.automatic)
{
pgtk_draw_rectangle (s->f, s->face->foreground,
x, s->ybase - glyph->ascent,
glyph->pixel_width - 1,
- glyph->ascent + glyph->descent - 1);
+ glyph->ascent + glyph->descent - 1,
+ false);
x += glyph->pixel_width;
}
}
cairo_t *cr;
cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, false);
cairo_move_to (cr, top_p ? x : x + height, y);
cairo_line_to (cr, x, y + height);
cairo_line_to (cr, top_p ? x + width - height : x + width, y + height);
int i;
cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, false);
for (i = 0; i < CORNER_LAST; i++)
if (corners & (1 << i))
{
if (left_p)
{
pgtk_fill_rectangle (f, top_left_color, left_x, top_y,
- vwidth, bottom_y + 1 - top_y);
+ vwidth, bottom_y + 1 - top_y, false);
if (top_p)
corners |= 1 << CORNER_TOP_LEFT;
if (bot_p)
if (right_p)
{
pgtk_fill_rectangle (f, bottom_right_color, right_x + 1 - vwidth, top_y,
- vwidth, bottom_y + 1 - top_y);
+ vwidth, bottom_y + 1 - top_y, false);
if (top_p)
corners |= 1 << CORNER_TOP_RIGHT;
if (bot_p)
{
if (!right_p)
pgtk_fill_rectangle (f, top_left_color, left_x, top_y,
- right_x + 1 - left_x, hwidth);
+ right_x + 1 - left_x, hwidth, false);
else
x_fill_trapezoid_for_relief (f, top_left_color, left_x, top_y,
right_x + 1 - left_x, hwidth, 1);
if (!left_p)
pgtk_fill_rectangle (f, bottom_right_color, left_x,
bottom_y + 1 - hwidth, right_x + 1 - left_x,
- hwidth);
+ hwidth, false);
else
x_fill_trapezoid_for_relief (f, bottom_right_color,
left_x, bottom_y + 1 - hwidth,
}
if (left_p && vwidth > 1)
pgtk_fill_rectangle (f, bottom_right_color, left_x, top_y,
- 1, bottom_y + 1 - top_y);
+ 1, bottom_y + 1 - top_y, false);
if (top_p && hwidth > 1)
pgtk_fill_rectangle (f, bottom_right_color, left_x, top_y,
- right_x + 1 - left_x, 1);
+ right_x + 1 - left_x, 1, false);
if (corners)
{
x_erase_corners_for_relief (f, FRAME_BACKGROUND_PIXEL (f), left_x,
/* Top. */
pgtk_fill_rectangle (s->f, s->xgcv.foreground,
- left_x, top_y, right_x - left_x + 1, hwidth);
+ left_x, top_y, right_x - left_x + 1, hwidth,
+ false);
/* Left. */
if (left_p)
pgtk_fill_rectangle (s->f, s->xgcv.foreground,
- left_x, top_y, vwidth, bottom_y - top_y + 1);
+ left_x, top_y, vwidth, bottom_y - top_y + 1,
+ false);
/* Bottom. */
pgtk_fill_rectangle (s->f, s->xgcv.foreground,
left_x, bottom_y - hwidth + 1, right_x - left_x + 1,
- hwidth);
+ hwidth, false);
/* Right. */
if (right_p)
pgtk_fill_rectangle (s->f, s->xgcv.foreground,
right_x - vwidth + 1, top_y, vwidth,
- bottom_y - top_y + 1);
+ bottom_y - top_y + 1, false);
s->xgcv.foreground = foreground_backup;
int xoffset, n;
cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, false);
cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr);
cairo_rectangle (cr, dest_x, dest_y, width, height);
else
{
- pgtk_set_cr_source_with_gc_background (f, gc);
+ pgtk_set_cr_source_with_gc_background (f, gc, false);
cairo_rectangle (cr, dest_x, dest_y, width, height);
cairo_fill_preserve (cr);
}
}
else
{
- pgtk_set_cr_source_with_gc_foreground (f, gc);
+ pgtk_set_cr_source_with_gc_foreground (f, gc, false);
cairo_clip (cr);
cairo_mask (cr, image);
}
int relief = eabs (s->img->relief);
pgtk_draw_rectangle (s->f, s->xgcv.foreground, x - relief, y - relief,
s->slice.width + relief*2 - 1,
- s->slice.height + relief*2 - 1);
+ s->slice.height + relief*2 - 1, false);
}
}
pgtk_end_cr_clip (s->f);
else
/* Draw a rectangle if image could not be loaded. */
pgtk_draw_rectangle (s->f, s->xgcv.foreground, x, y,
- s->slice.width - 1, s->slice.height - 1);
+ s->slice.width - 1, s->slice.height - 1, false);
}
/* Draw image glyph string S.
}
else
{
- pgtk_fill_rectangle (s->f, color, x, y, w, h);
+ pgtk_fill_rectangle (s->f, color, x, y, w, h,
+ false);
}
pgtk_end_cr_clip (s->f);
y = s->ybase + position;
if (s->face->underline_defaulted_p)
pgtk_fill_rectangle (s->f, s->xgcv.foreground,
- s->x, y, s->width, thickness);
+ s->x, y, s->width, thickness,
+ false);
else
{
pgtk_fill_rectangle (s->f, s->face->underline_color,
- s->x, y, s->width, thickness);
+ s->x, y, s->width, thickness,
+ false);
}
}
}
if (s->face->overline_color_defaulted_p)
pgtk_fill_rectangle (s->f, s->xgcv.foreground, s->x, s->y + dy,
- s->width, h);
+ s->width, h, false);
else
{
pgtk_fill_rectangle (s->f, s->face->overline_color, s->x,
- s->y + dy, s->width, h);
+ s->y + dy, s->width, h, false);
}
}
if (s->face->strike_through_color_defaulted_p)
pgtk_fill_rectangle (s->f, s->xgcv.foreground, s->x, glyph_y + dy,
- s->width, h);
+ s->width, h, false);
else
{
pgtk_fill_rectangle (s->f, s->face->strike_through_color, s->x,
- glyph_y + dy, s->width, h);
+ glyph_y + dy, s->width, h, false);
}
}
/* The foreground of cursor_gc is typically the same as the normal
background color, which can cause the cursor box to be invisible. */
cairo_t *cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, FRAME_X_OUTPUT (f)->cursor_color);
+ pgtk_set_cr_source_with_color (f, FRAME_X_OUTPUT (f)->cursor_color, false);
/* When on R2L character, show cursor at the right edge of the
glyph, unless the cursor box is as wide as the glyph or wider
}
/* Set clipping, draw the rectangle, and reset clipping again. */
pgtk_clip_to_row (w, row, TEXT_AREA, cr);
- pgtk_draw_rectangle (f, FRAME_X_OUTPUT (f)->cursor_color, x, y, wd, h - 1);
+ pgtk_draw_rectangle (f, FRAME_X_OUTPUT (f)->cursor_color, x, y, wd, h - 1, false);
pgtk_end_cr_clip (f);
}
pgtk_fill_rectangle (f, color, x,
WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
- width, row->height);
+ width, row->height, false);
}
else /* HBAR_CURSOR */
{
pgtk_fill_rectangle (f, color, x,
WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
row->height - width),
- w->phys_cursor_width - 1, width);
+ w->phys_cursor_width - 1, width, false);
}
pgtk_end_cr_clip (f);
face = FACE_FROM_ID_OR_NULL (f, VERTICAL_BORDER_FACE_ID);
if (face)
- pgtk_set_cr_source_with_color (f, face->foreground);
+ pgtk_set_cr_source_with_color (f, face->foreground, false);
cairo_rectangle (cr, x, y0, 1, y1 - y0);
cairo_fill (cr);
if (y1 - y0 > x1 - x0 && x1 - x0 > 2)
/* Vertical. */
{
- pgtk_set_cr_source_with_color (f, color_first);
+ pgtk_set_cr_source_with_color (f, color_first, false);
cairo_rectangle (cr, x0, y0, 1, y1 - y0);
cairo_fill (cr);
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, false);
cairo_rectangle (cr, x0 + 1, y0, x1 - x0 - 2, y1 - y0);
cairo_fill (cr);
- pgtk_set_cr_source_with_color (f, color_last);
+ pgtk_set_cr_source_with_color (f, color_last, false);
cairo_rectangle (cr, x1 - 1, y0, 1, y1 - y0);
cairo_fill (cr);
}
else if (x1 - x0 > y1 - y0 && y1 - y0 > 3)
/* Horizontal. */
{
- pgtk_set_cr_source_with_color (f, color_first);
+ pgtk_set_cr_source_with_color (f, color_first, false);
cairo_rectangle (cr, x0, y0, x1 - x0, 1);
cairo_fill (cr);
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, false);
cairo_rectangle (cr, x0, y0 + 1, x1 - x0, y1 - y0 - 2);
cairo_fill (cr);
- pgtk_set_cr_source_with_color (f, color_last);
+ pgtk_set_cr_source_with_color (f, color_last, false);
cairo_rectangle (cr, x0, y1 - 1, x1 - x0, 1);
cairo_fill (cr);
}
else
{
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, false);
cairo_rectangle (cr, x0, y0, x1 - x0, y1 - y0);
cairo_fill (cr);
}
cairo_rectangle (cr, dest_x, dest_y, width, height);
else
{
- pgtk_set_cr_source_with_gc_background (f, gc);
+ pgtk_set_cr_source_with_gc_background (f, gc, false);
cairo_rectangle (cr, dest_x, dest_y, width, height);
cairo_fill_preserve (cr);
}
}
else
{
- pgtk_set_cr_source_with_gc_foreground (f, gc);
+ pgtk_set_cr_source_with_gc_foreground (f, gc, false);
cairo_clip (cr);
cairo_mask (cr, image);
}
}
else
{
- pgtk_set_cr_source_with_color (f, face->background);
+ pgtk_set_cr_source_with_color (f, face->background, true);
cairo_rectangle (cr, p->bx, p->by, p->nx, p->ny);
cairo_fill (cr);
}
static void
pgtk_fill_rectangle (struct frame *f, unsigned long color, int x, int y,
- int width, int height)
+ int width, int height, bool respect_alpha_background)
{
cairo_t *cr;
cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, color);
+ pgtk_set_cr_source_with_color (f, color, respect_alpha_background);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
pgtk_end_cr_clip (f);
eassert (width > 0 && height > 0);
cr = pgtk_begin_cr_clip (f);
- pgtk_set_cr_source_with_color (f, FRAME_X_OUTPUT (f)->background_color);
+ pgtk_set_cr_source_with_color (f, FRAME_X_OUTPUT (f)->background_color,
+ true);
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
pgtk_end_cr_clip (f);
}
void
-pgtk_set_cr_source_with_gc_foreground (struct frame *f, Emacs_GC * gc)
+pgtk_set_cr_source_with_gc_foreground (struct frame *f, Emacs_GC *gc,
+ bool respects_alpha_background)
{
- pgtk_set_cr_source_with_color (f, gc->foreground);
+ pgtk_set_cr_source_with_color (f, gc->foreground,
+ respects_alpha_background);
}
void
-pgtk_set_cr_source_with_gc_background (struct frame *f, Emacs_GC * gc)
+pgtk_set_cr_source_with_gc_background (struct frame *f, Emacs_GC *gc,
+ bool respects_alpha_background)
{
- pgtk_set_cr_source_with_color (f, gc->background);
+ pgtk_set_cr_source_with_color (f, gc->background,
+ respects_alpha_background);
}
void
-pgtk_set_cr_source_with_color (struct frame *f, unsigned long color)
+pgtk_set_cr_source_with_color (struct frame *f, unsigned long color,
+ bool respects_alpha_background)
{
Emacs_Color col;
col.pixel = color;
pgtk_query_color (f, &col);
- cairo_set_source_rgb (FRAME_CR_CONTEXT (f), col.red / 65535.0,
- col.green / 65535.0, col.blue / 65535.0);
+
+ if (!respects_alpha_background)
+ cairo_set_source_rgb (FRAME_CR_CONTEXT (f), col.red / 65535.0,
+ col.green / 65535.0, col.blue / 65535.0);
+ else
+ {
+ cairo_set_source_rgba (FRAME_CR_CONTEXT (f), col.red / 65535.0,
+ col.green / 65535.0, col.blue / 65535.0,
+ f->alpha_background);
+ cairo_set_operator (FRAME_CR_CONTEXT (f), CAIRO_OPERATOR_SOURCE);
+ }
}
void