From 30f405da4e8932b91d3b27dbe3da794e2eaab2a7 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Sun, 16 Nov 2014 20:29:51 -0500 Subject: [PATCH] make non-focused windows translucent --- dwm.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/dwm.c b/dwm.c index f896170..31fad43 100644 --- a/dwm.c +++ b/dwm.c @@ -60,7 +60,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { SchemeNorm, SchemeSel, SchemeLast }; /* color schemes */ enum { NetSupported, NetWMName, NetWMState, - NetWMFullscreen, NetActiveWindow, NetWMWindowType, + NetWMFullscreen, NetWMWindowOpacity, NetActiveWindow, NetWMWindowType, NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */ enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */ enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, @@ -267,6 +267,20 @@ static Fnt *fnt; static Monitor *mons, *selmon; static Window root; +// unfocused windows get transparent (feature) +static const unsigned long unfocused_opacity[] = { 0xbfffffff }; +static void window_set_opaque(Client *c); +static void window_set_translucent(Client *c); +void +window_set_opaque(Client *c) { + XChangeProperty(dpy, c->win, netatom[NetWMWindowOpacity], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)unfocused_opacity, 1); +} +void +window_set_translucent(Client *c) { + XDeleteProperty(dpy, c->win, netatom[NetWMWindowOpacity]); +} + + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -784,6 +798,10 @@ focus(Client *c) { /* was if(selmon->sel) */ if(selmon->sel && selmon->sel != c) unfocus(selmon->sel, False); + if(selmon->sel && c!=selmon->sel && c && (!root || (selmon->sel->win!=root && c->win!=root)) ) + window_set_opaque(selmon->sel); + if(c && c!=selmon->sel && (!root || (c->win!=root)) ) + window_set_translucent(c); if(c) { if(c->mon != selmon) selmon = c->mon; @@ -801,6 +819,8 @@ focus(Client *c) { } selmon->sel = c; drawbars(); + if(c) + window_set_translucent(c); } void @@ -1523,6 +1543,7 @@ setup(void) { netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False); netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False); netatom[NetWMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); + netatom[NetWMWindowOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False); netatom[NetWMWindowType] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); netatom[NetWMWindowTypeDialog] = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); netatom[NetClientList] = XInternAtom(dpy, "_NET_CLIENT_LIST", False); -- 1.7.10.4