JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
making enternotify less focus hungry
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index f6cec0b..8c1adeb 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -42,7 +42,7 @@
 
 /* macros */
 #define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
-#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
+#define CLEANMASK(mask)         (mask & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
 #define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
 #define ISVISIBLE(C)            ((C->tags & C->mon->tagset[C->mon->seltags]))
 #define LENGTH(X)               (sizeof X / sizeof X[0])
@@ -585,11 +585,13 @@ void
 configurenotify(XEvent *e) {
        Monitor *m;
        XConfigureEvent *ev = &e->xconfigure;
+       Bool dirty;
 
        if(ev->window == root) {
+               dirty = (sw != ev->width);
                sw = ev->width;
                sh = ev->height;
-               if(updategeom()) {
+               if(updategeom() || dirty) {
                        if(dc.drawable != 0)
                                XFreePixmap(dpy, dc.drawable);
                        dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
@@ -818,15 +820,19 @@ drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
 
 void
 enternotify(XEvent *e) {
+       Client *c;
        Monitor *m;
        XCrossingEvent *ev = &e->xcrossing;
 
        if((ev->mode != NotifyNormal || ev->detail == NotifyInferior) && ev->window != root)
                return;
+       c = wintoclient(ev->window);
        if((m = wintomon(ev->window)) && m != selmon) {
                unfocus(selmon->sel, True);
                selmon = m;
        }
+       else if(c == selmon->sel || c == NULL)
+               return;
        focus((wintoclient(ev->window)));
 }
 
@@ -2034,7 +2040,6 @@ zoom(const Arg *arg) {
        Client *c = selmon->sel;
 
        if(!selmon->lt[selmon->sellt]->arrange
-       || selmon->lt[selmon->sellt]->arrange == monocle
        || (selmon->sel && selmon->sel->isfloating))
                return;
        if(c == nexttiled(selmon->clients))