dwm-combo-6.1.diff (1867B)
1 diff --git a/dwm.c b/dwm.c 2 index 0362114..40b7a99 100644 3 --- a/dwm.c 4 +++ b/dwm.c 5 @@ -234,6 +234,11 @@ static int xerrordummy(Display *dpy, XErrorEvent *ee); 6 static int xerrorstart(Display *dpy, XErrorEvent *ee); 7 static void zoom(const Arg *arg); 8 9 +static void keyrelease(XEvent *e); 10 +static void combotag(const Arg *arg); 11 +static void comboview(const Arg *arg); 12 + 13 + 14 /* variables */ 15 static const char broken[] = "broken"; 16 static char stext[256]; 17 @@ -244,6 +249,7 @@ static int (*xerrorxlib)(Display *, XErrorEvent *); 18 static unsigned int numlockmask = 0; 19 static void (*handler[LASTEvent]) (XEvent *) = { 20 [ButtonPress] = buttonpress, 21 + [ButtonRelease] = keyrelease, 22 [ClientMessage] = clientmessage, 23 [ConfigureRequest] = configurerequest, 24 [ConfigureNotify] = configurenotify, 25 @@ -251,6 +257,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { 26 [EnterNotify] = enternotify, 27 [Expose] = expose, 28 [FocusIn] = focusin, 29 + [KeyRelease] = keyrelease, 30 [KeyPress] = keypress, 31 [MappingNotify] = mappingnotify, 32 [MapRequest] = maprequest, 33 @@ -274,6 +281,42 @@ static Window root; 34 struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; 35 36 /* function implementations */ 37 +static int combo = 0; 38 + 39 +void 40 +keyrelease(XEvent *e) { 41 + combo = 0; 42 +} 43 + 44 +void 45 +combotag(const Arg *arg) { 46 + if(selmon->sel && arg->ui & TAGMASK) { 47 + if (combo) { 48 + selmon->sel->tags |= arg->ui & TAGMASK; 49 + } else { 50 + combo = 1; 51 + selmon->sel->tags = arg->ui & TAGMASK; 52 + } 53 + focus(NULL); 54 + arrange(selmon); 55 + } 56 +} 57 + 58 +void 59 +comboview(const Arg *arg) { 60 + unsigned newtags = arg->ui & TAGMASK; 61 + if (combo) { 62 + selmon->tagset[selmon->seltags] |= newtags; 63 + } else { 64 + selmon->seltags ^= 1; /*toggle tagset*/ 65 + combo = 1; 66 + if (newtags) 67 + selmon->tagset[selmon->seltags] = newtags; 68 + } 69 + focus(NULL); 70 + arrange(selmon); 71 +} 72 + 73 void 74 applyrules(Client *c) 75 {