0

So using the code here Why I set xlib window background transparent failed? I have a transparent window.

What I want though is to have a semi transparent window background, how can i do this with c and xlib?

If it helps, I'm using the compton compositor for my desktop enviroment.

Community
  • 1
  • 1
Keith M
  • 1,199
  • 2
  • 18
  • 38
  • just draw your background with some alpha value ( note that in x it's pre-multiplied - https://en.wikipedia.org/wiki/Alpha_compositing#Description ). With pure xlib ( no xrender / glx ) your only option is to prepare 32 bit RGBA data on the client and then draw in onto window or offcxrin pixmap using XPutImage call – Andrey Sidorov Nov 09 '15 at 22:31

1 Answers1

0

As far as I can find, it's impossible to do this in pure xlib. Instead you need to use OpenGL and set the clear color to semitransparent/argb when you draw the window:

glClearColor (0.7, 0.7, 0.7, 0.7);
glClear (GL_COLOR_BUFFER_BIT);
glXSwapBuffers (display, win);
glXWaitGL ();

There is an example here as to how to draw a window in XLib using OpenGL: https://gist.github.com/je-so/903479

Keith M
  • 1,199
  • 2
  • 18
  • 38
  • no, transparency in X has nothing to do with opengl ( though compositing managers often use gl for hardware accelerated blending ). It's completely up to composite manager how to handle RGBA data of a drawables. From the client point of view you just set alpha value of pixels, no magic ( and this can be achieved with xlib, xrender or opengl and probably with many other ways ) – Andrey Sidorov Nov 09 '15 at 22:34