diff -Naur old/config.def.h new/config.def.h --- old/config.def.h 2015-12-13 23:25:31.809649303 +0000 +++ new/config.def.h 2015-12-13 23:10:04.011248379 +0000 @@ -11,6 +11,8 @@ static const char selbordercolor[] = "#005577"; static const char selbgcolor[] = "#005577"; static const char selfgcolor[] = "#eeeeee"; +static const char normmarkcolor[] = "#ff0000"; +static const char selmarkcolor[] = "#ff00ff"; static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ @@ -68,7 +70,8 @@ { MODKEY, XK_d, incnmaster, {.i = -1 } }, { MODKEY, XK_h, setmfact, {.f = -0.05} }, { MODKEY, XK_l, setmfact, {.f = +0.05} }, - { MODKEY, XK_Return, zoom, {0} }, + { MODKEY, XK_Return, swap, {0} }, + { MODKEY, XK_semicolon, setmark, {.i = 1} }, { MODKEY, XK_Tab, view, {0} }, { MODKEY|ShiftMask, XK_c, killclient, {0} }, { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, diff -Naur old/drw.h new/drw.h --- old/drw.h 2015-11-08 22:39:37.000000000 +0000 +++ new/drw.h 2015-12-13 22:59:53.387882222 +0000 @@ -23,6 +23,7 @@ Clr *fg; Clr *bg; Clr *border; + Clr *mark; } ClrScheme; typedef struct { diff -Naur old/dwm.c new/dwm.c --- old/dwm.c 2015-11-08 22:39:37.000000000 +0000 +++ new/dwm.c 2015-12-13 23:21:13.226882033 +0000 @@ -93,6 +93,7 @@ int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + int ismarked; Client *next; Client *snext; Monitor *mon; @@ -127,6 +128,7 @@ Client *clients; Client *sel; Client *stack; + Client *mark; Monitor *next; Window barwin; const Layout *lt[2]; @@ -201,11 +203,13 @@ static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); static void setlayout(const Arg *arg); +static void setmark(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void showhide(Client *c); static void sigchld(int unused); static void spawn(const Arg *arg); +static void swap(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *); @@ -485,6 +489,7 @@ drw_clr_free(scheme[i].border); drw_clr_free(scheme[i].bg); drw_clr_free(scheme[i].fg); + drw_clr_free(scheme[i].mark); } drw_free(drw); XSync(dpy, False); @@ -807,7 +812,10 @@ detachstack(c); attachstack(c); grabbuttons(c, 1); - XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix); + if (c->ismarked) + XSetWindowBorder(dpy, c->win, scheme[SchemeSel].mark->pix); + else + XSetWindowBorder(dpy, c->win, scheme[SchemeSel].border->pix); setfocus(c); } else { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); @@ -1018,6 +1026,10 @@ { if (!selmon->sel) return; + if (selmon->mark == selmon->sel) { + selmon->mark->ismarked = 0; + selmon->mark = 0; + } if (!sendevent(selmon->sel, wmatom[WMDelete])) { XGrabServer(dpy); XSetErrorHandler(xerrordummy); @@ -1065,7 +1077,10 @@ wc.border_width = c->bw; XConfigureWindow(dpy, w, CWBorderWidth, &wc); - XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix); + if (c->ismarked) + XSetWindowBorder(dpy, w, scheme[SchemeNorm].mark->pix); + else + XSetWindowBorder(dpy, w, scheme[SchemeNorm].border->pix); configure(c); /* propagates border_width, if size doesn't change */ updatewindowtype(c); updatesizehints(c); @@ -1528,6 +1543,29 @@ drawbar(selmon); } +void +setmark(const Arg *arg) +{ + if (!selmon->sel) + return; + if (selmon->sel == selmon->mark) { + selmon->mark->ismarked = 0; + XSetWindowBorder(dpy, selmon->mark->win, scheme[SchemeSel].border->pix); + selmon->mark = 0; + } else { + if (selmon->mark) { + selmon->mark->ismarked = 0; + XSetWindowBorder(dpy, selmon->mark->win, scheme[SchemeNorm].border->pix); + selmon->mark = 0; + } + if (arg && arg->i) { + selmon->sel->ismarked = 1; + XSetWindowBorder(dpy, selmon->sel->win, scheme[SchemeSel].mark->pix); + selmon->mark = selmon->sel; + } + } +} + /* arg > 1.0 will set mfact absolutly */ void setmfact(const Arg *arg) @@ -1583,9 +1621,11 @@ scheme[SchemeNorm].border = drw_clr_create(drw, normbordercolor); scheme[SchemeNorm].bg = drw_clr_create(drw, normbgcolor); scheme[SchemeNorm].fg = drw_clr_create(drw, normfgcolor); + scheme[SchemeNorm].mark = drw_clr_create(drw, normmarkcolor); scheme[SchemeSel].border = drw_clr_create(drw, selbordercolor); scheme[SchemeSel].bg = drw_clr_create(drw, selbgcolor); scheme[SchemeSel].fg = drw_clr_create(drw, selfgcolor); + scheme[SchemeSel].mark = drw_clr_create(drw, selmarkcolor); /* init bars */ updatebars(); updatestatus(); @@ -1646,6 +1686,36 @@ } void +swap(const Arg *arg) +{ + Client **ts, **tm, *c; + + if (!selmon->mark) { + zoom(0); + return; + } + + if (!selmon->sel || selmon->mark == selmon->sel) + return; + if (!selmon->lt[selmon->sellt]->arrange || (selmon->sel->isfloating)) + return; + + for (ts = &selmon->clients; *ts != selmon->sel; ts = &(*ts)->next); + for (tm = &selmon->clients; *tm != selmon->mark; tm = &(*tm)->next); + + c = *ts; + *ts = *tm; + *tm = c; + + c = selmon->sel->next; + selmon->sel->next = selmon->mark->next; + selmon->mark->next = c; + + setmark(0); + arrange(selmon); +} + +void tag(const Arg *arg) { if (selmon->sel && arg->ui & TAGMASK) { @@ -1745,7 +1815,10 @@ if (!c) return; grabbuttons(c, 0); - XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix); + if (c->ismarked) + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].mark->pix); + else + XSetWindowBorder(dpy, c->win, scheme[SchemeNorm].border->pix); if (setfocus) { XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime); XDeleteProperty(dpy, root, netatom[NetActiveWindow]);