After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 150466 - gdk_rgb_find_color() returns wrong value for ARGB visual
gdk_rgb_find_color() returns wrong value for ARGB visual
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2004-08-18 16:56 UTC by Rich Wareham
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement



Description Rich Wareham 2004-08-18 16:56: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)
Comment 1 Owen Taylor 2004-08-19 17:41:07 UTC
See the recent changes to gdk_colormap_alloc_colors() for how this should
be done.b
Comment 2 Matthias Clasen 2004-08-23 05:20:04 UTC
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)