diff options
| author | bakkeby <[email protected]> | 2020-08-13 15:42:49 +0200 |
|---|---|---|
| committer | bakkeby <[email protected]> | 2020-08-13 15:42:49 +0200 |
| commit | de47bd8839e3a7fc48663b3b530b33fd4042596c (patch) | |
| tree | 6a2f4aba99c94df1bbc78149bf2265448d20ef1b /patch | |
| parent | 57e727b498e2916abdd7b819084c01c1db0f641b (diff) | |
| download | dwm-flexipatch-de47bd8839e3a7fc48663b3b530b33fd4042596c.tar.gz dwm-flexipatch-de47bd8839e3a7fc48663b3b530b33fd4042596c.zip | |
Adding bartabgroups patch
Diffstat (limited to 'patch')
| -rw-r--r-- | patch/bar_awesomebar.c | 97 | ||||
| -rw-r--r-- | patch/bar_awesomebar.h | 8 | ||||
| -rw-r--r-- | patch/bar_tabgroups.c | 170 | ||||
| -rw-r--r-- | patch/bar_tabgroups.h | 21 | ||||
| -rw-r--r-- | patch/bar_wintitleactions.c | 89 | ||||
| -rw-r--r-- | patch/bar_wintitleactions.h | 7 | ||||
| -rw-r--r-- | patch/include.c | 6 | ||||
| -rw-r--r-- | patch/include.h | 6 |
8 files changed, 303 insertions, 101 deletions
diff --git a/patch/bar_awesomebar.c b/patch/bar_awesomebar.c index 75155fb..d8a11e9 100644 --- a/patch/bar_awesomebar.c +++ b/patch/bar_awesomebar.c @@ -48,13 +48,12 @@ draw_awesomebar(Bar *bar, BarDrawArg *a) #endif // BAR_VTCOLORS_PATCH drw_setscheme(drw, scheme[scm]); - tabw += (i < remainder ? 1 : 0); #if BAR_PANGO_PATCH - drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0, False); + drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False); #else - drw_text(drw, x, 0, tabw, bh, lrpad / 2, c->name, 0); + drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0); #endif // BAR_PANGO_PATCH - x += tabw; + x += tabw + (i < remainder ? 1 : 0); } } return a->x + a->w; @@ -84,94 +83,4 @@ click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a) return ClkWinTitle; } return -1; -} - -void -hide(Client *c) { - - Client *n; - if (!c || HIDDEN(c)) - return; - - Window w = c->win; - static XWindowAttributes ra, ca; - - // more or less taken directly from blackbox's hide() function - XGrabServer(dpy); - XGetWindowAttributes(dpy, root, &ra); - XGetWindowAttributes(dpy, w, &ca); - // prevent UnmapNotify events - XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); - XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); - XUnmapWindow(dpy, w); - setclientstate(c, IconicState); - XSelectInput(dpy, root, ra.your_event_mask); - XSelectInput(dpy, w, ca.your_event_mask); - XUngrabServer(dpy); - - if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { - for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); - if (!n) - for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); - } else { - n = nexttiled(c); - if (!n) - n = prevtiled(c); - } - focus(n); - arrange(c->mon); -} - -void -show(Client *c) -{ - if (!c || !HIDDEN(c)) - return; - - XMapWindow(dpy, c->win); - setclientstate(c, NormalState); - arrange(c->mon); -} - -void -togglewin(const Arg *arg) -{ - Client *c = (Client*)arg->v; - if (!c) - return; - if (c == selmon->sel) - hide(c); - else { - if (HIDDEN(c)) - show(c); - focus(c); - restack(selmon); - } -} - -Client * -prevtiled(Client *c) -{ - Client *p, *i; - for (p = NULL, i = c->mon->clients; c && i != c; i = i->next) - if (ISVISIBLE(i) && !HIDDEN(i)) - p = i; - return p; -} - -void -showhideclient(const Arg *arg) -{ - Client *c = (Client*)arg->v; - if (!c) - c = selmon->sel; - if (!c) - return; - - if (HIDDEN(c)) { - show(c); - restack(selmon); - } else { - hide(c); - } }
\ No newline at end of file diff --git a/patch/bar_awesomebar.h b/patch/bar_awesomebar.h index 83572f6..3269954 100644 --- a/patch/bar_awesomebar.h +++ b/patch/bar_awesomebar.h @@ -1,9 +1,3 @@ static int width_awesomebar(Bar *bar, BarWidthArg *a); static int draw_awesomebar(Bar *bar, BarDrawArg *a); -static int click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a); - -static void hide(Client *c); -static void show(Client *c); -static void togglewin(const Arg *arg); -static Client *prevtiled(Client *c); -static void showhideclient(const Arg *arg);
\ No newline at end of file +static int click_awesomebar(Bar *bar, Arg *arg, BarClickArg *a);
\ No newline at end of file diff --git a/patch/bar_tabgroups.c b/patch/bar_tabgroups.c new file mode 100644 index 0000000..c5a0e43 --- /dev/null +++ b/patch/bar_tabgroups.c @@ -0,0 +1,170 @@ +int +width_bartabgroups(Bar *bar, BarWidthArg *a) +{ + return a->max_width; +} + +int +draw_bartabgroups(Bar *bar, BarDrawArg *a) +{ + drw_rect(drw, a->x, 0, a->w, bh, 1, 1); + bartabcalculate(bar->mon, a->x, a->w, -1, bartabdraw, NULL); + return a->x + a->w; +} + +int +click_bartabgroups(Bar *bar, Arg *arg, BarClickArg *a) +{ + bartabcalculate(bar->mon, 0, a->rel_w, a->rel_x, bartabclick, arg); + return ClkWinTitle; +} + +void +bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg) +{ + if (!c) + return; + int i, nclienttags = 0, nviewtags = 0; + drw_setscheme(drw, scheme[ + m->sel == c + ? SchemeSel + #if BAR_WINTITLEACTIONS_PATCH + : HIDDEN(c) + ? SchemeHid + #endif // BAR_WINTITLEACTIONS_PATCH + : groupactive + ? SchemeTabActive + : SchemeTabInactive + ]); + drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0); + if (c->isfloating) + drw_rect(drw, x + 2, 2, 5, 5, 0, 0); + + if (BARTAB_BORDERS) { + XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, 0, 1, bh); + XFillRectangle(drw->dpy, drw->drawable, drw->gc, x + w, 0, 1, bh); + } + /* Optional tags icons */ + for (i = 0; i < LENGTH(tags); i++) { + if ((m->tagset[m->seltags] >> i) & 1) + nviewtags++; + if ((c->tags >> i) & 1) + nclienttags++; + } + + if (BARTAB_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1) { + for (i = 0; i < LENGTH(tags); i++) { + drw_rect(drw, + ( x + w - 2 - ((LENGTH(tags) / BARTAB_TAGSROWS) * BARTAB_TAGSPX) + - (i % (LENGTH(tags)/BARTAB_TAGSROWS)) + ((i % (LENGTH(tags) / BARTAB_TAGSROWS)) * BARTAB_TAGSPX) + ), + ( 2 + ((i / (LENGTH(tags)/BARTAB_TAGSROWS)) * BARTAB_TAGSPX) + - ((i / (LENGTH(tags)/BARTAB_TAGSROWS))) + ), + BARTAB_TAGSPX, BARTAB_TAGSPX, (c->tags >> i) & 1, 0 + ); + } + } +} + +void +bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg) +{ + if (passx >= x && passx <= x + w) + arg->v = c; +} + +void +bartabcalculate( + Monitor *m, int offx, int tabw, int passx, + void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg +) { + Client *c; + int + i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0, + masteractive = 0, fulllayout = 0, + x = offx, w, r, num = 0, den, tgactive; + + for (i = 0; i < LENGTH(bartabmonfns); i++) + if (m ->lt[m->sellt]->arrange == bartabmonfns[i]) { + fulllayout = 1; + break; + } + + for (i = 0, c = m->clients; c; c = c->next) { + if (!ISVISIBLE(c)) + continue; + if (c->isfloating) { + clientsnfloating++; + continue; + } + if (m->sel == c) + masteractive = i < m->nmaster; + if (i < m->nmaster) + clientsnmaster++; + else + clientsnstack++; + i++; + } + + if (!i) + return; + + /* floating mode */ + if (clientsnmaster + clientsnstack == 0 || !m->lt[m->sellt]->arrange) { + tgactive = 1; + num = tabw; + den = clientsnmaster + clientsnstack + clientsnfloating; + r = num % den; + w = num / den; + for (c = m->clients, i = 0; c; c = c->next) { + if (!ISVISIBLE(c)) + continue; + tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg); + x += w + (i < r ? 1 : 0); + i++; + } + /* monocle mode */ + } else if (fulllayout || ((clientsnmaster == 0) ^ (clientsnstack == 0))) { + tgactive = 1; + num = tabw; + den = clientsnmaster + clientsnstack; + r = num % den; + w = num / den; + for (c = m->clients, i = 0; c; c = c->next) { + if (!ISVISIBLE(c) || c->isfloating) + continue; + tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg); + x += w + (i < r ? 1 : 0); + i++; + } + /* tiled mode */ + } else { + tgactive = masteractive; + num = clientsnstack ? tabw * m->mfact : tabw; + den = clientsnmaster; + r = num % den; + w = num / den; + for (c = m->clients, i = 0; c && i < m->nmaster; c = c->next) { + if (!ISVISIBLE(c) || c->isfloating) + continue; + tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg); + x += w + (i < r ? 1 : 0); + i++; + } + + tgactive = !tgactive; + num = tabw - num; + den = clientsnstack; + r = num % den; + w = num / den; + for (; c; c = c->next) { + if (!ISVISIBLE(c) || c->isfloating) + continue; + tabfn(m, c, passx, x, w + (i - m->nmaster < r ? 1 : 0), tgactive, arg); + x += w + (i - m->nmaster < r ? 1 : 0); + i++; + } + } +}
\ No newline at end of file diff --git a/patch/bar_tabgroups.h b/patch/bar_tabgroups.h new file mode 100644 index 0000000..7cf1254 --- /dev/null +++ b/patch/bar_tabgroups.h @@ -0,0 +1,21 @@ +/* Bartabgroups properties, you can override these in your config.h if you want. */ +#ifndef BARTAB_BORDERS +#define BARTAB_BORDERS 1 // 0 = off, 1 = on +#endif +#ifndef BARTAB_TAGSINDICATOR +#define BARTAB_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on +#endif +#ifndef BARTAB_TAGSPX +#define BARTAB_TAGSPX 5 // # pixels for tag grid boxes +#endif +#ifndef BARTAB_TAGSROWS +#define BARTAB_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3) +#endif + +static int width_bartabgroups(Bar *bar, BarWidthArg *a); +static int draw_bartabgroups(Bar *bar, BarDrawArg *a); +static int click_bartabgroups(Bar *bar, Arg *arg, BarClickArg *a); + +static void bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg); +static void bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg); +static void bartabcalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg);
\ No newline at end of file diff --git a/patch/bar_wintitleactions.c b/patch/bar_wintitleactions.c new file mode 100644 index 0000000..28dfa55 --- /dev/null +++ b/patch/bar_wintitleactions.c @@ -0,0 +1,89 @@ +void +hide(Client *c) { + + Client *n; + if (!c || HIDDEN(c)) + return; + + Window w = c->win; + static XWindowAttributes ra, ca; + + // more or less taken directly from blackbox's hide() function + XGrabServer(dpy); + XGetWindowAttributes(dpy, root, &ra); + XGetWindowAttributes(dpy, w, &ca); + // prevent UnmapNotify events + XSelectInput(dpy, root, ra.your_event_mask & ~SubstructureNotifyMask); + XSelectInput(dpy, w, ca.your_event_mask & ~StructureNotifyMask); + XUnmapWindow(dpy, w); + setclientstate(c, IconicState); + XSelectInput(dpy, root, ra.your_event_mask); + XSelectInput(dpy, w, ca.your_event_mask); + XUngrabServer(dpy); + + if (c->isfloating || !c->mon->lt[c->mon->sellt]->arrange) { + for (n = c->snext; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); + if (!n) + for (n = c->mon->stack; n && (!ISVISIBLE(n) || HIDDEN(n)); n = n->snext); + } else { + n = nexttiled(c); + if (!n) + n = prevtiled(c); + } + focus(n); + arrange(c->mon); +} + +void +show(Client *c) +{ + if (!c || !HIDDEN(c)) + return; + + XMapWindow(dpy, c->win); + setclientstate(c, NormalState); + arrange(c->mon); +} + +void +togglewin(const Arg *arg) +{ + Client *c = (Client*)arg->v; + if (!c) + return; + if (c == selmon->sel) + hide(c); + else { + if (HIDDEN(c)) + show(c); + focus(c); + restack(selmon); + } +} + +Client * +prevtiled(Client *c) +{ + Client *p, *i; + for (p = NULL, i = c->mon->clients; c && i != c; i = i->next) + if (ISVISIBLE(i) && !HIDDEN(i)) + p = i; + return p; +} + +void +showhideclient(const Arg *arg) +{ + Client *c = (Client*)arg->v; + if (!c) + c = selmon->sel; + if (!c) + return; + + if (HIDDEN(c)) { + show(c); + restack(selmon); + } else { + hide(c); + } +}
\ No newline at end of file diff --git a/patch/bar_wintitleactions.h b/patch/bar_wintitleactions.h new file mode 100644 index 0000000..e37201e --- /dev/null +++ b/patch/bar_wintitleactions.h @@ -0,0 +1,7 @@ +#define HIDDEN(C) ((getstate(C->win) == IconicState)) + +static void hide(Client *c); +static void show(Client *c); +static void togglewin(const Arg *arg); +static Client * prevtiled(Client *c); +static void showhideclient(const Arg *arg);
\ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 24293cd..b9be27f 100644 --- a/patch/include.c +++ b/patch/include.c @@ -41,6 +41,9 @@ #if BAR_STATUSCOLORS_PATCH #include "bar_statuscolors.c" #endif +#if BAR_TABGROUPS_PATCH +#include "bar_tabgroups.c" +#endif #if BAR_TAGS_PATCH #include "bar_tags.c" #endif @@ -62,6 +65,9 @@ #if BAR_VTCOLORS_PATCH #include "bar_vtcolors.c" #endif +#if BAR_WINTITLEACTIONS_PATCH +#include "bar_wintitleactions.c" +#endif /* Other patches */ #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH diff --git a/patch/include.h b/patch/include.h index 2615109..15645f0 100644 --- a/patch/include.h +++ b/patch/include.h @@ -38,6 +38,9 @@ #if BAR_STATUSCMD_PATCH #include "bar_statuscmd.h" #endif +#if BAR_TABGROUPS_PATCH +#include "bar_tabgroups.h" +#endif #if BAR_TAGS_PATCH #include "bar_tags.h" #endif @@ -59,6 +62,9 @@ #if BAR_VTCOLORS_PATCH #include "bar_vtcolors.h" #endif +#if BAR_WINTITLEACTIONS_PATCH +#include "bar_wintitleactions.h" +#endif /* Other patches */ #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH |
