JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
non-zero
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index dd55ee2..85292a9 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -60,7 +60,7 @@ enum { ColBorder, ColFG, ColBG, ColLast };              /* color */
 enum { NetSupported, NetWMName, NetLast };              /* EWMH atoms */
 enum { WMProtocols, WMDelete, WMName, WMState, WMLast };/* default atoms */
 enum { ClkLtSymbol = 64, ClkStatusText, ClkWinTitle,
-       ClkClientWin, ClkLast };                         /* clicks */
+       ClkClientWin, ClkRootWin, ClkLast };             /* clicks */
 
 /* typedefs */
 typedef unsigned int uint;
@@ -84,12 +84,12 @@ typedef struct {
 typedef struct Client Client;
 struct Client {
        char name[256];
+       float mina, maxa;
        int x, y, w, h;
        int basew, baseh, incw, inch, maxw, maxh, minw, minh;
-       float mina, maxa;
        int bw, oldbw;
-       Bool isbanned, isfixed, isfloating, ismoved, isurgent;
        uint tags;
+       Bool isbanned, isfixed, isfloating, ismoved, isurgent;
        Client *next;
        Client *snext;
        Window win;
@@ -312,7 +312,7 @@ buttonpress(XEvent *e) {
        Client *c;
        XButtonPressedEvent *ev = &e->xbutton;
 
-       click = ClkLast;
+       click = ClkRootWin;
        if(ev->window == barwin) {
                i = x = 0;
                do
@@ -327,8 +327,10 @@ buttonpress(XEvent *e) {
                else
                        click = ClkWinTitle;
        }
-       else if((c = getclient(ev->window)))
+       else if((c = getclient(ev->window))) {
+               focus(c);
                click = ClkClientWin;
+       }
 
        for(i = 0; i < LENGTH(buttons); i++)
                if(click == buttons[i].click && buttons[i].func && buttons[i].button == ev->button
@@ -911,7 +913,8 @@ manage(Window w, XWindowAttributes *wa) {
                if(c->y + c->h + 2 * c->bw > sy + sh)
                        c->y = sy + sh - c->h - 2 * c->bw;
                c->x = MAX(c->x, sx);
-               c->y = MAX(c->y, by == 0 ? bh : sy);
+               /* only fix client y-offset, if the client center might cover the bar */
+               c->y = MAX(c->y, ((by == 0) && (c->x + (c->w / 2) >= wx) && (c->x + (c->w / 2) < wx + ww)) ? bh : sy);
                c->bw = borderpx;
        }
 
@@ -980,11 +983,6 @@ movemouse(const Arg *arg) {
        None, cursor[CurMove], CurrentTime) != GrabSuccess)
                return;
        XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
-       if(x1 < c->x || x1 > c->x + c->w || y1 < c->y || y1 > c->y + c->h) {
-               XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, 0, 0);
-               x1 = c->x + 1;
-               y1 = c->y + 1;
-       }
        for(;;) {
                XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
                switch (ev.type) {
@@ -1096,11 +1094,11 @@ resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
 
                w = MAX(w, c->minw);
                h = MAX(h, c->minh);
-               
-               if (c->maxw)
+
+               if(c->maxw)
                        w = MIN(w, c->maxw);
 
-               if (c->maxh)
+               if(c->maxh)
                        h = MIN(h, c->maxh);
        }
        if(w <= 0 || h <= 0)
@@ -1498,14 +1496,22 @@ togglemax(const Arg *arg) {
 
 void
 toggletag(const Arg *arg) {
-       if(sel && (sel->tags ^= (arg->ui & TAGMASK)))
+       uint mask = sel->tags ^ (arg->ui & TAGMASK);
+
+       if(sel && mask) {
+               sel->tags = mask;
                arrange();
+       }
 }
 
 void
 toggleview(const Arg *arg) {
-       if((tagset[seltags] ^= (arg->ui & TAGMASK)))
+       uint mask = tagset[seltags] ^ (arg->ui & TAGMASK);
+
+       if(mask) {
+               tagset[seltags] = mask;
                arrange();
+       }
 }
 
 void