dwm

Kris's build of dwm
git clone git clone https://git.krisyotam.com/krisyotam/dwm.git
Log | Files | Refs | README | LICENSE

bar_alpha.c (846B)


      1 
      2 static int useargb = 0;
      3 static Visual *visual;
      4 static int depth;
      5 static Colormap cmap;
      6 
      7 void
      8 xinitvisual()
      9 {
     10 	XVisualInfo *infos;
     11 	XRenderPictFormat *fmt;
     12 	int nitems;
     13 	int i;
     14 
     15 	XVisualInfo tpl = {
     16 		.screen = screen,
     17 		.depth = 32,
     18 		.class = TrueColor
     19 	};
     20 	long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
     21 
     22 	infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
     23 	visual = NULL;
     24 	for (i = 0; i < nitems; i ++) {
     25 		fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
     26 		if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
     27 			visual = infos[i].visual;
     28 			depth = infos[i].depth;
     29 			cmap = XCreateColormap(dpy, root, visual, AllocNone);
     30 			useargb = 1;
     31 			break;
     32 		}
     33 	}
     34 
     35 	XFree(infos);
     36 
     37 	if (!visual) {
     38 		visual = DefaultVisual(dpy, screen);
     39 		depth = DefaultDepth(dpy, screen);
     40 		cmap = DefaultColormap(dpy, screen);
     41 	}
     42 }
     43