summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/dwm.c b/dwm.c
index c1540f3..3eab607 100644
--- a/dwm.c
+++ b/dwm.c
@@ -68,7 +68,7 @@ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { NetSupported, NetWMName, NetWMState, NetWMCheck,
NetWMFullscreen, NetActiveWindow, NetWMWindowType,
- NetWMWindowTypeDialog, NetClientList, NetLast }; /* EWMH atoms */
+ NetWMWindowTypeDialog, NetClientList, NetWMWindowsOpacity, NetLast }; /* EWMH atoms */
enum { WMProtocols, WMDelete, WMState, WMTakeFocus, WMLast }; /* default atoms */
enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -200,6 +200,7 @@ static void moveresize(const Arg *arg);
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
+static void opacity(Client *c, double opacity);
static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
@@ -230,6 +231,7 @@ static void tagtoleft(const Arg *arg);
static void tagtoright(const Arg *arg);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
+static void toggleopacity(const Arg *arg);
static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus);
@@ -896,6 +898,7 @@ focus(Client *c)
grabbuttons(c, 1);
XSetWindowBorder(dpy, c->win, scheme[SchemeSel][ColBorder].pixel);
setfocus(c);
+ opacity(c, activeopacity);
} else {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
@@ -1368,6 +1371,18 @@ nexttiled(Client *c)
}
void
+opacity(Client *c, double opacity)
+{
+ if(bUseOpacity && opacity > 0 && opacity < 1) {
+ unsigned long real_opacity[] = { opacity * 0xffffffff };
+ XChangeProperty(dpy, c->win, netatom[NetWMWindowsOpacity], XA_CARDINAL,
+ 32, PropModeReplace, (unsigned char *)real_opacity,
+ 1);
+ } else
+ XDeleteProperty(dpy, c->win, netatom[NetWMWindowsOpacity]);
+}
+
+void
pop(Client *c)
{
detach(c);
@@ -1745,6 +1760,7 @@ setup(void)
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);
+ netatom[NetWMWindowsOpacity] = XInternAtom(dpy, "_NET_WM_WINDOW_OPACITY", False);
/* init cursors */
cursor[CurNormal] = drw_cur_create(drw, XC_left_ptr);
cursor[CurResize] = drw_cur_create(drw, XC_sizing);
@@ -1889,6 +1905,14 @@ togglefloating(const Arg *arg)
}
void
+toggleopacity(const Arg *arg) {
+ bUseOpacity = !bUseOpacity;
+ for (Monitor* m = mons; m; m = m->next)
+ for (Client* c = m->clients; c; c = c->next)
+ opacity(c, (bUseOpacity && c != selmon->sel) ? inactiveopacity : activeopacity);
+}
+
+void
toggletag(const Arg *arg)
{
unsigned int newtags;
@@ -1921,6 +1945,7 @@ unfocus(Client *c, int setfocus)
if (!c)
return;
grabbuttons(c, 0);
+ opacity(c, inactiveopacity);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm][ColBorder].pixel);
if (setfocus) {
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);