revise drawbar and related mechanisms.
This also fixes a bug, where the last tab was hidden and no "after" text was displayed. Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
829980f28a
commit
74115f685f
48
tabbed.c
48
tabbed.c
|
@ -179,15 +179,13 @@ buttonpress(const XEvent *e) {
|
||||||
int fc;
|
int fc;
|
||||||
Arg arg;
|
Arg arg;
|
||||||
|
|
||||||
fc = getfirsttab();
|
if(ev->y < 0 || ev->y > bh)
|
||||||
|
|
||||||
if((fc > 0 && ev->x < TEXTW(before)) || ev->x < 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(ev->y < 0 || ev-> y > bh)
|
if(((fc = getfirsttab()) > 0 && ev->x < TEXTW(before)) || ev->x < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(i = (fc > 0) ? fc : 0; i < nclients; i++) {
|
for(i = fc; i < nclients; i++) {
|
||||||
if(clients[i]->tabx > ev->x) {
|
if(clients[i]->tabx > ev->x) {
|
||||||
switch(ev->button) {
|
switch(ev->button) {
|
||||||
case Button1:
|
case Button1:
|
||||||
|
@ -318,7 +316,7 @@ die(const char *errstr, ...) {
|
||||||
void
|
void
|
||||||
drawbar(void) {
|
drawbar(void) {
|
||||||
unsigned long *col;
|
unsigned long *col;
|
||||||
int c, fc, width, n = 0;
|
int c, cc, fc, width;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
|
|
||||||
if(nclients == 0) {
|
if(nclients == 0) {
|
||||||
|
@ -333,12 +331,11 @@ drawbar(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
width = ww;
|
width = ww;
|
||||||
clients[nclients-1]->tabx = -1;
|
cc = ww / tabwidth;
|
||||||
fc = getfirsttab();
|
if(nclients > cc)
|
||||||
if(fc > -1)
|
cc = (ww - TEXTW(before) - TEXTW(after)) / tabwidth;
|
||||||
n = nclients - fc;
|
|
||||||
|
|
||||||
if((n * tabwidth) > width) {
|
if((fc = getfirsttab()) + cc < nclients) {
|
||||||
dc.w = TEXTW(after);
|
dc.w = TEXTW(after);
|
||||||
dc.x = width - dc.w;
|
dc.x = width - dc.w;
|
||||||
drawtext(after, dc.sel);
|
drawtext(after, dc.sel);
|
||||||
|
@ -353,15 +350,12 @@ drawbar(void) {
|
||||||
width -= dc.w;
|
width -= dc.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(c = (fc > 0)? fc : 0; c < nclients && dc.x < width; c++) {
|
cc = MIN(cc, nclients);
|
||||||
dc.w = tabwidth;
|
for(c = fc; c < fc + cc; c++) {
|
||||||
|
dc.w = width / cc;
|
||||||
if(c == sel) {
|
if(c == sel) {
|
||||||
col = dc.sel;
|
col = dc.sel;
|
||||||
if((n * tabwidth) > width) {
|
dc.w += width % cc;
|
||||||
dc.w += width % tabwidth;
|
|
||||||
} else {
|
|
||||||
dc.w = width - (n - 1) * tabwidth;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
col = clients[c]->urgent ? dc.urg : dc.norm;
|
col = clients[c]->urgent ? dc.urg : dc.norm;
|
||||||
}
|
}
|
||||||
|
@ -556,21 +550,17 @@ getcolor(const char *colstr) {
|
||||||
|
|
||||||
int
|
int
|
||||||
getfirsttab(void) {
|
getfirsttab(void) {
|
||||||
int c, n, fc;
|
int cc, ret;
|
||||||
|
|
||||||
if(sel < 0)
|
if(sel < 0)
|
||||||
return -1;
|
return 0;
|
||||||
|
|
||||||
c = sel;
|
cc = ww / tabwidth;
|
||||||
fc = 0;
|
if(nclients > cc)
|
||||||
n = nclients;
|
cc = (ww - TEXTW(before) - TEXTW(after)) / tabwidth;
|
||||||
if((n * tabwidth) > ww) {
|
|
||||||
for(; (c * tabwidth) > (ww / 2)
|
|
||||||
&& (n * tabwidth) > ww;
|
|
||||||
c--, n--, fc++);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fc;
|
ret = sel - cc / 2 + (cc + 1) % 2;
|
||||||
|
return ret < 0 ? 0 : (ret + cc > nclients ? MAX(0, nclients - cc) : ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|
Loading…
Reference in a new issue