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,
static void motionnotify(XEvent *e);
static void movemouse(const Arg *arg);
static Client *nexttiled(Client *c);
+static Client *nextvisible(Client *c);
static void pop(Client *);
static void propertynotify(XEvent *e);
static void quit(const Arg *arg);
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) {
+ XDeleteProperty(dpy, c->win, netatom[NetWMWindowOpacity]);
+}
+void
+window_set_translucent(Client *c) {
+ XChangeProperty(dpy, c->win, netatom[NetWMWindowOpacity], XA_CARDINAL, 32, PropModeReplace, (unsigned char *)unfocused_opacity, 1);
+}
+
+
/* configuration, allows nested code to access above variables */
#include "config.h"
void
attach(Client *c) {
- c->next = c->mon->clients;
- c->mon->clients = c;
+ if (c->mon->sel) {
+ c->next = c->mon->sel->next;
+ c->mon->sel->next = c;
+ } else {
+ c->next = c->mon->clients;
+ c->mon->clients = c;
+ }
}
void
*tc = c->next;
}
+// NOTE: the stack is for z-order and most-recently-focused
+// only mon->clients determines position in visible layout
void
detachstack(Client *c) {
- Client **tc, *t;
-
- for(tc = &c->mon->stack; *tc && *tc != c; tc = &(*tc)->snext);
- *tc = c->snext;
-
+ Client *prev = NULL, *next_sel = NULL, *i;
+ for(i = c->mon->stack; i && i != c; i = i->snext) {
+ prev = i;
+ }
if(c == c->mon->sel) {
- for(t = c->mon->stack; t && !ISVISIBLE(t); t = t->snext);
- c->mon->sel = t;
+ // find last visible window before c
+ // WARNING if you detach() before detachstack() this will select last visible window
+ for(i = nextvisible(c->mon->clients); i && i != c; i = nextvisible(i->next))
+ next_sel = i;
+ // failing that, find first visible window
+ if (!next_sel)
+ for(i = nextvisible(c->mon->clients); i && i != c; i = nextvisible(i->next))
+ next_sel = i;
+ c->mon->sel = next_sel;
+ }
+ if (prev) {
+ prev->snext = c->snext;
+ } else {
+ c->mon->stack = c->snext;
}
}
}
selmon->sel = c;
drawbars();
+ if(c && (!root || (c->win!=root)) )
+ window_set_opaque(c);
}
void
if(!selmon->sel)
return;
- if(arg->i > 0) {
+ if(arg->i == 0) {
+ for(i = selmon->clients; i != selmon->sel; i = i->next) {
+ if(ISVISIBLE(i)) {
+ c = i;
+ break;
+ }
+ }
+ } else if(arg->i > 0) {
for(c = selmon->sel->next; c && !ISVISIBLE(c); c = c->next);
if(!c)
for(c = selmon->clients; c && !ISVISIBLE(c); c = c->next);
c->mon->sel = c;
arrange(c->mon);
XMapWindow(dpy, c->win);
- focus(NULL);
+ focus(c);
}
void
return c;
}
+Client *
+nextvisible(Client *c) {
+ for(; c && !ISVISIBLE(c); c = c->next);
+ return c;
+}
+
void
pop(Client *c) {
detach(c);
if(c->mon == m)
return;
unfocus(c, True);
- detach(c);
detachstack(c);
+ detach(c);
c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
attach(c);
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);
unfocus(Client *c, Bool setfocus) {
if(!c)
return;
+ if(!root || c->win!=root)
+ window_set_translucent(c);
grabbuttons(c, False);
XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->rgb);
if(setfocus) {
XWindowChanges wc;
/* The server grab construct avoids race conditions. */
- detach(c);
detachstack(c);
+ detach(c);
if(!destroyed) {
wc.border_width = c->oldbw;
XGrabServer(dpy);
XUngrabServer(dpy);
}
free(c);
- focus(NULL);
+ focus(selmon ? selmon->sel : NULL);
updateclientlist();
arrange(m);
}