JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
show hidden slave windows in tabs at the bottom
[dwm.git] / dwm.c
diff --git a/dwm.c b/dwm.c
index 7b3c0ab..0d68749 100644 (file)
--- a/dwm.c
+++ b/dwm.c
@@ -192,8 +192,8 @@ static void pop(Client *);
 static void propertynotify(XEvent *e);
 static void quit(const Arg *arg);
 static Monitor *recttomon(int x, int y, int w, int h);
-static void resize(Client *c, int x, int y, int w, int h, Bool interact);
-static void resizeclient(Client *c, int x, int y, int w, int h);
+static void resize(Client *c, int x, int y, int w, int h, Bool interact, Client *base);
+static void resizeclient(Client *c, int x, int y, int w, int h, Client *base);
 static void resizemouse(const Arg *arg);
 static void restack(Monitor *m);
 static void run(void);
@@ -322,7 +322,7 @@ update_window_opacities(Monitor *m) {
                        } else if (c == master || c == slave) {
                                window_set_translucent(c);
                        } else {
-                               window_set_invisible(c);
+                               window_set_opaque(c);
                        }
                }
        }
@@ -887,6 +887,7 @@ focus(Client *c) {
                XDeleteProperty(dpy, root, netatom[NetActiveWindow]);
        }
        selmon->sel = c;
+       jason_layout(selmon);
        update_window_opacities(selmon);
        drawbars();
        if(c && (!root || (c->win!=root)) )
@@ -1196,7 +1197,7 @@ monocle(Monitor *m) {
        if(n > 0) /* override layout symbol */
                snprintf(m->ltsymbol, sizeof m->ltsymbol, "[%d]", n);
        for(c = nexttiled(m->clients); c; c = nexttiled(c->next))
-               resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False);
+               resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False, 0);
 }
 
 void
@@ -1265,7 +1266,7 @@ movemouse(const Arg *arg) {
                                        togglefloating(NULL);
                        }
                        if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
-                               resize(c, nx, ny, c->w, c->h, True);
+                               resize(c, nx, ny, c->w, c->h, True, 0);
                        break;
                }
        } while(ev.type != ButtonRelease);
@@ -1352,21 +1353,27 @@ recttomon(int x, int y, int w, int h) {
 }
 
 void
-resize(Client *c, int x, int y, int w, int h, Bool interact) {
+resize(Client *c, int x, int y, int w, int h, Bool interact, Client *base) {
        if(applysizehints(c, &x, &y, &w, &h, interact))
-               resizeclient(c, x, y, w, h);
+               resizeclient(c, x, y, w, h, base);
 }
 
 void
-resizeclient(Client *c, int x, int y, int w, int h) {
+resizeclient(Client *c, int x, int y, int w, int h, Client *base) {
        XWindowChanges wc;
+       unsigned long mask = CWX|CWY|CWWidth|CWHeight|CWBorderWidth;
 
        c->oldx = c->x; c->x = wc.x = x;
        c->oldy = c->y; c->y = wc.y = y;
        c->oldw = c->w; c->w = wc.width = w;
        c->oldh = c->h; c->h = wc.height = h;
+       if (base) {
+               wc.stack_mode = Above;
+               wc.sibling = base->win;
+               mask |= CWStackMode|CWSibling;
+       }
        wc.border_width = c->bw;
-       XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc);
+       XConfigureWindow(dpy, c->win, mask, &wc);
        configure(c);
        XSync(dpy, False);
 }
@@ -1413,7 +1420,7 @@ resizemouse(const Arg *arg) {
                                        togglefloating(NULL);
                        }
                        if(!selmon->lt[selmon->sellt]->arrange || c->isfloating)
-                               resize(c, c->x, c->y, nw, nh, True);
+                               resize(c, c->x, c->y, nw, nh, True, 0);
                        break;
                }
        } while(ev.type != ButtonRelease);
