[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#858156: patch



Package: marco
Version: 1.20.3-1

The icon is mangled when the application is using XWMHints() method,
xterm is affected but also application using SDL1.2 framework among others.
The problem occur in Debian 9 and 10 with marco window manager.

See attached patch, the patch can be applied to marco source (Debian version 9 or 10).
diff -pur a/src/core/iconcache.c b/src/core/iconcache.c
--- a/src/core/iconcache.c	2018-12-19 14:47:57.000000000 -0500
+++ b/src/core/iconcache.c	2020-06-11 09:15:26.943970191 -0400
@@ -335,11 +335,20 @@ apply_mask (GdkPixbuf *pixbuf,
   int src_stride;
   int dest_stride;
 
-  w = MIN (gdk_pixbuf_get_width (mask), gdk_pixbuf_get_width (pixbuf));
-  h = MIN (gdk_pixbuf_get_height (mask), gdk_pixbuf_get_height (pixbuf));
-
   with_alpha = gdk_pixbuf_add_alpha (pixbuf, FALSE, 0, 0, 0);
 
+  /* make sure we have the proper pixel format before proceeding */
+  if (gdk_pixbuf_get_n_channels (with_alpha) != 4 ||
+      gdk_pixbuf_get_bits_per_sample (with_alpha) != 8 ||
+      gdk_pixbuf_get_has_alpha (with_alpha) != 1 ||
+      gdk_pixbuf_get_n_channels (mask) != 4 ||
+      gdk_pixbuf_get_bits_per_sample (mask) != 8 ||
+      gdk_pixbuf_get_has_alpha (mask) != 1)
+    return with_alpha; /* wrong pixel format: no alpha */
+
+  w = MIN (gdk_pixbuf_get_width (mask), gdk_pixbuf_get_width (with_alpha));
+  h = MIN (gdk_pixbuf_get_height (mask), gdk_pixbuf_get_height (with_alpha));
+
   dest = gdk_pixbuf_get_pixels (with_alpha);
   src = gdk_pixbuf_get_pixels (mask);
 
@@ -352,13 +361,13 @@ apply_mask (GdkPixbuf *pixbuf,
       j = 0;
       while (j < w)
         {
-          guchar *s = src + i * src_stride + j * 3;
+          guchar *s = src + i * src_stride + j * 4;
           guchar *d = dest + i * dest_stride + j * 4;
 
           /* s[0] == s[1] == s[2], they are 255 if the bit was set, 0
            * otherwise
            */
-          if (s[0] == 0)
+          if (s[3] == 0)
             d[3] = 0;   /* transparent */
           else
             d[3] = 255; /* opaque */

Reply to: