Added clientindicators patch and unified and simplified indicator code. Enabled centeredwindowname option for awesomebar and bartabgroups patches.

pull/48/head
bakkeby 4 years ago
parent 512a656ddd
commit 32819a48f3

@ -15,7 +15,7 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2020-08-22 - Added logic to auto-hide bars if nothing is drawn on them (e.g. for standalone bars that only show certain clients)
2020-08-22 - Added logic to auto-hide bars if nothing is drawn on them (e.g. for standalone bars that only show certain clients). Added clientindicators patch and unified indicator code.
2020-08-21 - Simplification of color configuration; settling on a set of color schemes that is shared between multiple patches (urgentborder, floatborder and titlecolor patches made non-optional)
@ -204,6 +204,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [cfacts](https://dwm.suckless.org/patches/cfacts/)
- the cfacts patch provides the ability to assign different weights to clients in their respective stack in tiled layout
- [clientindicators](https://dwm.suckless.org/patches/clientindicators/)
- raws a dot indicator overlayed on each tag icon for each client
- the selected client is drawn as a larger horizontal line
- [cmdcustomize](https://dwm.suckless.org/patches/cmdcustomize/)
- allows color attributes to be set through the command line

@ -52,6 +52,8 @@ static const char buttonbar[] = "<O>";
static const unsigned int systrayspacing = 2; /* systray spacing */
static const int showsystray = 1; /* 0 means no systray */
#endif // BAR_SYSTRAY_PATCH
static int tagindicatortype = INDICATOR_TOP_LEFT_SQUARE; // see patch/bar_indicators.h for options
static int floatindicatortype = INDICATOR_TOP_LEFT_SQUARE; // see patch/bar_indicators.h for options
#if ONLYQUITONEMPTY_PATCH
static const int quit_empty_window_count = 2; /* only allow dwm to quit if no windows are open, value here represents number of deamons */
#endif // ONLYQUITONEMPTY_PATCH

@ -7,7 +7,7 @@ width_awesomebar(Bar *bar, BarWidthArg *a)
int
draw_awesomebar(Bar *bar, BarDrawArg *a)
{
int n = 0, scm, remainder = 0, tabw;
int n = 0, scm, remainder = 0, tabw, pad;
unsigned int i;
#if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad;
@ -37,12 +37,20 @@ draw_awesomebar(Bar *bar, BarDrawArg *a)
else
scm = SchemeTitleNorm;
pad = lrpad / 2;
#if BAR_CENTEREDWINDOWNAME_PATCH
if (TEXTW(c->name) < w)
pad = (tabw - TEXTW(c->name) + lrpad) / 2;
#endif // BAR_CENTEREDWINDOWNAME_PATCH
drw_setscheme(drw, scheme[scm]);
#if BAR_PANGO_PATCH
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0, False);
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, pad, c->name, 0, False);
#else
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, lrpad / 2, c->name, 0);
drw_text(drw, x, 0, tabw + (i < remainder ? 1 : 0), bh, pad, c->name, 0);
#endif // BAR_PANGO_PATCH
if (c->isfloating)
drawindicator(c->mon, c, 1, x, w, 0, 0, c->isfixed, floatindicatortype);
x += tabw + (i < remainder ? 1 : 0);
}
}

@ -12,8 +12,6 @@ draw_fancybar(Bar *bar, BarDrawArg *a)
Client *c;
Monitor *m = bar->mon;
int boxs = drw->fonts->h / 9;
int boxw = drw->fonts->h / 6 + 2;
#if BAR_TITLE_LEFT_PAD && BAR_TITLE_RIGHT_PAD
int x = a->x + lrpad / 2, w = a->w - lrpad;
#elif BAR_TITLE_LEFT_PAD
@ -60,7 +58,7 @@ draw_fancybar(Bar *bar, BarDrawArg *a)
drw_text(drw, x, 0, ftw, bh, lrpad / 2, c->name, 0);
#endif // BAR_PANGO_PATCH
if (c->isfloating)
drw_rect(drw, x + boxs, boxs, boxw, boxw, c->isfixed, 0);
drawindicator(c->mon, c, 1, x, w, 0, 0, c->isfixed, floatindicatortype);
x += ftw;
w -= ftw;
}

