From 24b94d72ba73bf4c4c4cadde3136e5ad1de528af Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Fri, 20 Jul 2012 17:11:43 +0300 Subject: rework buttonpress fuction - allow commands even if no window is there --- monsterwm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'monsterwm.c') diff --git a/monsterwm.c b/monsterwm.c index e176855..c586fc2 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -237,15 +237,14 @@ void buttonpress(XEvent *e) { Desktop *d = NULL; Client *c = NULL; - if (!wintoclient(e->xbutton.window, &c, &d)) return; - - if (CLICK_TO_FOCUS && d->curr != c && e->xbutton.button == Button1) focus(c, d); + if (wintoclient(e->xbutton.window, &c, &d) && CLICK_TO_FOCUS && + c != d->curr && e->xbutton.button == Button1) focus(c, d); for (unsigned int i = 0; i < LENGTH(buttons); i++) - if (CLEANMASK(buttons[i].mask) == CLEANMASK(e->xbutton.state) - && buttons[i].button == e->xbutton.button) { - if (d->curr != c) focus(c, d); - if (buttons[i].func) buttons[i].func(&(buttons[i].arg)); + if (CLEANMASK(buttons[i].mask) == CLEANMASK(e->xbutton.state) && + buttons[i].func && buttons[i].button == e->xbutton.button) { + if (c && d->curr != c) focus(c, d); + buttons[i].func(&(buttons[i].arg)); } } -- cgit v1.3.1