[Xcb] Window transparency and clearing a window

Uli Schlachter psychon at znc.in
Fri Oct 13 18:06:44 UTC 2017


Hi,

first of: This is not really a XCB question, but I guess there aren't
that many questions where one can ask X11 questions.

On 10.10.2017 00:49, Sheheryar Parvaz wrote:
[...]
> For transparency, I can't seem to figure out how to make the window transparent. Even pseudo-transparency would be fine. I've heard of the possibility of copying the root pixmap, but have no idea how to do so.

For pseudo-transparency, the convention is to save the pixmap XID in the
_XROOTPMAP_ID (or ESETROOT_PMAP_ID) property of the root window. With
that, you can just copy the contents of this pixmap to your window. To
handle changes to the background, you'd have to monitor PropertyNotify
message on the root window to get informed when the value of this
property changes.

If this property is not there, you are out of luck.

[...]> Every time Cairo draws to the surface, it overwrites what was
previously there. This is probably due to the fact that the window isn't
truly transparent, and so isn't being cleared.
> 
> 
> Could someone explain how to create a transparent XCB window or simulate it?

You want a window with depth 32. If you have that (and correctly tell
cairo about it), you can just cairo to draw a transparent background
[1]. Note that this only works if a compositing manager is running,
otherwise the visible results will be equivalent to a black background
(I think). The convention to check if a compositing manager is running
is to check if the _NET_WM_CM_Sn selection is owned. See ICCCM for
details (or be lazy and copy from [2], but please honour the GPL).

Cheers,
Uli

[1]: cairo_set_source_rgba(cr, 0, 0, 0, 0); cairo_set_operator(cr,
CAIRO_OPERATOR_SOURCE); cairo_paint(cr);
[2]:
https://github.com/awesomeWM/awesome/blob/a1376557917a8859222c49f59ba42373c02905c7/luaa.c#L179-L211
-- 
- He made himself, me nothing, you nothing out of the dust
- Er machte sich mir nichts, dir nichts aus dem Staub


More information about the Xcb mailing list