Clean up code for the buttonpress function
This commit is contained in:
parent
4d68e538dc
commit
44360a9cf7
89
speedwm.c
89
speedwm.c
|
@ -931,81 +931,18 @@ buttonpress(XEvent *e)
|
|||
selmon = m;
|
||||
focus(NULL);
|
||||
}
|
||||
|
||||
/* For !leftlayout */
|
||||
if (!leftlayout) {
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = occ = 0;
|
||||
|
||||
/* Bitmask of occupied tags */
|
||||
unsigned int occ = 0;
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
do {
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
x += TEXTW(occ & 1 << i ? alttags[i] : tags[i]);
|
||||
} while (ev->x >= x && ++i < LENGTH(tags));
|
||||
if (i < LENGTH(tags)) {
|
||||
selmon->mouseactivated = 1;
|
||||
click = ClkTagBar;
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x < x + blw)
|
||||
click = ClkLtSymbol;
|
||||
else if (ev->x > (selmon->ww - TEXTW(stext) + lrpad) - 2) {
|
||||
x = selmon->ww - TEXTW(stext) + lrpad - 2;
|
||||
click = ClkStatusText;
|
||||
|
||||
char *text = rawstext;
|
||||
int i = -1;
|
||||
char ch;
|
||||
statuscmdn = 0;
|
||||
while (text[++i]) {
|
||||
if ((unsigned char)text[i] < ' ') {
|
||||
ch = text[i];
|
||||
text[i] = '\0';
|
||||
x += TEXTW(text) - lrpad;
|
||||
text[i] = ch;
|
||||
text += i+1;
|
||||
i = -1;
|
||||
if (x >= ev->x) break;
|
||||
statuscmdn = ch;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
x += blw;
|
||||
c = m->clients;
|
||||
|
||||
if (c) {
|
||||
do {
|
||||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
else
|
||||
x += (1.0 / (double)m->bt) * m->btw;
|
||||
} while (ev->x > x && (c = c->next));
|
||||
|
||||
click = ClkWinTitle;
|
||||
arg.v = c;
|
||||
}
|
||||
}
|
||||
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
||||
click = ClkClientWin;
|
||||
}
|
||||
} else {
|
||||
if (ev->window == selmon->barwin) {
|
||||
i = x = occ = 0;
|
||||
/* Bitmask of occupied tags */
|
||||
for (c = m->clients; c; c = c->next)
|
||||
occ |= c->tags;
|
||||
x += blw;
|
||||
if (ev->x < x) {
|
||||
click = ClkLtSymbol;
|
||||
|
||||
if (leftlayout)
|
||||
x += blw;
|
||||
if (ev->x < x && leftlayout) {
|
||||
click = ClkLtSymbol; // left layout
|
||||
} else {
|
||||
do {
|
||||
do {
|
||||
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
|
||||
continue;
|
||||
x += TEXTW(occ & 1 << i ? alttags[i] : tags[i]);
|
||||
|
@ -1014,7 +951,9 @@ if (!leftlayout) {
|
|||
selmon->mouseactivated = 1;
|
||||
click = ClkTagBar;
|
||||
arg.ui = 1 << i;
|
||||
} else if (ev->x > selmon->ww - statusw + lrpad - 2) {
|
||||
} else if (ev->x < x + blw && !leftlayout) // right layout
|
||||
click = ClkLtSymbol; // right layout
|
||||
else if (ev->x > selmon->ww - statusw + lrpad - 2) {
|
||||
x = selmon->ww - TEXTW(stext) + lrpad - 2;
|
||||
click = ClkStatusText;
|
||||
char *text = rawstext;
|
||||
|
@ -1034,7 +973,9 @@ if (!leftlayout) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
//x += blw;
|
||||
if (!leftlayout)
|
||||
x += blw; // Left layout does not need this
|
||||
|
||||
c = m->clients;
|
||||
|
||||
if (c) {
|
||||
|
@ -1042,7 +983,7 @@ if (!leftlayout) {
|
|||
if (!ISVISIBLE(c))
|
||||
continue;
|
||||
else
|
||||
x += (1.0 / (double)m->bt) * m->btw - 2 * sp;
|
||||
x += (1.0 / (double)m->bt) * m->btw;
|
||||
} while (ev->x > x && (c = c->next));
|
||||
|
||||
click = ClkWinTitle;
|
||||
|
@ -1050,13 +991,13 @@ if (!leftlayout) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if ((c = wintoclient(ev->window))) {
|
||||
focus(c);
|
||||
restack(selmon);
|
||||
XAllowEvents(dpy, ReplayPointer, CurrentTime);
|
||||
click = ClkClientWin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < LENGTH(buttons); i++)
|
||||
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
|
||||
|
|
Loading…
Reference in a new issue