[PATCH] ARGB visuals (for Composite)
- From: Amit Gurdasani <gurdasani gmx net>
- To: sawfish-list gnome org
- Cc: Christian Marillat <marillat debian org>
- Subject: [PATCH] ARGB visuals (for Composite)
- Date: Thu, 3 Feb 2005 23:21:21 +0530 (IST)
Hi,
I have a small patch I'd like to submit that allows Sawfish to display windows
utilizing the alpha channel provided by the RENDER extension in conjunction
with Composite.
Currently, Sawfish (along with most window managers) picks a preferred visual
reported by gdk-pixbuf and uses that for all X window frames, then reparents
the windows into those frames. For ARGB windows, the net effect is that the
alpha channel ends up being ignored and the window is rendered opaque.
The small patch causes frames for windows with an alpha channel (depth 32) to
inherit the visual and colormap so that the compositor will correctly identify
the alpha channel and render it correctly. (This essentially does what Keith
Packard's patch for MetaCity does:
http://bugs.gnome.org/show_bug.cgi?id=126875)
The patch doesn't work perfectly -- in particular, shaped window frames will
cause the remainder of the rectangular frame window to simply remain unpainted --
but it should work for rectangular frames with the edges covered completely by
frameparts. Unfortunately I'm not familiar with RENDER or Composite enough to
know how to fix that.
The following are links to screenshots of what an alpha-channel-enabled
application looks like with the patch (in this case, Keith Packard's hacked-up
xterm at http://www.freedesktop.org/xterm-trans.tar.gz).
http://thorin.battleaxe.net/~prototyped/sawfish-trans.png (212KB)
http://thorin.battleaxe.net/~prototyped/sawfish-argb.png (639KB)
Thank you for your interest.
Amit Gurdasani
///////////////////////////////// cut here /////////////////////////////////
Index: frames.c
===================================================================
RCS file: /cvs/gnome/sawfish/src/frames.c,v
retrieving revision 1.108
diff -u -r1.108 frames.c
--- frames.c 4 Jan 2005 15:34:25 -0000 1.108
+++ frames.c 3 Feb 2005 17:21:15 -0000
@@ -1556,16 +1556,43 @@
configure it to the correct size.. */
if (w->frame == 0)
{
+ /*
+ * Determine if the window is using an ARGB visual.
+ * If it is, we inherit the visual from the window.
+ */
+ XWindowAttributes child_attrs;
+ int wdepth;
+ Visual *wvisual;
+ Status s = XGetWindowAttributes(dpy, w->id, &child_attrs);
+ if (s != BadDrawable && s != BadWindow && child_attrs.depth == 32)
+ {
+ /*
+ * This window appears to have an alpha channel.
+ * The frame should inherit its colormap and visual.
+ */
+
+ wdepth = 32;
+ wvisual = child_attrs.visual;
+ wa.colormap = child_attrs.colormap;
+ }
+ else
+ {
+ /* Use the preferred visual and colormap. */
+
+ wdepth = image_depth;
+ wvisual = image_visual;
+ wa.colormap = image_cmap;
+ }
+
/* create the frame */
wa.override_redirect = True;
wa.save_under = w->attr.save_under;
- wa.colormap = image_cmap;
wa.border_pixel = BlackPixel (dpy, screen_num);
wamask = CWOverrideRedirect | CWColormap | CWBorderPixel | CWSaveUnder;
w->frame = XCreateWindow (dpy, root_window, w->attr.x, w->attr.y,
w->frame_width, w->frame_height,
- 0, image_depth, InputOutput,
- image_visual, wamask, &wa);
+ 0, wdepth, InputOutput,
+ wvisual, wamask, &wa);
}
else
{
///////////////////////////////// cut here /////////////////////////////////
Index: frames.c
===================================================================
RCS file: /cvs/gnome/sawfish/src/frames.c,v
retrieving revision 1.108
diff -u -r1.108 frames.c
--- frames.c 4 Jan 2005 15:34:25 -0000 1.108
+++ frames.c 3 Feb 2005 17:21:15 -0000
@@ -1556,16 +1556,43 @@
configure it to the correct size.. */
if (w->frame == 0)
{
+ /*
+ * Determine if the window is using an ARGB visual.
+ * If it is, we inherit the visual from the window.
+ */
+ XWindowAttributes child_attrs;
+ int wdepth;
+ Visual *wvisual;
+ Status s = XGetWindowAttributes(dpy, w->id, &child_attrs);
+ if (s != BadDrawable && s != BadWindow && child_attrs.depth == 32)
+ {
+ /*
+ * This window appears to have an alpha channel.
+ * The frame should inherit its colormap and visual.
+ */
+
+ wdepth = 32;
+ wvisual = child_attrs.visual;
+ wa.colormap = child_attrs.colormap;
+ }
+ else
+ {
+ /* Use the preferred visual and colormap. */
+
+ wdepth = image_depth;
+ wvisual = image_visual;
+ wa.colormap = image_cmap;
+ }
+
/* create the frame */
wa.override_redirect = True;
wa.save_under = w->attr.save_under;
- wa.colormap = image_cmap;
wa.border_pixel = BlackPixel (dpy, screen_num);
wamask = CWOverrideRedirect | CWColormap | CWBorderPixel | CWSaveUnder;
w->frame = XCreateWindow (dpy, root_window, w->attr.x, w->attr.y,
w->frame_width, w->frame_height,
- 0, image_depth, InputOutput,
- image_visual, wamask, &wa);
+ 0, wdepth, InputOutput,
+ wvisual, wamask, &wa);
}
else
{
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]