From fd3549cb320755a105fff055e31f0a36c39483cb Mon Sep 17 00:00:00 2001 From: rafa_99 Date: Sun, 2 Feb 2020 00:32:42 +0000 Subject: Alpha Patch --- dwm.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) (limited to 'dwm.c') diff --git a/dwm.c b/dwm.c index 9ec5209..7b26dd5 100644 --- a/dwm.c +++ b/dwm.c @@ -57,6 +57,8 @@ #define TAGMASK ((1 << LENGTH(tags)) - 1) #define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad) +#define OPAQUE 0xffU + /* enums */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel }; /* color schemes */ @@ -246,6 +248,7 @@ static Monitor *wintomon(Window w); static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); +static void xinitvisual(); static void zoom(const Arg *arg); /* variables */ @@ -285,6 +288,11 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; +static int useargb = 0; +static Visual *visual; +static int depth; +static Colormap cmap; + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -1667,7 +1675,8 @@ setup(void) sw = DisplayWidth(dpy, screen); sh = DisplayHeight(dpy, screen); root = RootWindow(dpy, screen); - drw = drw_create(dpy, screen, root, sw, sh); + xinitvisual(); + drw = drw_create(dpy, screen, root, sw, sh, visual, depth, cmap); if (!drw_fontset_create(drw, fonts, LENGTH(fonts))) die("no fonts could be loaded."); lrpad = drw->fonts->h; @@ -1698,7 +1707,7 @@ setup(void) /* init appearance */ scheme = ecalloc(LENGTH(colors), sizeof(Clr *)); for (i = 0; i < LENGTH(colors); i++) - scheme[i] = drw_scm_create(drw, colors[i], 3); + scheme[i] = drw_scm_create(drw, colors[i], alphas[i], 3); /* init bars */ updatebars(); updatestatus(); @@ -1940,7 +1949,9 @@ updatebars(void) Monitor *m; XSetWindowAttributes wa = { .override_redirect = True, - .background_pixmap = ParentRelative, + .background_pixel = 0, + .border_pixel = 0, + .colormap = cmap, .event_mask = ButtonPressMask|ExposureMask }; XClassHint ch = {"dwm", "dwm"}; @@ -2246,6 +2257,43 @@ xerrorstart(Display *dpy, XErrorEvent *ee) return -1; } +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); + } +} + void zoom(const Arg *arg) { -- cgit v1.2.3