@ -2,15 +2,6 @@
#ifndef FLEXWINTITLE_BORDERS
#define FLEXWINTITLE_BORDERS 1 // 0 = off, 1 = on
#endif
#ifndef FLEXWINTITLE_TAGSINDICATOR
#define FLEXWINTITLE_TAGSINDICATOR 1 // 0 = off, 1 = on if >1 client/view tag, 2 = always on
#endif
#ifndef FLEXWINTITLE_TAGSPX
#define FLEXWINTITLE_TAGSPX 5 // # pixels for tag grid boxes
#endif
#ifndef FLEXWINTITLE_TAGSROWS
#define FLEXWINTITLE_TAGSROWS 3 // # rows in tag grid (9 tags, e.g. 3x3)
#endif
#ifndef FLEXWINTITLE_SHOWFLOATING
#define FLEXWINTITLE_SHOWFLOATING 0 // whether to show titles for floating windows, hidden clients are always shown
#endif
@ -26,9 +17,6 @@
#ifndef FLEXWINTITLE_FLOATWEIGHT
#define FLEXWINTITLE_FLOATWEIGHT 1 // floating window title weight, set to 0 to not show floating windows
#endif
#ifndef FLEXWINTITLE_CENTERTEXT
#define FLEXWINTITLE_CENTERTEXT 1 // center windowtitle text
#endif
#define SCHEMEFOR(c) getschemefor(m, c, groupactive == c)
@ -195,14 +183,14 @@ flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Ar
)]);
if (w <= TEXTW("A") - lrpad + pad) // reduce text padding if wintitle is too small
pad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
#if FLEXWINTITLE_CENTERTEXT
#if BAR_CENTEREDWINDOWNAME_PATCH
else if (TEXTW(c->name) < w)
pad = (w - TEXTW(c->name) + lrpad) / 2;
#endif // FLEXWINTITLE_CENTERTEXT
#endif // BAR_CENTEREDWINDOWNAME_PATCH
drw_text(drw, x, 0, w, bh, pad, c->name, 0);
if (c->isfloating)
drw_rect(drw, x + 2, 2, 5, 5, 0, 0);
drawindicator(m, c, 1, x + 2, w, 0, 0, 0, floatindicatortype);
if (FLEXWINTITLE_BORDERS) {
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
@ -217,19 +205,8 @@ flextitledraw(Monitor *m, Client *c, int unused, int x, int w, int tabscheme, Ar
nclienttags++;
}
if (FLEXWINTITLE_TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1) {
for (i = 0; i < LENGTH(tags); i++) {
drw_rect(drw,
( x + w - 2 - ((LENGTH(tags) / FLEXWINTITLE_TAGSROWS) * FLEXWINTITLE_TAGSPX)
- (i % (LENGTH(tags)/FLEXWINTITLE_TAGSROWS)) + ((i % (LENGTH(tags) / FLEXWINTITLE_TAGSROWS)) * FLEXWINTITLE_TAGSPX)
),
( 2 + ((i / (LENGTH(tags)/FLEXWINTITLE_TAGSROWS)) * FLEXWINTITLE_TAGSPX)
- ((i / (LENGTH(tags)/FLEXWINTITLE_TAGSROWS)))
),
FLEXWINTITLE_TAGSPX, FLEXWINTITLE_TAGSPX, (c->tags >> i) & 1, 0
);
}
}
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
drawindicator(m, c, 1, x, w, 0, 0, 0, INDICATOR_RIGHT_TAGS);
}
#ifndef HIDDEN

@ -33,12 +33,6 @@ draw_pwrl_tags(Bar *bar, BarDrawArg *a)
unsigned int i, occ = 0, urg = 0;
Client *c;
Clr *prevscheme, *nxtscheme;
#if !BAR_HIDEVACANTTAGS_PATCH
#if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
int boxs = drw->fonts->h / 9;
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
int boxw = drw->fonts->h / 6 + 2;
#endif // BAR_HIDEVACANTTAGS_PATCH
for (c = bar->mon->clients; c; c = c->next) {
#if BAR_HIDEVACANTTAGS_PATCH
@ -63,22 +57,12 @@ draw_pwrl_tags(Bar *bar, BarDrawArg *a)
#if BAR_POWERLINE_TAGS_SLASH_PATCH
drw_arrow(drw, x, 0, plw, bh, 1, 1);
#else
drw_arrow(drw, x, 0, plw, bh, 1, 1);
drw_arrow(drw, x, 0, plw, bh, 1, 0);
#endif // BAR_POWERLINE_TAGS_SLASH_PATCH
x += plw;
drw_setscheme(drw, nxtscheme);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert);
#if !BAR_HIDEVACANTTAGS_PATCH
if (occ & 1 << i)
#if BAR_ACTIVETAGINDICATORBAR_PATCH
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw,
#elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2,
#else
drw_rect(drw, x + boxs, boxs, boxw, boxw,
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH
bar->mon == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert);
#endif // BAR_HIDEVACANTTAGS_PATCH
drawindicator(m, NULL, occ, x, w, i, -1, invert, tagindicatortype);
x += w;
prevscheme = nxtscheme;
}

