diff options
Diffstat (limited to 'monsterwm.c')
| -rw-r--r-- | monsterwm.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/monsterwm.c b/monsterwm.c index 2f00afc..26dd19a 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -234,11 +234,10 @@ Client* addwindow(Window w, Desktop *d) { * call the appropriate handler */ void buttonpress(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; + Desktop *d = NULL; Client *c = NULL; + Bool w = wintoclient(e->xbutton.window, &c, &d); - if (wintoclient(e->xbutton.window, &c, &d) && CLICK_TO_FOCUS && - c != d->curr && e->xbutton.button == FOCUS_BUTTON) focus(c, d); + if (w && CLICK_TO_FOCUS && c != d->curr && e->xbutton.button == FOCUS_BUTTON) focus(c, d); for (unsigned int i = 0; i < LENGTH(buttons); i++) if (CLEANMASK(buttons[i].mask) == CLEANMASK(e->xbutton.state) && @@ -327,9 +326,7 @@ void client_to_desktop(const Arg *arg) { * on its desktop. */ void clientmessage(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; - + Desktop *d = NULL; Client *c = NULL; if (!wintoclient(e->xclient.window, &c, &d)) return; if (e->xclient.message_type == netatoms[NET_WM_STATE] && ( @@ -423,8 +420,7 @@ void desktopinfo(void) { * on receival, remove the client that held that window */ void destroynotify(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; + Desktop *d = NULL; Client *c = NULL; if (wintoclient(e->xdestroywindow.window, &c, &d)) removeclient(c, d); } @@ -435,8 +431,7 @@ void destroynotify(XEvent *e) { * and will get focus if FOLLOW_MOUSE is set in the config. */ void enternotify(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; + Desktop *d = NULL; Client *c = NULL; if (FOLLOW_MOUSE && wintoclient(e->xcrossing.window, &c, &d) && e->xcrossing.mode == NotifyNormal && e->xcrossing.detail != NotifyInferior && e->xcrossing.window != d->curr->win) focus(c, d); @@ -551,9 +546,7 @@ void focus(Client *c, Desktop *d) { * client, by the user, through the wm. */ void focusin(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; - + Desktop *d = NULL; Client *c = NULL; if (wintoclient(e->xfocus.window, &c, &d) && d->curr && e->xfocus.window != d->curr->win) focus(d->curr, d); } @@ -665,16 +658,15 @@ void killclient(void) { * then display/map the window, else, if follow is set, focus the new desktop. */ void maprequest(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; + Desktop *d = NULL; Client *c = NULL; Window w = e->xmaprequest.window; XWindowAttributes wa = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return; + XClassHint ch = {0, 0}; Bool follow = False, floating = False; int newdsk = currdeskidx; - if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return; - if (XGetClassHint(dis, w, &ch)) for (unsigned int i = 0; i < LENGTH(rules); i++) if (strstr(ch.res_class, rules[i].class) || strstr(ch.res_name, rules[i].class)) { if (rules[i].desktop >= 0 && rules[i].desktop < DESKTOPS) newdsk = rules[i].desktop; @@ -880,11 +872,12 @@ void prev_win(void) { * set unrgent hint for a window */ void propertynotify(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; + Desktop *d = NULL; Client *c = NULL; if (e->xproperty.atom != XA_WM_HINTS || !wintoclient(e->xproperty.window, &c, &d)) return; + XWMHints *wmh = XGetWMHints(dis, c->win); c->isurgn = (c != desktops[currdeskidx].curr && wmh && (wmh->flags & XUrgencyHint)); + if (wmh) XFree(wmh); desktopinfo(); } @@ -1092,8 +1085,7 @@ void tile(Desktop *d) { * client, so invisible windows do not exist on screen */ void unmapnotify(XEvent *e) { - Desktop *d = NULL; - Client *c = NULL; + Desktop *d = NULL; Client *c = NULL; if (e->xunmap.send_event && wintoclient(e->xunmap.window, &c, &d)) removeclient(c, d); } |
