JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
bar shows if currently is tiled (Mod1-space) or floating (Mod1-Shift-space) mode
[dwm.git] / client.c
index 029a59c..5b666c9 100644 (file)
--- a/client.c
+++ b/client.c
@@ -28,17 +28,21 @@ next(Client *c)
 void
 zoom(Arg *arg)
 {
-       Client **l, *old;
+       Client **l, *c;
 
-       if(!(old = sel))
+       if(!sel)
                return;
 
+       if(sel == next(clients) && sel->next)  {
+               if((c = next(sel->next)))
+                       sel = c;
+       }
+
        for(l = &clients; *l && *l != sel; l = &(*l)->next);
        *l = sel->next;
 
-       old->next = clients; /* pop */
-       clients = old;
-       sel = old;
+       sel->next = clients; /* pop */
+       clients = sel;
        arrange(NULL);
        focus(sel);
 }
@@ -54,7 +58,6 @@ max(Arg *arg)
        sel->h = sh - 2 * sel->border - bh;
        craise(sel);
        resize(sel, False);
-       discard_events(EnterWindowMask);
 }
 
 void
@@ -65,9 +68,6 @@ view(Arg *arg)
        tsel = arg->i;
        arrange(NULL);
 
-       if((c = next(clients)))
-               focus(c);
-
        for(c = clients; c; c = next(c->next))
                draw_client(c);
        draw_bar();
@@ -120,7 +120,7 @@ floating(Arg *arg)
                        focus(sel);
                }
        }
-       discard_events(EnterWindowMask);
+       draw_bar();
 }
 
 void
@@ -171,13 +171,13 @@ tiling(Arg *arg)
                else
                        ban_client(c);
        }
-       if(sel && !sel->tags[tsel]) {
+       if(!sel || (sel && !sel->tags[tsel])) {
                if((sel = next(clients))) {
                        craise(sel);
                        focus(sel);
                }
        }
-       discard_events(EnterWindowMask);
+       draw_bar();
 }
 
 void
@@ -323,14 +323,16 @@ void
 focus(Client *c)
 {
        Client *old = sel;
+       XEvent ev;
 
+       XFlush(dpy);
        sel = c;
        if(old && old != c)
                draw_client(old);
        draw_client(c);
        XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
        XFlush(dpy);
-       discard_events(EnterWindowMask);
+       while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
 }
 
 static void
@@ -499,6 +501,10 @@ resize(Client *c, Bool inc)
                if(c->inch)
                        c->h -= (c->h - c->baseh) % c->inch;
        }
+       if(c->x > sw) /* might happen on restart */
+               c->x = sw - c->w;
+       if(c->y > sh)
+               c->ty = c->y = sh - c->h;
        if(c->minw && c->w < c->minw)
                c->w = c->minw;
        if(c->minh && c->h < c->minh)
@@ -600,12 +606,12 @@ draw_client(Client *c)
                if(c->tags[i]) {
                        dc.x += dc.w;
                        dc.w = textw(c->tags[i]) + dc.font.height;
-                       drawtext(c->tags[i], True);
+                       drawtext(c->tags[i], False, True);
                }
        }
        dc.x += dc.w;
        dc.w = textw(c->name) + dc.font.height;
-       drawtext(c->name, True);
+       drawtext(c->name, False, True);
        XCopyArea(dpy, dc.drawable, c->title, dc.gc,
                        0, 0, c->tw, c->th, 0, 0);
        XFlush(dpy);