Added logic to auto-hide bars if nothing is drawn on them (e.g. for standalone bars that only show certain clients)

This commit is contained in:
bakkeby
2020-08-22 08:43:07 +02:00
parent 81488b4862
commit 110cc7d240
18 changed files with 91 additions and 69 deletions

View File

@@ -46,7 +46,7 @@ draw_awesomebar(Bar *bar, BarDrawArg *a)
x += tabw + (i < remainder ? 1 : 0);
}
}
return a->x + a->w;
return n;
}
int

View File

@@ -65,7 +65,7 @@ draw_fancybar(Bar *bar, BarDrawArg *a)
w -= ftw;
}
}
return x + w;
return n;
}
int

View File

@@ -44,8 +44,7 @@ int
draw_flexwintitle(Bar *bar, BarDrawArg *a)
{
drw_rect(drw, a->x, 0, a->w, bh, 1, 1);
flextitlecalculate(bar->mon, a->x, a->w, -1, flextitledraw, NULL);
return a->x + a->w;
return flextitlecalculate(bar->mon, a->x, a->w, -1, flextitledraw, NULL);
}
int
@@ -244,7 +243,7 @@ flextitleclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *
arg->v = c;
}
void
int
flextitlecalculate(
Monitor *m, int offx, int tabw, int passx,
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
@@ -310,7 +309,7 @@ flextitlecalculate(
n = clientsnmaster + clientsnstack + clientsnstack2 + clientsnfloating + clientsnhidden;
if (n == 0)
return;
return 0;
#if FLEXTILE_DELUXE_LAYOUT
else if (m->lt[m->sellt]->arrange == &flextile) {
int layout = m->ltaxis[LAYOUT];
@@ -448,4 +447,5 @@ flextitlecalculate(
rr -= clientsnhidden;
c = flextitledrawarea(m, m->clients, flt_x, rr, w * FLEXWINTITLE_FLOATWEIGHT + rw, clientsnfloating, SCHEMEFOR(GRP_FLOAT), 0, 0, 1, passx, tabfn, arg); // floating
}
return 1;
}

View File

@@ -4,7 +4,7 @@ static int click_flexwintitle(Bar *bar, Arg *arg, BarClickArg *a);
static void flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg *arg);
static void flextitleclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg);
static void flextitlecalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg);
static int flextitlecalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg);
static int getschemefor(Monitor *m, int group, int activegroup);
static int getselschemefor(int scheme);
static Client *flextitledrawarea(Monitor *m, Client *c, int x, int r, int w, int max_clients, int tabscheme, int draw_tiled, int draw_hidden, int draw_floating, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg);

View File

@@ -90,7 +90,7 @@ draw_pwrl_tags(Bar *bar, BarDrawArg *a)
#else
drw_arrow(drw, x, 0, plw, bh, 1, 0);
#endif // BAR_POWERLINE_TAGS_SLASH_PATCH
return a->x + a->w;
return 1;
}
int

View File

@@ -164,7 +164,7 @@ drawstatusbar(int x, char* stext)
free(p);
drw_setscheme(drw, scheme[SchemeNorm]);
return x;
return i;
}
int

View File

@@ -17,7 +17,7 @@ int
draw_systray(Bar *bar, BarDrawArg *a)
{
if (!showsystray)
return a->x;
return 0;
XSetWindowAttributes wa;
Client *i;
@@ -61,7 +61,7 @@ draw_systray(Bar *bar, BarDrawArg *a)
fprintf(stderr, "dwm: unable to obtain system tray.\n");
free(systray);
systray = NULL;
return a->x;
return 0;
}
}
@@ -86,7 +86,7 @@ draw_systray(Bar *bar, BarDrawArg *a)
}
XMoveResizeWindow(dpy, systray->win, bar->bx + a->x + lrpad / 2, (w ? bar->by : -bar->by), MAX(w, 1), bar->bh);
return a->x + a->w;
return w;
}
int

View File

@@ -34,8 +34,7 @@ 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;
return bartabcalculate(bar->mon, a->x, a->w, -1, bartabdraw, NULL);
}
int
@@ -105,7 +104,7 @@ bartabclick(Monitor *m, Client *c, int passx, int x, int w, int unused, Arg *arg
arg->v = c;
}
void
int
bartabcalculate(
Monitor *m, int offx, int tabw, int passx,
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
@@ -143,7 +142,7 @@ bartabcalculate(
}
if (clientsnmaster + clientsnstack + clientsnfloating + clientsnhidden == 0)
return;
return 0;
tgactive = 1;
num = tabw;
@@ -230,4 +229,5 @@ bartabcalculate(
}
#endif // BARTAB_FLOATWEIGHT
}
return 1;
}

View File

@@ -4,4 +4,4 @@ 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);
static int bartabcalculate(Monitor *m, int offx, int w, int passx, void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg);

View File

@@ -53,7 +53,7 @@ draw_taggrid(Bar *bar, BarDrawArg *a)
}
y += h;
}
return max_x;
return 1;
}
int

View File

@@ -92,7 +92,7 @@ draw_tags(Bar *bar, BarDrawArg *a)
x += w;
}
return x;
return 1;
}
int

View File

