summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
authorbakkeby <[email protected]>2020-07-15 17:14:14 +0200
committerbakkeby <[email protected]>2020-07-15 17:14:14 +0200
commite780c5078f1b344f3a9902fba1a7641e18931ca3 (patch)
tree13287d682249042198c5f89a26e744d48fe53383 /patch
parentaa70728d0049f771820f17cfca4488768cf57cef (diff)
downloaddwm-flexipatch-e780c5078f1b344f3a9902fba1a7641e18931ca3.tar.gz
dwm-flexipatch-e780c5078f1b344f3a9902fba1a7641e18931ca3.zip
taggrid: fix for invalid highlighting for the last tag when columns have an uneven number of clients
Diffstat (limited to 'patch')
-rw-r--r--patch/bar_taggrid.c215
1 files changed, 112 insertions, 103 deletions
diff --git a/patch/bar_taggrid.c b/patch/bar_taggrid.c
index 78b3d1c..71379ba 100644
--- a/patch/bar_taggrid.c
+++ b/patch/bar_taggrid.c
@@ -7,47 +7,56 @@ width_taggrid(Monitor *m, BarWidthArg *a)
int
draw_taggrid(Monitor *m, BarDrawArg *a)
{
- unsigned int x, y, h, max_x, columns, occ = 0;
- int invert, i,j, k;
- Client *c;
+ unsigned int x, y, h, max_x, columns, occ = 0;
+ int invert, i,j, k;
+ Client *c;
- for (c = m->clients; c; c = c->next)
+ for (c = m->clients; c; c = c->next)
occ |= c->tags;
- h = bh / tagrows;
- x = max_x = a->x;
- y = 0;
- columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
+ h = bh / tagrows;
+ x = max_x = a->x;
+ y = 0;
+ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
- /* Firstly we will fill the borders of squares */
- XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh);
+ /* Firstly we will fill the borders of squares */
+ XFillRectangle(dpy, drw->drawable, drw->gc, x, y, h*columns + 1, bh);
- /* We will draw LENGTH(tags) squares in tagraws raws. */
- for (j = 0, i = 0; j < tagrows; j++) {
- x = a->x;
- for (k = 0; k < columns && i < LENGTH(tags); k++, i++) {
- invert = m->tagset[m->seltags] & 1 << i ? 0 : 1;
+ /* We will draw LENGTH(tags) squares in tagraws raws. */
+ for (j = 0, i = 0; j < tagrows; j++) {
+ x = a->x;
+ for (k = 0; k < columns; k++, i++) {
+ if (i < LENGTH(tags)) {
+ invert = m->tagset[m->seltags] & 1 << i ? 0 : 1;
- /* Select active color for current square */
- XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel :
- scheme[SchemeNorm][ColFg].pixel);
- XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1);
+ /* Select active color for current square */
+ XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel :
+ scheme[SchemeNorm][ColFg].pixel);
+ XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1);
- /* Mark square if tag has client */
- if (occ & 1 << i) {
- XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel :
- scheme[SchemeNorm][ColBg].pixel);
- XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1,
- h / 2, h / 2);
- }
- x += h;
- if (x > max_x) {
- max_x = x;
- }
- }
- y += h;
+ /* Mark square if tag has client */
+ if (occ & 1 << i) {
+ XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel :
+ scheme[SchemeNorm][ColBg].pixel);
+ XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1,
+ h / 2, h / 2);
+ }
+ } else {
+ #if BAR_VTCOLORS_PATCH
+ XSetForeground(drw->dpy, drw->gc, scheme[SchemeTagsNorm][ColBg].pixel);
+ #else
+ XSetForeground(drw->dpy, drw->gc, scheme[SchemeNorm][ColBg].pixel);
+ #endif // BAR_VTCOLORS_PATCH
+ XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h);
+ }
+ x += h;
+ if (x > max_x) {
+ max_x = x;
+ }
+ }
+ y += h;
}
- return max_x;
+ return max_x;
}
int
@@ -67,76 +76,76 @@ click_taggrid(Monitor *m, Arg *arg, BarClickArg *a)
void
switchtag(const Arg *arg)
{
- unsigned int columns;
- unsigned int new_tagset = 0;
- unsigned int pos, i;
- int col, row;
- Arg new_arg;
+ unsigned int columns;
+ unsigned int new_tagset = 0;
+ unsigned int pos, i;
+ int col, row;
+ Arg new_arg;
- columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
+ columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
- for (i = 0; i < LENGTH(tags); ++i) {
- if (!(selmon->tagset[selmon->seltags] & 1 << i)) {
- continue;
- }
- pos = i;
- row = pos / columns;
- col = pos % columns;
- if (arg->ui & SWITCHTAG_UP) { /* UP */
- row --;
- if (row < 0) {
- row = tagrows - 1;
- }
- do {
- pos = row * columns + col;
- row --;
- } while (pos >= LENGTH(tags));
- }
- if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */
- row ++;
- if (row >= tagrows) {
- row = 0;
- }
- pos = row * columns + col;
- if (pos >= LENGTH(tags)) {
- row = 0;
- }
- pos = row * columns + col;
- }
- if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */
- col --;
- if (col < 0) {
- col = columns - 1;
- }
- do {
- pos = row * columns + col;
- col --;
- } while (pos >= LENGTH(tags));
- }
- if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */
- col ++;
- if (col >= columns) {
- col = 0;
- }
- pos = row * columns + col;
- if (pos >= LENGTH(tags)) {
- col = 0;
- pos = row * columns + col;
- }
- }
- new_tagset |= 1 << pos;
- }
- new_arg.ui = new_tagset;
- if (arg->ui & SWITCHTAG_TOGGLETAG) {
- toggletag(&new_arg);
- }
- if (arg->ui & SWITCHTAG_TAG) {
- tag(&new_arg);
- }
- if (arg->ui & SWITCHTAG_VIEW) {
- view (&new_arg);
- }
- if (arg->ui & SWITCHTAG_TOGGLEVIEW) {
- toggleview (&new_arg);
- }
+ for (i = 0; i < LENGTH(tags); ++i) {
+ if (!(selmon->tagset[selmon->seltags] & 1 << i)) {
+ continue;
+ }
+ pos = i;
+ row = pos / columns;
+ col = pos % columns;
+ if (arg->ui & SWITCHTAG_UP) { /* UP */
+ row --;
+ if (row < 0) {
+ row = tagrows - 1;
+ }
+ do {
+ pos = row * columns + col;
+ row --;
+ } while (pos >= LENGTH(tags));
+ }
+ if (arg->ui & SWITCHTAG_DOWN) { /* DOWN */
+ row ++;
+ if (row >= tagrows) {
+ row = 0;
+ }
+ pos = row * columns + col;
+ if (pos >= LENGTH(tags)) {
+ row = 0;
+ }
+ pos = row * columns + col;
+ }
+ if (arg->ui & SWITCHTAG_LEFT) { /* LEFT */
+ col --;
+ if (col < 0) {
+ col = columns - 1;
+ }
+ do {
+ pos = row * columns + col;
+ col --;
+ } while (pos >= LENGTH(tags));
+ }
+ if (arg->ui & SWITCHTAG_RIGHT) { /* RIGHT */
+ col ++;
+ if (col >= columns) {
+ col = 0;
+ }
+ pos = row * columns + col;
+ if (pos >= LENGTH(tags)) {
+ col = 0;
+ pos = row * columns + col;
+ }
+ }
+ new_tagset |= 1 << pos;
+ }
+ new_arg.ui = new_tagset;
+ if (arg->ui & SWITCHTAG_TOGGLETAG) {
+ toggletag(&new_arg);
+ }
+ if (arg->ui & SWITCHTAG_TAG) {
+ tag(&new_arg);
+ }
+ if (arg->ui & SWITCHTAG_VIEW) {
+ view (&new_arg);
+ }
+ if (arg->ui & SWITCHTAG_TOGGLEVIEW) {
+ toggleview (&new_arg);
+ }
} \ No newline at end of file