Refinement
This commit is contained in:
@@ -1,43 +1,58 @@
|
||||
int
|
||||
width_taggrid(Monitor *m, BarWidthArg *a)
|
||||
width_taggrid(Bar *bar, BarWidthArg *a)
|
||||
{
|
||||
return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0));
|
||||
return (bh / 2) * (LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0)) + lrpad;
|
||||
}
|
||||
|
||||
int
|
||||
draw_taggrid(Monitor *m, BarDrawArg *a)
|
||||
draw_taggrid(Bar *bar, BarDrawArg *a)
|
||||
{
|
||||
unsigned int x, y, h, max_x, columns, occ = 0;
|
||||
unsigned int x, y, h, max_x = 0, columns, occ = 0;
|
||||
int invert, i,j, k;
|
||||
Client *c;
|
||||
|
||||
for (c = m->clients; c; c = c->next)
|
||||
for (c = bar->mon->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
|
||||
max_x = x = a->x + lrpad / 2;
|
||||
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 */
|
||||
#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, 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;
|
||||
x = a->x + lrpad / 2;
|
||||
for (k = 0; k < columns; k++, i++) {
|
||||
if (i < LENGTH(tags)) {
|
||||
invert = m->tagset[m->seltags] & 1 << i ? 0 : 1;
|
||||
invert = bar->mon->tagset[bar->mon->seltags] & 1 << i ? 0 : 1;
|
||||
|
||||
/* Select active color for current square */
|
||||
#if BAR_VTCOLORS_PATCH
|
||||
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColBg].pixel :
|
||||
scheme[SchemeTagsNorm][ColFg].pixel);
|
||||
#else
|
||||
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColBg].pixel :
|
||||
scheme[SchemeNorm][ColFg].pixel);
|
||||
#endif // BAR_VTCOLORS_PATCH
|
||||
XFillRectangle(dpy, drw->drawable, drw->gc, x+1, y+1, h-1, h-1);
|
||||
|
||||
/* Mark square if tag has client */
|
||||
if (occ & 1 << i) {
|
||||
#if BAR_VTCOLORS_PATCH
|
||||
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeTagsSel][ColFg].pixel :
|
||||
scheme[SchemeTagsNorm][ColBg].pixel);
|
||||
#else
|
||||
XSetForeground(drw->dpy, drw->gc, !invert ? scheme[SchemeSel][ColFg].pixel :
|
||||
scheme[SchemeNorm][ColBg].pixel);
|
||||
#endif // BAR_VTCOLORS_PATCH
|
||||
XFillRectangle(dpy, drw->drawable, drw->gc, x + 1, y + 1,
|
||||
h / 2, h / 2);
|
||||
}
|
||||
@@ -60,12 +75,12 @@ draw_taggrid(Monitor *m, BarDrawArg *a)
|
||||
}
|
||||
|
||||
int
|
||||
click_taggrid(Monitor *m, Arg *arg, BarClickArg *a)
|
||||
click_taggrid(Bar *bar, Arg *arg, BarClickArg *a)
|
||||
{
|
||||
unsigned int i, columns;
|
||||
|
||||
columns = LENGTH(tags) / tagrows + ((LENGTH(tags) % tagrows > 0) ? 1 : 0);
|
||||
i = (a->rel_x - 0) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows));
|
||||
i = (a->rel_x - lrpad / 2) / (bh / tagrows) + columns * (a->rel_y / (bh / tagrows));
|
||||
if (i >= LENGTH(tags)) {
|
||||
i = LENGTH(tags) - 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user