Do not handle bar clicks

This commit is contained in:
Alex Kotov 2021-11-20 01:07:54 +05:00
parent 1cdf2bc180
commit 18b5b78d73
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 14 additions and 28 deletions

View File

@ -106,15 +106,11 @@ static Key keys[] = {
}; };
/* button definitions */ /* button definitions */
/* click can be ClkTagBar, ClkLtSymbol, ClkClientWin, or ClkRootWin */ /* click can be ClkClientWin, or ClkRootWin */
static Button buttons[] = { static Button buttons[] = {
/* click event mask button function argument */ /* click event mask button function argument */
{ ClkClientWin, MODKEY, Button1, movemouse, {0} }, { ClkClientWin, MODKEY, Button1, movemouse, {0} },
{ ClkClientWin, MODKEY, Button2, togglefloating, {0} }, { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
{ ClkClientWin, MODKEY, Button3, resizemouse, {0} }, { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
{ ClkTagBar, 0, Button1, view, {0} },
{ ClkTagBar, 0, Button3, toggleview, {0} },
{ ClkTagBar, MODKEY, Button1, tag, {0} },
{ ClkTagBar, MODKEY, Button3, toggletag, {0} },
}; };

View File

@ -74,7 +74,7 @@
enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
enum { SchemeNorm, SchemeSel }; /* color schemes */ enum { SchemeNorm, SchemeSel }; /* color schemes */
enum { ClkTagBar, ClkLtSymbol, ClkClientWin, ClkRootWin, ClkLast }; /* clicks */ enum { ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
typedef struct Monitor Monitor; typedef struct Monitor Monitor;
typedef struct Client Client; typedef struct Client Client;

View File

@ -4,8 +4,7 @@
void void
on_button_press(XEvent *e) on_button_press(XEvent *e)
{ {
unsigned int i, x, click, occ = 0; unsigned int i, click;
Arg arg = {0};
Client *c; Client *c;
Monitor *m; Monitor *m;
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
@ -18,32 +17,23 @@ on_button_press(XEvent *e)
selmon = m; selmon = m;
focus(NULL); focus(NULL);
} }
if (ev->window == selmon->barwin) { if ((c = wintoclient(ev->window))) {
i = x = 0;
for (c = m->clients; c; c = c->next)
occ |= c->tags == 255 ? 0 : c->tags;
do {
/* do not reserve space for vacant tags */
if (!(occ & 1 << i || m->tagset[m->seltags] & 1 << i || tags_get(i)->has_custom_name))
continue;
x += TEXTW(tags_get(i)->name.cstr);
} while (ev->x >= x && ++i < TAGS_COUNT);
if (i < TAGS_COUNT) {
click = ClkTagBar;
arg.ui = 1 << i;
} else if (ev->x < x + blw) {
click = ClkLtSymbol;
}
} else if ((c = wintoclient(ev->window))) {
if (settings_get_focus_on_wheel() || (ev->button != Button4 && ev->button != Button5)) if (settings_get_focus_on_wheel() || (ev->button != Button4 && ev->button != Button5))
focus(c); focus(c);
XAllowEvents(dpy, ReplayPointer, CurrentTime); XAllowEvents(dpy, ReplayPointer, CurrentTime);
click = ClkClientWin; click = ClkClientWin;
} }
for (i = 0; i < LENGTH(buttons); i++) for (i = 0; i < LENGTH(buttons); i++)
if (click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button if (
&& CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)) click == buttons[i].click
buttons[i].func(click == ClkTagBar && buttons[i].arg.i == 0 ? &arg : &buttons[i].arg); &&
buttons[i].func
&&
buttons[i].button == ev->button
&&
CLEANMASK(buttons[i].mask) == CLEANMASK(ev->state)
)
buttons[i].func(&buttons[i].arg);
} }
void void