]> git.armaanb.net Git - dwm.git/commitdiff
removed VRATIO, NMASTER, inc*(), renamed HRATIO into MASTER, see mailinglist for...
authorAnselm R. Garbe <garbeam@gmail.com>
Fri, 10 Aug 2007 16:16:05 +0000 (18:16 +0200)
committerAnselm R. Garbe <garbeam@gmail.com>
Fri, 10 Aug 2007 16:16:05 +0000 (18:16 +0200)
client.c
config.arg.h
config.default.h
dwm.1
dwm.h
event.c
layout.c
tag.c

index d4dfe6e6806b7735df9f599cab784fa9652ecbe1..08fe1bddc8de1b532559f2c791ac33d3d573b6c3 100644 (file)
--- a/client.c
+++ b/client.c
@@ -230,7 +230,7 @@ manage(Window w, XWindowAttributes *wa) {
        setclientstate(c, IconicState);
        c->isbanned = True;
        focus(c);
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
@@ -305,7 +305,7 @@ togglefloating(const char *arg) {
        sel->isfloating = !sel->isfloating;
        if(sel->isfloating)
                resize(sel, sel->x, sel->y, sel->w, sel->h, True);
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
@@ -337,7 +337,7 @@ unmanage(Client *c) {
        XSync(dpy, False);
        XSetErrorHandler(xerror);
        XUngrabServer(dpy);
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
index d5994b20238bd109155ebdb41df513800250fd5c..4d441f828e9e91c1bb4b707845d41726c334c9fc 100644 (file)
@@ -24,15 +24,14 @@ static Rule rule[] = { \
 };
 
 /* layout(s) */
+void tile(const char *arg);            /* arranges all windows tiled */
 #define LAYOUTS \
 static Layout layout[] = { \
        /* symbol               function */ \
        { "[]=",                tile }, /* first entry is default */ \
        { "><>",                floating }, \
 };
-#define NMASTER                        1       /* clients in master area */
-#define HRATIO                 .8      /* horizontal ratio of tile */
-#define VRATIO                 .9      /* vertical ratio of tile */
+#define MASTER                 0.6     /* 0.1 .. 0.9 */
 #define SNAP                   32      /* snap pixel */
 
 /* key definitions */
@@ -47,14 +46,10 @@ static Key key[] = { \
                "exec urxvtcd -tr -bg '#111' -fg '#eee' -cr '#eee' +sb -fn '"FONT"'" }, \
        { MODKEY,                       XK_space,       setlayout,      NULL }, \
        { MODKEY,                       XK_b,           togglebar,      NULL }, \
-       { MODKEY,                       XK_h,           incnmaster,     "1" }, \
-       { MODKEY,                       XK_l,           incnmaster,     "-1" }, \
+       { MODKEY,                       XK_h,           tile,           "-0.05" }, \
        { MODKEY,                       XK_j,           focusclient,    "1" }, \
        { MODKEY,                       XK_k,           focusclient,    "-1" }, \
-       { MODKEY|ShiftMask,             XK_h,           inchratio,      ".1" }, \
-       { MODKEY|ShiftMask,             XK_l,           inchratio,      "-.1" }, \
-       { MODKEY|ShiftMask,             XK_j,           incvratio,      "-.1" }, \
-       { MODKEY|ShiftMask,             XK_k,           incvratio,      ".1" }, \
+       { MODKEY,                       XK_l,           tile,           "0.05" }, \
        { MODKEY,                       XK_m,           togglemax,      NULL }, \
        { MODKEY,                       XK_Return,      zoom,           NULL }, \
        { MODKEY|ShiftMask,             XK_space,       togglefloating, NULL }, \
index eaba9fb663acce63c001b8ec21e8be36669eed47..ec32e9dafb548cc906f4e364b7dab2275947b03a 100644 (file)
@@ -25,15 +25,14 @@ static Rule rule[] = { \
 };
 
 /* layout(s) */
+void tile(const char *arg);            /* arranges all windows tiled */
 #define LAYOUTS \
 static Layout layout[] = { \
        /* symbol               function */ \
        { "[]=",                tile }, /* first entry is default */ \
        { "><>",                floating }, \
 };
-#define NMASTER                        1       /* clients in master area */
-#define HRATIO                 .8      /* horizontal ratio of tile */
-#define VRATIO                 1       /* vertical ratio of tile */
+#define MASTER                 0.6     /* 0.1 .. 0.9 */
 #define SNAP                   32      /* snap pixel */
 
 /* key definitions */
@@ -45,14 +44,10 @@ static Key key[] = { \
        { MODKEY,                       XK_p,           spawn,          "exe=`dmenu_path | dmenu` && exec $exe" }, \
        { MODKEY,                       XK_space,       setlayout,      NULL }, \
        { MODKEY,                       XK_b,           togglebar,      NULL }, \
-       { MODKEY,                       XK_h,           incnmaster,     "1" }, \
-       { MODKEY,                       XK_l,           incnmaster,     "-1" }, \
+       { MODKEY,                       XK_h,           tile,           "-0.05" }, \
        { MODKEY,                       XK_j,           focusclient,    "1" }, \
        { MODKEY,                       XK_k,           focusclient,    "-1" }, \
-       { MODKEY|ShiftMask,             XK_h,           inchratio,      ".1" }, \
-       { MODKEY|ShiftMask,             XK_l,           inchratio,      "-.1" }, \
-       { MODKEY|ShiftMask,             XK_j,           incvratio,      "-.1" }, \
-       { MODKEY|ShiftMask,             XK_k,           incvratio,      ".1" }, \
+       { MODKEY,                       XK_l,           tile,           "0.05" }, \
        { MODKEY,                       XK_m,           togglemax,      NULL }, \
        { MODKEY,                       XK_Return,      zoom,           NULL }, \
        { MODKEY|ShiftMask,             XK_space,       togglefloating, NULL }, \
diff --git a/dwm.1 b/dwm.1
index 47b888050f2be44ccea6d940690184f82356e481..885405aeca593589e853bad836870b85d6e5d96a 100644 (file)
--- a/dwm.1
+++ b/dwm.1
@@ -10,7 +10,7 @@ floating layouts. Either layout can be applied dynamically, optimizing the
 environment for the application in use and the task performed.
 .P
 In tiled layout windows are managed in a master and stacking area. The master
-area contains the windows which currently need most attention, whereas the
+area contains the window which currently needs most attention, whereas the
 stacking area contains all other windows. In floating layout windows can be
 resized and moved freely. Dialog windows are always managed floating,
 regardless of the layout applied.
@@ -62,29 +62,17 @@ Zooms/cycles current window to/from master area (tiled layout only).
 .B Mod1\-b
 Shows/hides the status bar.
 .TP
+.B Mod1\-h
+Decreases the master area width about 5% (tiled layout only).
+.TP
 .B Mod1\-j
 Focus next window.
 .TP
 .B Mod1\-k
 Focus previous window.
 .TP
-.B Mod1\-h
-Increase the number of windows in the master area (tiled layout only).
-.TP
 .B Mod1\-l
-Decrease the number of windows in the master area (tiled layout only).
-.TP
-.B Mod1\-Shift\-k
-Increase vertical tile ratio, effects tile heights (tiled layout only).
-.TP
-.B Mod1\-Shift\-j
-Decrease vertical tile ratio, effects tile heights (tiled layout only).
-.TP
-.B Mod1\-Shift\-h
-Increase horizontal tile ratio, effects master area width (tiled layout only).
-.TP
-.B Mod1\-Shift\-l
-Decrease horizontal tile ratio, effects master area width (tiled layout only).
+Increases the master area width about 5% (tiled layout only).
 .TP
 .B Mod1\-m
 Toggles maximization of current window (floating layout only).
diff --git a/dwm.h b/dwm.h
index 7f7d42243b1b8eb5da8baa51888f6fe41afd5097..d20cf32bd029672d777d6aaeec420ebc82f032c1 100644 (file)
--- a/dwm.h
+++ b/dwm.h
@@ -76,7 +76,7 @@ typedef struct {
 
 typedef struct {
        const char *symbol;
-       void (*arrange)(void);
+       void (*arrange)(const char *);
 } Layout;
 
 extern const char *tags[];                     /* all tags */
@@ -120,11 +120,8 @@ unsigned int textw(const char *text);      /* return the width of text in px*/
 void grabkeys(void);                   /* grab all keys defined in config.h */
 
 /* layout.c */
-void floating(void);                   /* arranges all windows floating */
+void floating(const char *arg);                /* arranges all windows floating */
 void focusclient(const char *arg);     /* focuses next(1)/previous(-1) visible client */
-void inchratio(const char *arg);       /* increments the horizontal tile ratio with arg's value */
-void incvratio(const char *arg);       /* increments the vertical tile ratio with arg's value */
-void incnmaster(const char *arg);      /* increments nmaster with arg's index value */
 void initlayouts(void);                        /* initialize layout array */
 Client *nexttiled(Client *c);          /* returns tiled successor of c */
 void restack(void);                    /* restores z layers of all clients */
diff --git a/event.c b/event.c
index d0716fa842466b0f419b63de4d7f1bf76c451afb..0fa1081c9dfc9084be1e360c8294d3f887c13561 100644 (file)
--- a/event.c
+++ b/event.c
@@ -216,7 +216,7 @@ configurenotify(XEvent *e) {
                dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
                XResizeWindow(dpy, barwin, sw, bh);
                updatebarpos();
-               lt->arrange();
+               lt->arrange(NULL);
        }
 }
 
@@ -317,7 +317,7 @@ propertynotify(XEvent *e) {
                        case XA_WM_TRANSIENT_FOR:
                                XGetTransientForHint(dpy, c->win, &trans);
                                if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL)))
-                                       lt->arrange();
+                                       lt->arrange(NULL);
                                break;
                        case XA_WM_NORMAL_HINTS:
                                updatesizehints(c);
index 7a7abae20fc98815da1d93dc548e42c638169a70..000239791f2458cf8b5144b74c029d4eb37cf7d2 100644 (file)
--- a/layout.c
+++ b/layout.c
@@ -8,131 +8,19 @@ Layout *lt = NULL;
 
 /* static */
 
-static double hratio = HRATIO;
-static double vratio = VRATIO;
 static unsigned int nlayouts = 0;
-static unsigned int nmaster = NMASTER;
-
-static double /* simple pow() */
-spow(double x, double y)
-{
-       if(y == 0)
-               return 1;
-       while(--y)
-               x *= x;
-       return x;
-}
-
-static void
-tile(void) {
-       Bool mmaxtile = False, smaxtile = False; /* fallback tiling */
-       double mscale = 0, sscale = 0, sum = 0;
-       unsigned int i, n, nx, ny, nw, nh, mw, tw;
-       Client *c;
-
-       /* preparation */
-       for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
-               n++;
-       nx = wax;
-       ny = way;
-       mw = (n <= nmaster) ? waw :  waw / (1 + hratio);
-       tw = waw - mw;
-       if(n > 0) {
-               if(n <= nmaster) {
-                       for(i = 0; i < n; i++)
-                               sum += spow(vratio, i);
-                       mscale = wah / sum;
-                       if(vratio >= 1)
-                               mmaxtile = bh > mscale;
-                       else
-                               mmaxtile = bh > (mscale * spow(vratio, n - 1));
-               }
-               else {
-                       for(i = 0; i < nmaster; i++)
-                               sum += spow(vratio, i);
-                       mscale = wah / sum;
-                       for(sum = 0, i = 0; i < (n - nmaster); i++)
-                               sum += spow(vratio, i);
-                       sscale = wah / sum;
-                       if(vratio >= 1) {
-                               mmaxtile = bh > mscale;
-                               smaxtile = bh > sscale;
-                       }
-                       else {
-                               mmaxtile = bh > (mscale * spow(vratio, nmaster - 1));
-                               smaxtile = bh > (sscale * spow(vratio, n - nmaster - 1));
-                       }
-               }
-       }
-       /* tiling */
-       for(i = 0, c = clients; c; c = c->next)
-               if(isvisible(c)) {
-                       unban(c);
-                       if(c->isfloating)
-                               continue;
-                       c->ismax = False;
-                       if(i < nmaster) { /* master window */
-                               nw = mw - 2 * c->border;
-                               if(mmaxtile) {
-                                       ny = way;
-                                       nh = wah - 2 * c->border;
-                               }
-                               else if(i + 1 == (n < nmaster ? n : nmaster))
-                                       nh = (way + wah) - ny - 2 * c->border;
-                               else
-                                       nh = (mscale * spow(vratio, i)) - 2 * c->border;
-                       }
-                       else { /* tile window */
-                               nw = tw - 2 * c->border;
-                               if(i == nmaster) {
-                                       ny = way;
-                                       nx = wax + mw;
-                               }
-                               if(smaxtile) {
-                                       ny = way;
-                                       nh = wah - 2 * c->border;
-                               }
-                               else if(i + 1 == n)
-                                       nh = (way + wah) - ny - 2 * c->border;
-                               else
-                                       nh = (sscale * spow(vratio, i - nmaster)) - 2 * c->border;
-                       }
-                       resize(c, nx, ny, nw, nh, False);
-                       ny += nh;
-                       i++;
-               }
-               else
-                       ban(c);
-       focus(NULL);
-       restack();
-}
 
 LAYOUTS
 
-static void
-incratio(const char *arg, double *ratio, double def) {
-       double delta;
-
-       if(lt->arrange != tile)
-               return;
-       if(!arg)
-               *ratio = def;
-       else {
-               if(1 == sscanf(arg, "%lf", &delta)) {
-                       if(delta + (*ratio) < .1 || delta + (*ratio) > 1.9)
-                               return;
-                       *ratio += delta;
-               }
-       }
-       lt->arrange();
-}
-
 /* extern */
 
 void
-floating(void) {
+floating(const char *arg) {
        Client *c;
 
+       if(lt->arrange != floating)
+               return;
+
        for(c = clients; c; c = c->next)
                if(isvisible(c)) {
                        unban(c);
@@ -168,35 +56,6 @@ focusclient(const char *arg) {
        }
 }
 
-void
-inchratio(const char *arg) {
-       incratio(arg, &hratio, HRATIO);
-}
-
-void
-incvratio(const char *arg) {
-       incratio(arg, &vratio, VRATIO);
-}
-
-void
-incnmaster(const char *arg) {
-       int i;
-
-       if(!arg)
-               nmaster = NMASTER;
-       else {
-               i = atoi(arg);
-               if((lt->arrange != tile) || (nmaster + i < 1)
-               || (wah / (nmaster + i) <= 2 * BORDERPX))
-                       return;
-               nmaster += i;
-       }
-       if(sel)
-               lt->arrange();
-       else
-               drawstatus();
-}
-
 void
 initlayouts(void) {
        unsigned int i, w;
@@ -261,11 +120,70 @@ setlayout(const char *arg) {
                lt = &layout[i];
        }
        if(sel)
-               lt->arrange();
+               lt->arrange(NULL);
        else
                drawstatus();
 }
 
+void
+tile(const char *arg) {
+       static double master = MASTER;
+       double delta;
+       unsigned int i, n, nx, ny, nw, nh, mw, th;
+       Client *c;
+
+       if(lt->arrange != tile)
+               return;
+
+       /* arg handling, manipulate master */
+       if(arg && (1 == sscanf(arg, "%lf", &delta))) {
+               if(delta + master > 0.1 && delta + master < 0.9)
+                       master += delta;
+       }
+
+       for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
+               n++;
+
+       /* window geoms */
+       mw = (n == 1) ? waw : master * waw;
+       th = (n > 1) ? wah / (n - 1) : 0;
+       if(n > 1 && th < bh)
+               th = wah;
+
+       nx = wax;
+       ny = way;
+       for(i = 0, c = clients; c; c = c->next)
+               if(isvisible(c)) {
+                       unban(c);
+                       if(c->isfloating)
+                               continue;
+                       c->ismax = False;
+                       if(i == 0) { /* master */
+                               nw = mw - 2 * c->border;
+                               nh = wah - 2 * c->border;
+                       }
+                       else {  /* tile window */
+                               if(i == 1) {
+                                       ny = way;
+                                       nx += mw;
+                               }
+                               nw = waw - mw - 2 * c->border;
+                               if(i + 1 == n) /* remainder */
+                                       nh = (way + wah) - ny - 2 * c->border;
+                               else
+                                       nh = th - 2 * c->border;
+                       }
+                       resize(c, nx, ny, nw, nh, False);
+                       if(n > 1 && th != wah)
+                               ny += nh;
+                       i++;
+               }
+               else
+                       ban(c);
+       focus(NULL);
+       restack();
+}
+
 void
 togglebar(const char *arg) {
        if(bpos == BarOff)
@@ -273,7 +191,7 @@ togglebar(const char *arg) {
        else
                bpos = BarOff;
        updatebarpos();
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
@@ -307,5 +225,5 @@ zoom(const char *arg) {
        detach(c);
        attach(c);
        focus(c);
-       lt->arrange();
+       lt->arrange(NULL);
 }
diff --git a/tag.c b/tag.c
index c44954b52a3e55ca5aa8626805e9f7564fd826aa..e9d6445c40c28c4fe319bdf36bb838c0bd190f7a 100644 (file)
--- a/tag.c
+++ b/tag.c
@@ -110,7 +110,7 @@ tag(const char *arg) {
        i = arg ? atoi(arg) : 0;
        if(i >= 0 && i < ntags)
                sel->tags[i] = True;
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
@@ -124,7 +124,7 @@ toggletag(const char *arg) {
        for(j = 0; j < ntags && !sel->tags[j]; j++);
        if(j == ntags)
                sel->tags[i] = True;
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
@@ -136,7 +136,7 @@ toggleview(const char *arg) {
        for(j = 0; j < ntags && !seltag[j]; j++);
        if(j == ntags)
                seltag[i] = True; /* cannot toggle last view */
-       lt->arrange();
+       lt->arrange(NULL);
 }
 
 void
@@ -148,5 +148,5 @@ view(const char *arg) {
        i = arg ? atoi(arg) : 0;
        if(i >= 0 && i < ntags)
                seltag[i] = True;
-       lt->arrange();
+       lt->arrange(NULL);
 }