@@ -1441,10 +1448,11 @@ restack(Monitor *m) {
        if(m->lt[m->sellt]->arrange) {
                wc.stack_mode = Below;
                wc.sibling = m->barwin;
-               for(c = m->stack; c; c = c->snext)
+               for(c = m->clients; c; c = c->next)
                        if(!c->isfloating && ISVISIBLE(c)) {
                                XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
                                wc.sibling = c->win;
+                               wc.stack_mode = Above;
                        }
        }
        XSync(dpy, False);
@@ -1555,7 +1563,7 @@ setfullscreen(Client *c, Bool fullscreen) {
                c->oldbw = c->bw;
                c->bw = 0;
                c->isfloating = True;
-               resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
+               resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh, 0);
                XRaiseWindow(dpy, c->win);
        }
        else {
@@ -1568,7 +1576,7 @@ setfullscreen(Client *c, Bool fullscreen) {
                c->y = c->oldy;
                c->w = c->oldw;
                c->h = c->oldh;
-               resizeclient(c, c->x, c->y, c->w, c->h);
+               resizeclient(c, c->x, c->y, c->w, c->h, 0);
                arrange(c->mon);
        }
 }
@@ -1667,7 +1675,7 @@ showhide(Client *c) {
        if(ISVISIBLE(c)) { /* show clients top down */
                XMoveWindow(dpy, c->win, c->x, c->y);
                if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
-                       resize(c, c->x, c->y, c->w, c->h, False);
+                       resize(c, c->x, c->y, c->w, c->h, False, 0);
                showhide(c->snext);
        }
        else { /* hide clients bottom up */
@@ -1746,23 +1754,23 @@ tile(Monitor *m) {
        for(i = my = ty = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++)
                if(i < m->nmaster) {
                        h = (m->wh - my) / (MIN(n, m->nmaster) - i);
-                       resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False);
+                       resize(c, m->wx, m->wy + my, mw - (2*c->bw), h - (2*c->bw), False, 0);
                        my += HEIGHT(c);
                }
                else {
                        h = (m->wh - ty) / (n - i);
-                       resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False);
+                       resize(c, m->wx + mw, m->wy + ty, m->ww - mw - (2*c->bw), h - (2*c->bw), False, 0);
                        ty += HEIGHT(c);
                }
 }
 
 void
 jason_layout(Monitor *m) {
-       unsigned int i, n, mw;
-       Client *c, *vis_slave;
+       unsigned int i, tiled_count, mw, right_width, tabs_count, cur_tab;
+       Client *c, *vis_slave, *base = 0;
 
-       for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
-       if(n == 0) {
+       for(tiled_count = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), tiled_count++);
+       if(tiled_count == 0) {
                return;
        }
 
@@ -1773,7 +1781,7 @@ jason_layout(Monitor *m) {
        } else {
                vis_slave = m->sel;
        }
-       if(n > 1 || (n == 1 && !c->screen_hog)) {
+       if(tiled_count > 1 || (tiled_count == 1 && !c->screen_hog)) {
                mw = m->ww * m->mfact;
        } else {
                // one of these:
@@ -1782,18 +1790,23 @@ jason_layout(Monitor *m) {
                // * miltiple tiled windows
                mw = m->ww;
        }
+       right_width = m->ww - mw;
+       tabs_count = tiled_count - 2;
+       cur_tab = 0;
        for (i = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), i++) {
                if (i == 0) {
-                       resize(c, m->wx, m->wy, mw, m->wh, False);
+                       resize(c, m->wx, m->wy, mw, m->wh, False, 0);
                } else {
                        if (c == vis_slave) {
-                               resize(c, m->wx + mw, m->wy, m->ww - mw, m->wh, False);
+                               resize(c, m->wx + mw, m->wy, right_width, m->wh - 30, False, base);
                        } else {
                                // this function does not get called when focus changes
                                // resize(c, m->wx + m->ww, m->wy, m->ww - mw, m->wh, False);
-                               resize(c, m->wx + mw, m->wy, m->ww - mw, m->wh, False);
+                               resize(c, m->wx + mw + right_width * cur_tab / tabs_count, m->wy + m->wh - 20, right_width, m->wh - 30, False, base);
+                               cur_tab += 1;
                        }
                }
+               base = c;
        }
 }
 
@@ -1814,7 +1827,7 @@ togglefloating(const Arg *arg) {
        selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
        if(selmon->sel->isfloating)
                resize(selmon->sel, selmon->sel->x, selmon->sel->y,
-                      selmon->sel->w, selmon->sel->h, False);
+                      selmon->sel->w, selmon->sel->h, False, 0);
        arrange(selmon);
 }