]> git.eshelyaron.com Git - emacs.git/commitdiff
Make fringe bitmaps respect alpha-background
authorPo Lu <luangruo@yahoo.com>
Tue, 1 Feb 2022 01:38:26 +0000 (09:38 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 1 Feb 2022 01:38:26 +0000 (09:38 +0800)
* 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
src/xterm.h

index 5bcb77bbebac185df9c2becd04554254f6ef1ff8..2fc336f72a9b9a39ec71e7d217988fe1d7fbb603 100644 (file)
@@ -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;
            }
        }
     }
index c8c491a7d31956a024df58424b4a67f460e05365..02270d693600a07ede9d1f4cc65aeed021c06583 100644 (file)
@@ -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