Re: Some small bugs



On 20 Feb 2001, Owen Taylor wrote:
> I think this isn't the correct fix - I believe that the problem is
> that there has been a incompatible change in gdk_pixmap_new_from_xpm_d() 
> [ and friends ]; before, a no-transparency XMP gave a solid mask,
> now it gives a NULL mask.
> 
> So, I think we need to fix that instead, since it will break a LOT
> of app programs as well.
> 
> It should be pretty easy - something like:
> 
>  if (mask && !*mask) 
>    [ Create solid mask ]
> 

How about this one then? It changes gdk_pixmap_create_from_xpm_d,
gdk_pixmap_colormap_create_from_xpm_d, gdk_pixmap_create_from_xpm and
gdk_pixmap_colormap_create_from_xpm,

gdk_pixmap_colormap_new_from_pixbuf is *not* changed, since it's a new
API call which don't have backwards compatibility demands, and I think
NULL mask for no alpha is a more logical behaviour.

/ Alex

Index: gdk/gdkpixmap.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk/gdkpixmap.c,v
retrieving revision 1.37
diff -u -p -r1.37 gdkpixmap.c
--- gdk/gdkpixmap.c	2000/12/15 01:46:39	1.37
+++ gdk/gdkpixmap.c	2001/02/21 09:30:02
@@ -476,6 +476,24 @@ gdk_pixmap_colormap_new_from_pixbuf (Gdk
   return pixmap;
 }
 
+static GdkBitmap *
+make_solid_mask(gint width, gint height)
+{
+  GdkBitmap *bitmap;
+  GdkColor color;
+  GdkGC *gc;
+  
+  bitmap = gdk_pixmap_new (NULL, width, height, 1);
+
+  gc = gdk_gc_new (bitmap);
+
+  color.pixel = 1;
+  gdk_gc_set_foreground (gc, &color);
+  gdk_draw_rectangle (bitmap, gc, TRUE, 0, 0, width, height);
+  gdk_gc_unref (gc);
+  return bitmap;
+}
+
 GdkPixmap*
 gdk_pixmap_colormap_create_from_xpm (GdkWindow   *window,
 				     GdkColormap *colormap,
@@ -498,8 +516,13 @@ gdk_pixmap_colormap_create_from_xpm (Gdk
     return NULL;
 
   pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
-  gdk_pixbuf_unref (pixbuf);
 
+  if (mask && !*mask)
+    *mask = make_solid_mask (gdk_pixbuf_get_width (pixbuf),
+			     gdk_pixbuf_get_height (pixbuf));
+  
+  gdk_pixbuf_unref (pixbuf);
+  
   return pixmap;
 }
 
@@ -535,6 +558,11 @@ gdk_pixmap_colormap_create_from_xpm_d (G
     return NULL;
 
   pixmap = gdk_pixmap_colormap_new_from_pixbuf (colormap, mask, transparent_color, pixbuf);
+
+  if (mask && !*mask)
+    *mask = make_solid_mask (gdk_pixbuf_get_width (pixbuf),
+			     gdk_pixbuf_get_height (pixbuf));
+
   gdk_pixbuf_unref (pixbuf);
 
   return pixmap;





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