From d6d73224a21506b0ba31fd03bd99c5535ce3bb9c Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 1 Feb 2022 09:38:26 +0800 Subject: [PATCH] Make fringe bitmaps respect alpha-background * src/xterm.c (x_draw_fringe_bitmap): Respect alpha-background on non-overlay fringe bitmaps. * src/xterm.h (struct x_display_info): New field `alpha_mask'. --- src/xterm.c | 13 ++++++++++++- src/xterm.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/xterm.c b/src/xterm.c index 5bcb77bbeba..2fc336f72a9 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -2032,6 +2032,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring Pixmap pixmap, clipmask = None; int depth = FRAME_DISPLAY_INFO (f)->n_planes; XGCValues gcv; + unsigned long background = face->background; #ifdef HAVE_XRENDER Picture picture = None; XRenderPictureAttributes attrs; @@ -2044,6 +2045,14 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring else bits = (char *) p->bits + p->dh; + if (FRAME_DISPLAY_INFO (f)->alpha_bits) + { + background = (background & ~FRAME_DISPLAY_INFO (f)->alpha_mask); + background |= (((unsigned long) (f->alpha_background * 0xffff) + >> (16 - FRAME_DISPLAY_INFO (f)->alpha_bits)) + << FRAME_DISPLAY_INFO (f)->alpha_offset); + } + /* Draw the bitmap. I believe these small pixmaps can be cached by the server. */ pixmap = XCreatePixmapFromBitmapData (display, drawable, bits, p->wd, p->h, @@ -2051,7 +2060,7 @@ x_draw_fringe_bitmap (struct window *w, struct glyph_row *row, struct draw_fring ? (p->overlay_p ? face->background : f->output_data.x->cursor_pixel) : face->foreground), - face->background, depth); + background, depth); #ifdef HAVE_XRENDER if (FRAME_X_PICTURE_FORMAT (f) @@ -15574,6 +15583,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) if (channel_mask) get_bits_and_offset (channel_mask, &dpyinfo->alpha_bits, &dpyinfo->alpha_offset); + dpyinfo->alpha_mask = channel_mask; } else #endif @@ -15594,6 +15604,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) if (alpha_mask) get_bits_and_offset (alpha_mask, &dpyinfo->alpha_bits, &dpyinfo->alpha_offset); + dpyinfo->alpha_mask = alpha_mask; } } } diff --git a/src/xterm.h b/src/xterm.h index c8c491a7d31..02270d69360 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -462,6 +462,7 @@ struct x_display_info /* Bits and shifts to use to compose pixel values on TrueColor visuals. */ int red_bits, blue_bits, green_bits, alpha_bits; int red_offset, blue_offset, green_offset, alpha_offset; + unsigned long alpha_mask; /* The type of window manager we have. If we move FRAME_OUTER_WINDOW to x/y 0/0, some window managers (type A) puts the window manager -- 2.39.5