@@ -23,42 +23,43 @@ draw_wintitle(Bar *bar, BarDrawArg *a)
#endif // BAR_TITLE_LEFT_PAD_PATCH | BAR_TITLE_RIGHT_PAD_PATCH
Monitor *m = bar->mon;
if (m->sel) {
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
XSetErrorHandler(xerrordummy);
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
#if BAR_CENTEREDWINDOWNAME_PATCH
int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x;
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0, False);
#else
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
#endif // BAR_PANGO_PATCH
#else
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False);
#else
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
#endif // BAR_PANGO_PATCH
#endif // BAR_CENTEREDWINDOWNAME_PATCH
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
XSync(dpy, False);
XSetErrorHandler(xerror);
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
if (m->sel->isfloating)
#if BAR_ACTIVETAGINDICATORBAR_PATCH
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, m->sel->isfixed, 0);
#elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, 0);
#else
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH
} else {
if (!m->sel) {
drw_setscheme(drw, scheme[SchemeTitleNorm]);
drw_rect(drw, x, 0, w, bh, 1, 1);
return 0;
}
return x + w;
drw_setscheme(drw, scheme[m == selmon ? SchemeTitleSel : SchemeTitleNorm]);
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
XSetErrorHandler(xerrordummy);
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
#if BAR_CENTEREDWINDOWNAME_PATCH
int mid = (m->ww - TEXTW(m->sel->name)) / 2 - x;
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0, False);
#else
drw_text(drw, x, 0, w, bh, mid, m->sel->name, 0);
#endif // BAR_PANGO_PATCH
#else
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0, False);
#else
drw_text(drw, x, 0, w, bh, lrpad / 2, m->sel->name, 0);
#endif // BAR_PANGO_PATCH
#endif // BAR_CENTEREDWINDOWNAME_PATCH
#if BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
XSync(dpy, False);
XSetErrorHandler(xerror);
#endif // BAR_IGNORE_XFT_ERRORS_WHEN_DRAWING_TEXT_PATCH
if (m->sel->isfloating)
#if BAR_ACTIVETAGINDICATORBAR_PATCH
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw, m->sel->isfixed, 0);
#elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2, 0);
#else
drw_rect(drw, x + boxs, boxs, boxw, boxw, m->sel->isfixed, 0);
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH
return 1;
}
int

View File

@@ -8,8 +8,7 @@ int
draw_wintitle_floating(Bar *bar, BarDrawArg *a)
{
drw_rect(drw, a->x, 0, a->w, bh, 1, 1);
calc_wintitle_floating(bar->mon, a->x, a->w, -1, flextitledraw, NULL);
return a->x + a->w;
return calc_wintitle_floating(bar->mon, a->x, a->w, -1, flextitledraw, NULL);;
}
int
@@ -19,7 +18,7 @@ click_wintitle_floating(Bar *bar, Arg *arg, BarClickArg *a)
return ClkWinTitle;
}
void
int
calc_wintitle_floating(
Monitor *m, int offx, int tabw, int passx,
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
@@ -36,9 +35,10 @@ calc_wintitle_floating(
}
if (!clientsnfloating)
return;
return 0;
w = tabw / clientsnfloating;
r = tabw % clientsnfloating;
c = flextitledrawarea(m, m->clients, offx, r, w, clientsnfloating, SCHEMEFOR(GRP_FLOAT), 0, 0, 1, passx, tabfn, arg);
return 1;
}

View File

@@ -1,7 +1,7 @@
static int width_wintitle_floating(Bar *bar, BarWidthArg *a);
static int draw_wintitle_floating(Bar *bar, BarDrawArg *a);
static int click_wintitle_floating(Bar *bar, Arg *arg, BarClickArg *a);
static void calc_wintitle_floating(
static int calc_wintitle_floating(
Monitor *m, int offx, int tabw, int passx,
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
);

View File

@@ -8,8 +8,7 @@ int
draw_wintitle_hidden(Bar *bar, BarDrawArg *a)
{
drw_rect(drw, a->x, 0, a->w, bh, 1, 1);
calc_wintitle_hidden(bar->mon, a->x, a->w, -1, flextitledraw, NULL);
return a->x + a->w;
return calc_wintitle_hidden(bar->mon, a->x, a->w, -1, flextitledraw, NULL);;
}
int
@@ -19,7 +18,7 @@ click_wintitle_hidden(Bar *bar, Arg *arg, BarClickArg *a)
return ClkWinTitle;
}
void
int
calc_wintitle_hidden(
Monitor *m, int offx, int tabw, int passx,
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
@@ -36,9 +35,10 @@ calc_wintitle_hidden(
}
if (!clientsnhidden)
return;
return 0;
w = tabw / clientsnhidden;
r = tabw % clientsnhidden;
c = flextitledrawarea(m, m->clients, offx, r, w, clientsnhidden, SCHEMEFOR(GRP_HIDDEN), 0, 1, 0, passx, tabfn, arg);
return 1;
}

View File

@@ -1,7 +1,7 @@
static int width_wintitle_hidden(Bar *bar, BarWidthArg *a);
static int draw_wintitle_hidden(Bar *bar, BarDrawArg *a);
static int click_wintitle_hidden(Bar *bar, Arg *arg, BarClickArg *a);
static void calc_wintitle_hidden(
static int calc_wintitle_hidden(
Monitor *m, int offx, int tabw, int passx,
void(*tabfn)(Monitor *, Client *, int, int, int, int, Arg *arg), Arg *arg
);