[cairo] Problem in cairo + xcb where alpha blending is cumulative (becoming more opaque with each render)

Ryan Flannery ryan.flannery at gmail.com
Fri Sep 28 02:24:42 UTC 2018

On Thu, Sep 27, 2018 at 3:56 AM, Uli Schlachter <psychon at znc.in> wrote:

> Hi,
> On 26.09.2018 07:51, Ryan Flannery wrote:
> > The raw transparency piece works fine and is
> > easy in cairo + xcb,
> sorry to tell you this, but the problem is in the raw transparency part.
> You only *think* that you have transparency. Also, "is easy" is the
> total opposite of the truth. Again, sorry.
> When a new window is mapped, its content is undefined. In practice this
> means that the window contains whatever was visible at this position
> before. Thus, you think you have transparency when you draw ontop of
> this. However, this is wrong.


I was digging into a totally different path. After reading this, I dove
into what you described and now have a good handle on the issue. I can now
detect if it's supported and apply the alpha blending only when it is. Also
I learned what compositing window managers are and now have these sweet
transparent urxvt terminals :D (though I doubt I'll keep them).

Many thanks again. You saved me many more hours and headaches before I
would have arrived at this.

Try apply the attached patch move.patch. What this patch does is to wait
> for the window to become visible and then it moves the window. You will
> notice that together with the window, its content is moved. Thus, making
> it obvious that your transparency does not work.
> The black background that you see is the working case *if your window
> had an alpha channel*. Because it does not have an alpha channel, you
> only see black.
> To create a transparent window in X11, first of all, the user has to be
> using a compositing manager (compiz, compton, xcompmgr, ...). Without
> this, there is no real transparency. The _NET_WM_CMs selection can be
> used to figure out if a compositing manager is running.
> Next, you need to create a window with a 32bit visual (and also tell
> cairo that your window is using this visual). For this part, I refer you
> to:
> https://stackoverflow.com/questions/3645632/how-to-
> create-a-window-with-a-bit-depth-of-32
> The attached patch fix.patch gives me a window with either a black
> background (if no compositing manager is running) or a transparent black
> background (if a compositing manager is running; I used compton).

Thanks for the patch and stackoverflow link. That both solved the issue in
my example program and also cleaned up a couple things, like applying
OVERRIDE_REDIRECT when I create the window rather than later.

Many thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20180927/e9fa180c/attachment.html>

More information about the cairo mailing list