mirror of
https://github.com/bakkeby/dwm-flexipatch
synced 2024-11-16 21:28:03 +00:00
43 lines
845 B
C
43 lines
845 B
C
|
|
static int useargb = 0;
|
|
static Visual *visual;
|
|
static int depth;
|
|
static Colormap cmap;
|
|
|
|
void
|
|
xinitvisual()
|
|
{
|
|
XVisualInfo *infos;
|
|
XRenderPictFormat *fmt;
|
|
int nitems;
|
|
int i;
|
|
|
|
XVisualInfo tpl = {
|
|
.screen = screen,
|
|
.depth = 32,
|
|
.class = TrueColor
|
|
};
|
|
long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
|
|
|
|
infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
|
|
visual = NULL;
|
|
for (i = 0; i < nitems; i ++) {
|
|
fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
|
|
if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
|
|
visual = infos[i].visual;
|
|
depth = infos[i].depth;
|
|
cmap = XCreateColormap(dpy, root, visual, AllocNone);
|
|
useargb = 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
XFree(infos);
|
|
|
|
if (!visual) {
|
|
visual = DefaultVisual(dpy, screen);
|
|
depth = DefaultDepth(dpy, screen);
|
|
cmap = DefaultColormap(dpy, screen);
|
|
}
|
|
}
|