diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 36 |
1 files changed, 36 insertions, 0 deletions
@@ -208,12 +208,14 @@ static void sendmon(Client *c, Monitor *m); static void setclientstate(Client *c, long state); static void setfocus(Client *c); static void setfullscreen(Client *c, int fullscreen); +static void setlasttag(int tagbit); static void setlayout(const Arg *arg); static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); static void spawn(const Arg *arg); +static void spawndefault(); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void tile(Monitor *m); @@ -280,6 +282,9 @@ static Drw *drw; static Monitor *mons, *selmon; static Window root, wmcheckwin; +static int lastchosentag[8]; +static int previouschosentag[8]; + /* configuration, allows nested code to access above variables */ #include "config.h" @@ -1527,6 +1532,24 @@ setfullscreen(Client *c, int fullscreen) } void +setlasttag(int tagbit) { + const int mon = selmon->num; + if (tagbit > 0) { + int i = 1, pos = 0; + while (!(i & tagbit)) { + i = i << 1; + ++pos; + } + previouschosentag[mon] = lastchosentag[mon]; + lastchosentag[mon] = pos; + } else { + const int tempTag = lastchosentag[mon]; + lastchosentag[mon] = previouschosentag[mon]; + previouschosentag[mon] = tempTag; + } +} + +void setlayout(const Arg *arg) { if (!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) @@ -1891,6 +1914,17 @@ altTabStart(const Arg *arg) } void +spawndefault() +{ + const char *app = defaulttagapps[lastchosentag[selmon->num]]; + if (app) { + const char *defaultcmd[] = {app, NULL}; + Arg a = {.v = defaultcmd}; + spawn(&a); + } +} + +void tag(const Arg *arg) { if (selmon->sel && arg->ui & TAGMASK) { @@ -1990,6 +2024,7 @@ toggleview(const Arg *arg) if (newtagset) { selmon->tagset[selmon->seltags] = newtagset; + setlasttag(newtagset); focus(NULL); arrange(selmon); } @@ -2288,6 +2323,7 @@ view(const Arg *arg) { if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags]) return; + setlasttag(arg->ui); selmon->seltags ^= 1; /* toggle sel tagset */ if (arg->ui & TAGMASK) selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; |
