Quantcast
Channel: Recent Gists from je-so
Viewing all articles
Browse latest Browse all 5

Xlib set transparency of top level window

$
0
0
glxwindow.c
/* Sets the transparency of the toplevel window.
* An alpha value of 1 draws the window opaque a value of 0 makes
* it totally translucent.
* If alpha is set to a value outside of [0..1] EINVAL is returned. */
staticintsettransparency_helper(Display*display, Windowwin, doublealpha)
{
interr ;
if ( alpha<0
||alpha>1) {
LOG_DOUBLE(alpha) ;
err=EINVAL ;
goto ABBRUCH ;
}
uint32_tcardinal_alpha= (uint32_t) (alpha* (uint32_t)-1) ;
if (cardinal_alpha== (uint32_t)-1) {
XDeleteProperty( display, win, XInternAtom( display, "_NET_WM_WINDOW_OPACITY", 0)) ;
} else {
XChangeProperty( display, win, XInternAtom( display, "_NET_WM_WINDOW_OPACITY", 0),
XA_CARDINAL, 32, PropModeReplace, (uint8_t*) &cardinal_alpha, 1) ;
}
return0 ;
ABBRUCH:
LOG_ABORT(err) ;
returnerr ;
}

Viewing all articles
Browse latest Browse all 5

Trending Articles