creating true transparent widgets

Carl Worth cworth at cworth.org
Wed Nov 17 12:40:18 PST 2004


On Mon, 15 Nov 2004 01:49:03 +0100, Christian Parpart wrote:
> I tried to write a *simple* xlib application whose background is semi
> transparent, just like in xterm.
> What did I wrong?

Using XCreateSimpleWindow doesn't work here, because that just gives you
the visual of the parent (root) window. But that won't do. You don't
want just any visual, but you need to find an ARGB visual to get the
effect you want.

Here's a similar program that seems to do the trick. It's got a new
function for finding the ARGB visual, and code to add a window title,
(as otherwise metacity seems to decide the window doesn't need
decorations/window controls).

Oh, and note also that the ARGB pixel values should use pre-multiplied
alpha. That is, the R, G, and B components should be multiplied by the
alpha value. So, where you wanted RGB=0xc0c0c0 with A=0x80, you actually
need to use ARGB=0x80606060.

I hope this helps.

-Carl

PS. This kind of information might go nicely on a wiki page. Or maybe
this demo program should be thrown into xapps CVS. Either of those would
be easy right now if the server were up and running...

-------------- next part --------------
A non-text attachment was scrubbed...
Name: argb_demo.c
Type: text/x-c
Size: 4203 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg/attachments/20041117/a66af30a/attachment.bin>


More information about the xorg mailing list