GNOME Bugzilla – Bug 150466
gdk_rgb_find_color() returns wrong value for ARGB visual
Last modified: 2004-12-22 21:47:04 UTC
The spiffy new X.org X server includes a new ARGB visual type for translucent windows. This includes a new set of 8 alpha bits in addition to the existing RGB bits. Currently gdk_rgb_find_color() returns these bits as unset when using an ARGB visual leading to interesting effects (usually large holes appearing in windows). The following patch sets these bits when using an ARGV visual. Note that we see if it is an ARGB visual by looking at the depth. A more 'correct' approach would be to have GdkVisual check the visual format via the Render extension if present and set some flag in the GdkVisual structure. I can post a patch which does this if people want. Also see bug #150465 for an example of this causing problems. --- gtk+-2.4.7/gdk/gdkrgb.c 2004-04-14 00:57:12.000000000 +0100 +++ gtk+-2.4.7.argb/gdk/gdkrgb.c 2004-08-18 17:48:30.274641976 +0100 @@ -757,6 +757,10 @@ pixel = (((r >> (16 - image_info->visual->red_prec)) << image_info->visual->red_shift) + ((g >> (16 - image_info->visual->green_prec)) << image_info->visual->green_shift) + ((b >> (16 - image_info->visual->blue_prec)) << image_info->visual->blue_shift)); + + /* Ensure that colour returned for ARGB Visuals has alpha set correctly */ + if(image_info->visual->depth == 32) + pixel |= 0xff000000; } else if (image_info->visual->type == GDK_VISUAL_STATIC_GRAY || image_info->visual->type == GDK_VISUAL_GRAYSCALE)
See the recent changes to gdk_colormap_alloc_colors() for how this should be done.b
Mon Aug 23 01:17:59 2004 Matthias Clasen <maclas@gmx.de> * gdk/gdkrgb.c (gdk_rgb_xpixel_from_rgb_internal): Set unused bits in pixel to 1s in case they are used as alpha; copying code from gdk_colormap_alloc_colors(). (#150466, Rich Wareham)