bartabgroups: grouped floating and hidden windows, added stack, float and hidden group weights

This commit is contained in:
bakkeby 2020-08-15 10:58:33 +02:00
parent ed2b8c27c8
commit 2632f112a8
2 changed files with 90 additions and 48 deletions

View File

@ -1,3 +1,29 @@
/* 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
#ifndef BARTAB_SHOWFLOATING
#define BARTAB_SHOWFLOATING 0 // whether to show titles for floating windows, hidden clients are always shown
#endif
#ifndef BARTAB_STACKWEIGHT
#define BARTAB_STACKWEIGHT 1 // stack weight compared to hidden and floating window titles
#endif
#ifndef BARTAB_HIDDENWEIGHT
#define BARTAB_HIDDENWEIGHT 1 // hidden window title weight
#endif
#ifndef BARTAB_FLOATWEIGHT
#define BARTAB_FLOATWEIGHT 1 // floating window title weight, set to 0 to not show floating windows
#endif
int int
width_bartabgroups(Bar *bar, BarWidthArg *a) width_bartabgroups(Bar *bar, BarWidthArg *a)
{ {
@ -80,7 +106,7 @@ bartabcalculate(
) { ) {
Client *c; Client *c;
int int
i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0, i, clientsnmaster = 0, clientsnstack = 0, clientsnfloating = 0, clientsnhidden = 0,
masteractive = 0, fulllayout = 0, masteractive = 0, fulllayout = 0,
x = offx, w, r, num = 0, den, tgactive; x = offx, w, r, num = 0, den, tgactive;
@ -93,7 +119,11 @@ bartabcalculate(
for (i = 0, c = m->clients; c; c = c->next) { for (i = 0, c = m->clients; c; c = c->next) {
if (!ISVISIBLE(c)) if (!ISVISIBLE(c))
continue; continue;
if (!HIDDEN(c) && c->isfloating && !BARTAB_SHOWFLOATING) { if (HIDDEN(c)) {
clientsnhidden++;
continue;
}
if (c->isfloating) {
clientsnfloating++; clientsnfloating++;
continue; continue;
} }
@ -106,14 +136,14 @@ bartabcalculate(
i++; i++;
} }
if (!i) if (clientsnmaster + clientsnstack + clientsnfloating + clientsnhidden == 0)
return; return;
tgactive = 1;
num = tabw;
/* floating mode */ /* floating mode */
if (clientsnmaster + clientsnstack == 0 || !m->lt[m->sellt]->arrange) { if ((fulllayout && BARTAB_FLOATWEIGHT) || clientsnmaster + clientsnstack == 0 || !m->lt[m->sellt]->arrange) {
tgactive = 1; den = clientsnmaster + clientsnstack + clientsnfloating + clientsnhidden;
num = tabw;
den = clientsnmaster + clientsnstack + clientsnfloating;
r = num % den; r = num % den;
w = num / den; w = num / den;
for (c = m->clients, i = 0; c; c = c->next) { for (c = m->clients, i = 0; c; c = c->next) {
@ -123,15 +153,13 @@ bartabcalculate(
x += w + (i < r ? 1 : 0); x += w + (i < r ? 1 : 0);
i++; i++;
} }
/* monocle mode */ /* no master and stack mode, e.g. monocole, grid layouts, fibonacci */
} else if (fulllayout || ((clientsnmaster == 0) ^ (clientsnstack == 0))) { } else if (fulllayout) {
tgactive = 1; den = clientsnmaster + clientsnstack + clientsnhidden;
num = tabw;
den = clientsnmaster + clientsnstack;
r = num % den; r = num % den;
w = num / den; w = num / den;
for (c = m->clients, i = 0; c; c = c->next) { for (c = m->clients, i = 0; c; c = c->next) {
if (!ISVISIBLE(c) || (!HIDDEN(c) && c->isfloating && !BARTAB_SHOWFLOATING)) if (!ISVISIBLE(c) || (c->isfloating && !HIDDEN(c)))
continue; continue;
tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg); tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg);
x += w + (i < r ? 1 : 0); x += w + (i < r ? 1 : 0);
@ -139,30 +167,61 @@ bartabcalculate(
} }
/* tiled mode */ /* tiled mode */
} else { } else {
tgactive = masteractive;
num = clientsnstack ? tabw * m->mfact : tabw;
den = clientsnmaster; den = clientsnmaster;
r = num % den; c = m->clients;
w = num / den; i = 0;
for (c = m->clients, i = 0; c && i < m->nmaster; c = c->next) { if (den) {
if (!ISVISIBLE(c) || (!HIDDEN(c) && c->isfloating && !BARTAB_SHOWFLOATING)) if (clientsnstack + clientsnfloating * BARTAB_FLOATWEIGHT + clientsnhidden) {
continue; tgactive = masteractive;
tabfn(m, c, passx, x, w + (i < r ? 1 : 0), tgactive, arg); num = tabw * m->mfact;
x += w + (i < r ? 1 : 0); }
i++; r = num % den;
w = num / den;
for (; c && i < m->nmaster; c = c->next) { // tiled master
if (!ISVISIBLE(c) || c->isfloating || HIDDEN(c))
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;
} }
tgactive = !tgactive; den = clientsnstack * BARTAB_STACKWEIGHT + clientsnfloating * BARTAB_FLOATWEIGHT + clientsnhidden * BARTAB_HIDDENWEIGHT;
num = tabw - num; if (!den)
den = clientsnstack; return;
r = num % den; r = num % den;
w = num / den; w = num / den;
for (; c; c = c->next) { #if BARTAB_STACKWEIGHT
if (!ISVISIBLE(c) || (!HIDDEN(c) && c->isfloating && !BARTAB_SHOWFLOATING)) for (; c; c = c->next) { // tiled stack
if (!ISVISIBLE(c) || HIDDEN(c) || c->isfloating)
continue; continue;
tabfn(m, c, passx, x, w + (i - m->nmaster < r ? 1 : 0), tgactive, arg); tabfn(m, c, passx, x, w * BARTAB_STACKWEIGHT + (i - m->nmaster < r ? 1 : 0), tgactive, arg);
x += w + (i - m->nmaster < r ? 1 : 0); x += w * BARTAB_STACKWEIGHT + (i - m->nmaster < r ? 1 : 0);
i++; i++;
} }
#endif // BARTAB_STACKWEIGHT
#if BARTAB_HIDDENWEIGHT
for (c = m->clients; c; c = c->next) { // hidden windows
if (!ISVISIBLE(c) || !HIDDEN(c))
continue;
tabfn(m, c, passx, x, w * BARTAB_HIDDENWEIGHT + (i - m->nmaster < r ? 1 : 0), tgactive, arg);
x += w * BARTAB_HIDDENWEIGHT + (i - m->nmaster < r ? 1 : 0);
i++;
}
#endif // BARTAB_HIDDENWEIGHT
#if BARTAB_FLOATWEIGHT
for (c = m->clients; c; c = c->next) { // floating windows
if (!ISVISIBLE(c) || HIDDEN(c) || !c->isfloating)
continue;
tabfn(m, c, passx, x, w * BARTAB_FLOATWEIGHT + (i - m->nmaster < r ? 1 : 0), tgactive, arg);
x += w * BARTAB_FLOATWEIGHT + (i - m->nmaster < r ? 1 : 0);
i++;
}
#endif // BARTAB_FLOATWEIGHT
} }
} }

View File

@ -1,20 +1,3 @@
/* 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
#ifndef BARTAB_SHOWFLOATING
#define BARTAB_SHOWFLOATING 0 // whether to show titles for floating windows, hidden clients are always shown
#endif
static int width_bartabgroups(Bar *bar, BarWidthArg *a); static int width_bartabgroups(Bar *bar, BarWidthArg *a);
static int draw_bartabgroups(Bar *bar, BarDrawArg *a); static int draw_bartabgroups(Bar *bar, BarDrawArg *a);
static int click_bartabgroups(Bar *bar, Arg *arg, BarClickArg *a); static int click_bartabgroups(Bar *bar, Arg *arg, BarClickArg *a);