diff options
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -350,6 +350,11 @@ static Client *termforwin(const Client *c); static pid_t winpid(Window w); +static void keyrelease(XEvent *e); +static void combotag(const Arg *arg); +static void comboview(const Arg *arg); + + /* variables */ static Systray *systray = NULL; static Client *prevzoom = NULL; @@ -371,6 +376,7 @@ static int enableoutergaps = 1; static int lrpad; /* sum of left and right padding for text */ static void (*handler[LASTEvent]) (XEvent *) = { [ButtonPress] = buttonpress, + [ButtonRelease] = keyrelease, [ClientMessage] = clientmessage, [ConfigureRequest] = configurerequest, [ConfigureNotify] = configurenotify, @@ -378,6 +384,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [EnterNotify] = enternotify, [Expose] = expose, [FocusIn] = focusin, + [KeyRelease] = keyrelease, [KeyPress] = keypress, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, @@ -415,6 +422,42 @@ struct Pertag { struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; /* function implementations */ +static int combo = 0; + +void +keyrelease(XEvent *e) { + combo = 0; +} + +void +combotag(const Arg *arg) { + if(selmon->sel && arg->ui & TAGMASK) { + if (combo) { + selmon->sel->tags |= arg->ui & TAGMASK; + } else { + combo = 1; + selmon->sel->tags = arg->ui & TAGMASK; + } + focus(NULL); + arrange(selmon); + } +} + +void +comboview(const Arg *arg) { + unsigned newtags = arg->ui & TAGMASK; + if (combo) { + selmon->tagset[selmon->seltags] |= newtags; + } else { + selmon->seltags ^= 1; /*toggle tagset*/ + combo = 1; + if (newtags) + selmon->tagset[selmon->seltags] = newtags; + } + focus(NULL); + arrange(selmon); +} + void applyrules(Client *c) { |