@ -1,22 +1,26 @@
int
width_status2d(Bar *bar, BarWidthArg *a)
{
int width;
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH
return status2dtextlength(rawstext) + lrpad;
width = status2dtextlength(rawstext);
#else
return status2dtextlength(stext) + lrpad;
width = status2dtextlength(stext);
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH
return width ? width + lrpad : 0;
}
#if BAR_EXTRASTATUS_PATCH
int
width_status2d_es(Bar *bar, BarWidthArg *a)
{
int width;
#if BAR_EXTRASTATUS_PATCH || BAR_STATUSCMD_PATCH
return status2dtextlength(rawestext) + lrpad;
width = status2dtextlength(rawestext);
#else
return status2dtextlength(estext) + lrpad;
width = status2dtextlength(estext);
#endif // #if BAR_EXTRASTATUS_PATCH | BAR_STATUSCMD_PATCH
return width ? width + lrpad : 0;
}
#endif // BAR_EXTRASTATUS_PATCH

@ -2,15 +2,6 @@
#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
@ -49,7 +40,7 @@ bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg
{
if (!c)
return;
int i, nclienttags = 0, nviewtags = 0;
int i, nclienttags = 0, nviewtags = 0, pad = lrpad / 2;
drw_setscheme(drw, scheme[
m->sel == c
? SchemeSel
@ -61,9 +52,16 @@ bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg
? SchemeTitleSel
: SchemeTitleNorm
]);
drw_text(drw, x, 0, w, bh, lrpad / 2, c->name, 0);
if (w <= TEXTW("A") - lrpad + pad) // reduce text padding if wintitle is too small
pad = (w - TEXTW("A") + lrpad < 0 ? 0 : (w - TEXTW("A") + lrpad) / 2);
#if BAR_CENTEREDWINDOWNAME_PATCH
else if (TEXTW(c->name) < w)
pad = (w - TEXTW(c->name) + lrpad) / 2;
#endif // BAR_CENTEREDWINDOWNAME_PATCH
drw_text(drw, x, 0, w, bh, pad, c->name, 0);
if (c->isfloating)
drw_rect(drw, x + 2, 2, 5, 5, 0, 0);
drawindicator(m, c, 1, x, w, 0, 0, c->isfixed, floatindicatortype);
if (BARTAB_BORDERS) {
XSetForeground(drw->dpy, drw->gc, scheme[SchemeSel][ColBorder].pixel);
@ -78,19 +76,8 @@ bartabdraw(Monitor *m, Client *c, int unused, int x, int w, int groupactive, Arg
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
);
}
}
if (TAGSINDICATOR == 2 || nclienttags > 1 || nviewtags > 1)
drawindicator(m, c, 1, x, w, 0, 0, 0, INDICATOR_RIGHT_TAGS);
}
#ifndef HIDDEN
@ -195,7 +182,7 @@ bartabcalculate(
den = clientsnstack * BARTAB_STACKWEIGHT + clientsnfloating * BARTAB_FLOATWEIGHT + clientsnhidden * BARTAB_HIDDENWEIGHT;
if (!den)
return;
return 1;
r = num % den;
w = num / den;

@ -31,12 +31,6 @@ draw_tags(Bar *bar, BarDrawArg *a)
#if BAR_ALTERNATIVE_TAGS_PATCH
int wdelta;
#endif // BAR_ALTERNATIVE_TAGS_PATCH
#if !BAR_HIDEVACANTTAGS_PATCH
#if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
int boxs = drw->fonts->h / 9;
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
int boxw = drw->fonts->h / 6 + 2;
#endif // BAR_HIDEVACANTTAGS_PATCH
unsigned int i, occ = 0, urg = 0;
Client *c;
Monitor *m = bar->mon;
@ -78,17 +72,7 @@ draw_tags(Bar *bar, BarDrawArg *a)
#else
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], invert);
#endif // BAR_ALTERNATIVE_TAGS_PATCH
#if !BAR_HIDEVACANTTAGS_PATCH
if (occ & 1 << i)
#if BAR_ACTIVETAGINDICATORBAR_PATCH
drw_rect(drw, x + boxw, 0, w - ( 2 * boxw + 1), boxw,
#elif BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
drw_rect(drw, x + boxw, bh - boxw/2, w - ( 2 * boxw + 1), boxw/2,
#else
drw_rect(drw, x + boxs, boxs, boxw, boxw,
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH
m == selmon && selmon->sel && selmon->sel->tags & 1 << i, invert);
#endif // BAR_HIDEVACANTTAGS_PATCH
drawindicator(m, NULL, occ, x, w, i, -1, invert, tagindicatortype);
x += w;
}

@ -7,11 +7,6 @@ width_wintitle(Bar *bar, BarWidthArg *a)
int
draw_wintitle(Bar *bar, BarDrawArg *a)
{
#if !BAR_ACTIVETAGINDICATORBAR_PATCH && !BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
int boxs = drw->fonts->h / 9;
#endif // BAR_ACTIVETAGINDICATORBAR_PATCH | BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH
int boxw = drw->fonts->h / 6 + 2;
#if BAR_TITLE_LEFT_PAD_PATCH && BAR_TITLE_RIGHT_PAD_PATCH
int x = a->x + lrpad / 2, w = a->w - lrpad;
#elif BAR_TITLE_LEFT_PAD_PATCH
@ -52,13 +47,7 @@ draw_wintitle(Bar *bar, BarDrawArg *a)
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
drawindicator(m, m->sel, 1, x, w, 0, 0, c->isfixed, floatindicatortype);
return 1;
}

@ -1,4 +1,5 @@
/* Bar functionality */
#include "bar_indicators.c"
#if BAR_ALPHA_PATCH
#include "bar_alpha.c"
#endif

@ -1,4 +1,5 @@
/* Bar functionality */
#include "bar_indicators.h"
#if BAR_ALPHA_PATCH
#include "bar_alpha.h"
#endif

@ -158,22 +158,31 @@
/* This patch changes the rectangle indicating if a tag is used by a client into a bar
* above the tag name for better visibility.
* Set the tagindicatortype variable in config.h to INDICATOR_TOP_BAR to enable this.
* https://dwm.suckless.org/patches/activetagindicatorbar/
*/
#define BAR_ACTIVETAGINDICATORBAR_PATCH 0
#define BAR_ACTIVETAGINDICATORBAR_PATCH N/A
/* Alternative patch to the activetagindicatorbar patch, adds the bar below the tag
* icon rather than above.
* Set the tagindicatortype variable in config.h to INDICATOR_BOTTOM_BAR to enable this.
*/
#define BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH 0
#define BAR_ACTIVETAGINDICATORBAR_ALT1_PATCH N/A
/* This patch centers the WM_NAME of the currently selected window on the status bar.
* Both fancybar and awesomebar patches take precedence over this patch.
* This patch only applies when the BAR_WINTITLE_PATCH module is used.
* This is compatible with the wintitle, bartabgroups, flexwintitle and awesomebar bar
* modules.
* https://dwm.suckless.org/patches/centeredwindowname/
*/
#define BAR_CENTEREDWINDOWNAME_PATCH 0
/* Draws a dot indicator overlayed on each tag icon for each client. The selected client
* is drawn as a larger horizontal line.
* Set the tagindicatortype variable in config.h to INDICATOR_CLIENT_DOTS to enable this.
* https://dwm.suckless.org/patches/clientindicators/
*/
#define BAR_CLIENTINDICATOR_PATCH N/A
/* This patch enables color emoji in dwm by removing a workaround for a BadLength error
* in the Xft library when color glyphs are used.
* To enable this you will need an updated Xft library that can handle color glyphs otherwise

Loading…
Cancel
Save