diff --git a/config.def.h b/config.def.h index 9efa774..b562a5f 100644 --- a/config.def.h +++ b/config.def.h @@ -79,6 +79,7 @@ static const Key keys[] = { { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, + { MODKEY|ControlMask, XK_space, togglealwaysontop, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } }, diff --git a/dwm.c b/dwm.c index f1d86b2..77ebfb2 100644 --- a/dwm.c +++ b/dwm.c @@ -92,7 +92,7 @@ struct Client { int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int bw, oldbw; unsigned int tags; - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + int isfixed, isfloating, isalwaysontop, isurgent, neverfocus, oldstate, isfullscreen; Client *next; Client *snext; Monitor *mon; @@ -209,6 +209,7 @@ static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); +static void togglealwaysontop(const Arg *arg); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void toggletag(const Arg *arg); @@ -738,8 +739,11 @@ drawbar(Monitor *m) if (m->sel) { drw_setscheme(drw, scheme[m == selmon ? SchemeSel : SchemeNorm]); drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0); - if (m->sel->isfloating) + if (m->sel->isfloating) { drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0); + if (m->sel->isalwaysontop) + drw_rect(drw, x + boxs, bh - boxw, boxw, boxw, 0, 0); + } } else { drw_setscheme(drw, scheme[SchemeNorm]); drw_rect(drw, x, 0, w, bh, 1, 1); @@ -1366,6 +1370,11 @@ restack(Monitor *m) return; if (m->sel->isfloating || !m->lt[m->sellt]->arrange) XRaiseWindow(dpy, m->sel->win); + for (c = m->clients; c; c = c->next){ + if (c->isalwaysontop) { + XRaiseWindow(dpy, c->win); + } + } if (m->lt[m->sellt]->arrange) { wc.stack_mode = Below; wc.sibling = m->barwin; @@ -1712,6 +1721,25 @@ tile(Monitor *m) } } +void +togglealwaysontop(const Arg *arg) +{ + if (!selmon->sel) + return; + if (selmon->sel->isfullscreen) + return; + + if (selmon->sel->isalwaysontop) { + selmon->sel->isalwaysontop = 0; + } + else { + selmon->sel->isfloating = 1; + selmon->sel->isalwaysontop = 1; + } + + arrange(selmon); +} + void togglebar(const Arg *arg) { @@ -1732,6 +1760,8 @@ togglefloating(const Arg *arg) if (selmon->sel->isfloating) resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h, 0); + else + selmon->sel->isalwaysontop = 0; /* disabled, turn this off too */ arrange(selmon); }