diff options
| author | Mouad Alami <moadalami40@gmail.com> | 2023-09-12 15:36:03 +0100 |
|---|---|---|
| committer | Mouad Alami <moadalami40@gmail.com> | 2023-09-12 15:36:03 +0100 |
| commit | b0c17bbe25e022e3de907c7361e9d9883cd78ffd (patch) | |
| tree | dc7dd33a060503f97281cbcd99953a9b84873234 /dwm.c | |
| parent | 48c4a82ec30a106e9cab7d6bb2f6bfc99fa28094 (diff) | |
added alternative tags patch
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -132,6 +132,7 @@ struct Monitor { Window barwin; const Layout *lt[2]; Pertag *pertag; + unsigned int alttag; }; typedef struct { @@ -181,6 +182,7 @@ static void grabbuttons(Client *c, int focused); static void grabkeys(void); static void incnmaster(const Arg *arg); static void keypress(XEvent *e); +static void keyrelease(XEvent *e); static void killclient(const Arg *arg); static void manage(Window w, XWindowAttributes *wa); static void mappingnotify(XEvent *e); @@ -215,6 +217,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 togglealttag(const Arg *arg); static void togglebar(const Arg *arg); static void togglefloating(const Arg *arg); static void togglesticky(const Arg *arg); @@ -266,6 +269,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [Expose] = expose, [FocusIn] = focusin, [KeyPress] = keypress, + [KeyRelease] = keyrelease, [MappingNotify] = mappingnotify, [MapRequest] = maprequest, [MotionNotify] = motionnotify, @@ -762,7 +766,7 @@ dirtomon(int dir) void drawbar(Monitor *m) { - int x, w, tw = 0; + int x, w, wdelta, tw = 0; int boxs = drw->fonts->h / 9; int boxw = drw->fonts->h / 6 + 2; unsigned int i, occ = 0, urg = 0; @@ -804,8 +808,9 @@ drawbar(Monitor *m) if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i)) continue; w = TEXTW(tags[i]); + wdelta = selmon->alttag ? abs(TEXTW(tags[i]) - TEXTW(tagsalt[i])) / 2 : 0; drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]); - drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i); + drw_text(drw, x, 0, w, bh, wdelta + lrpad / 2, (selmon->alttag ? tagsalt[i] : tags[i]), urg & 1 << i); x += w; } w = TEXTW(m->ltsymbol); @@ -1129,6 +1134,25 @@ keypress(XEvent *e) } void +keyrelease(XEvent *e) +{ + unsigned int i; + KeySym keysym; + XKeyEvent *ev; + + ev = &e->xkey; + keysym = XKeycodeToKeysym(dpy, (KeyCode)ev->keycode, 0); + + for (i = 0; i < LENGTH(keys); i++) + if (momentaryalttags + && keys[i].func && keys[i].func == togglealttag + && selmon->alttag + && (keysym == keys[i].keysym + || CLEANMASK(keys[i].mod) == CLEANMASK(ev->state))) + keys[i].func(&(keys[i].arg)); +} + +void killclient(const Arg *arg) { if (!selmon->sel) @@ -1884,6 +1908,13 @@ tile(Monitor *m) } void +togglealttag(const Arg *arg) +{ + selmon->alttag = !selmon->alttag; + drawbar(selmon); +} + +void togglebar(const Arg *arg) { selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar; |
