Re: Some small bugs



Alexander Larsson <alla lysator liu se> writes:

> 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.

gdk_pixmap_colormap_new_from_pixbuf() isn't an API call - it's an
internal static function used to simplify the code. The API call for
creating a pixmap from a pixbuf is:
gdk_pixbuf_render_pixmap_and_mask().

So, I think it makes sense to put the mask-filling code in
there instead of duplicating it. The whole point of 
gdk_pixmap_colormap_new_from_pixbuf was to avoid duplication of
code!
 
> +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;
> +}

This looks fine. I might tend save one X request by using
gdk_gc_new_with_values(), but the difference there is 
miniscule.

Regards,
                                        Owen




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