Commits

Anonymous committed 3d273d0

nmaster implementiert, aber noch ein tagandview-bug

Comments (0)

Files changed (3)

 static const unsigned int snap      = 32;       /* snap pixel */
 static const Bool showbar           = True;     /* False means no bar */
 static const Bool topbar            = True;     /* False means bottom bar */
-static const int nmaster            = 2;
+#define NMASTER
 
+#ifdef NMASTER 
+static const int nmaster            = 1;
+#endif
 /* tagging */
 static const char *tags[] = { "main", "web", "less", "edit", "tv"};
 
 };
 
 #include <functions.h>
-#include <nmaster.c>
 
 /* layout(s) */
 static const float mfact      = 0.62; /* factor of master area size [0.05..0.95] */
 
 static const Layout layouts[] = {
 	/* symbol     arrange function */
-	{ "[]=",      tile },    /* first entry is default */
+    { "-|=",      ntile },
+	//{ "[]=",      tile },    /* first entry is default */
 	{ "[M]",      monocle },
 	{ "><>",      NULL },    /* no layout function means floating behavior */
 };
     { MODKEY,                     XK_l,      focusmon,         {.i = +1 } },
     { Mod4Mask,                     XK_h,      tagmon,         {.i = -1 } },
     { Mod4Mask,                     XK_l,      tagmon,         {.i = +1 } },
+    { MODKEY,                       XK_plus,    incnmaster,    {.i = +1 } },
+    { MODKEY,                       XK_minus,    incnmaster,    {.i = -1 } },
     TAGKEYS(                        XK_1,                      0)
     TAGKEYS(                        XK_2,                      1)
     TAGKEYS(                        XK_3,                      2)
     { ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
     { ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
 };
+
 static void tag(const Arg *arg);
 static void tagmon(const Arg *arg);
 static int textnw(const char *text, unsigned int len);
-static void tile(Monitor *);
+#ifndef NMASTER
+void tile(Monitor *);
+#endif
 static void togglebar(const Arg *arg);
 static void togglefloating(const Arg *arg);
 static void toggletag(const Arg *arg);
 	const Layout *lts[LENGTH(tags) + 1];
 	double mfacts[LENGTH(tags) + 1];
 	Bool showbars[LENGTH(tags) + 1];
+#ifdef NMASTER
+    int nmaster;
+    int nmasters[LENGTH(tags) + 1];
+#endif
 };
 
 #include <functions.c>
 	attach(c);
 	attachstack(c);
 	focus(NULL);
-	arrange(NULL);
+    arrange(NULL);
+    arrange(m);
 }
 
 void
 			m->showbars[i] = m->showbar;
 		}
 	}
+    /* init nmaster */
+	for(m = mons; m; m = m->next) {
+		for(i=0; i < LENGTH(tags) + 1; i++) {
+			m->nmasters[i] = nmaster;
+		}
+	}
 	updatebars();
 	updatestatus();
 	/* EWMH support per view */
 	return XTextWidth(dc.font.xfont, text, len);
 }
 
+#ifndef NMASTER
 void
 tile(Monitor *m) {
 	int x, y, h, w, mw;
 			y = c->y + HEIGHT(c);
 	}
 }
+#endif
 
 void
 togglebar(const Arg *arg) {
 		selmon->curtag^= selmon->prevtag;
 		selmon->prevtag= selmon->curtag ^ selmon->prevtag;
 	}
-	selmon->lt[selmon->sellt]= selmon->lts[selmon->curtag];
+	selmon->lt[selmon->sellt] = selmon->lts[selmon->curtag];
 	selmon->mfact = selmon->mfacts[selmon->curtag];
 	if(selmon->showbar != selmon->showbars[selmon->curtag])
 		togglebar(NULL);
     focus(NULL);
     arrange(m);
 }
-static void
+void
 tagviewnextmon(const Arg *arg) {
     Monitor *m; 
     Client *c = selmon->sel;
     focus(c);
     arrange(m);
 }
-static Client *
+Client *
 prevtiled(Client *c) {
 	Client *p, *r;
 
 	return r;
 }
 
-static void
+void
 pushup(const Arg *arg) {
 	Client *sel = selmon->sel;
 	Client *c;
 	arrange(selmon);
 }
 
-static void
+void
 pushdown(const Arg *arg) {
 	Client *sel = selmon->sel;
 	Client *c;
 	focus(sel);
 	arrange(selmon);
 }
-static void
+void
 viewall(const Arg *arg) {
 	unsigned int i;
     Monitor *m; 
         }
     }
 }
+void
+incnmaster(const Arg *arg) {
+    int cur;
+	if(!arg || !selmon->lt[selmon->sellt]->arrange )
+		return;
+	cur = selmon->nmasters[selmon->curtag] + arg->i;
+	if(cur < 1)
+        return;
+    selmon->nmaster = selmon->nmasters[selmon->curtag] = cur;
+	arrange(selmon);
+}
+static void
+ntile(Monitor *m) {
+	int x, y, h, w, mw, nm;
+	unsigned int i, n;
+	Client *c;
 
+	/* override layout symbol */
+    //snprintf(selmon->ltsymbol, sizeof selmon->ltsymbol, "%d]=", nmasters[m->num]);
+	snprintf(m->ltsymbol, sizeof m->ltsymbol, "%d]=", m->nmasters[m->curtag]);
+	for(n = 0, c = nexttiled(m->clients); c; c = nexttiled(c->next), n++);
+	c = nexttiled(m->clients);
+    nm = m->nmasters[m->curtag]; 
+	if(nm > n)
+		nm = n;
+	/* master */
+	if(nm > 0) {
+		mw = m->mfact * m->ww;
+		h = m->wh / nm;
+		if(h < bh)
+			h = m->wh;
+		y = m->wy;
+		for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
+			resize(c, m->wx, y, (n == nm ? m->ww : mw) - 2 * c->bw,
+			       ((i + 1 == nm) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
+			if(h != m->wh)
+				y = c->y + HEIGHT(c);
+		}
+		n -= nm;
+	} else
+		mw = 0;
+	if(n == 0)
+		return;
+	/* tile stack */
+	x = m->wx + mw;
+	y = m->wy;
+	w = m->ww - mw;
+	h = m->wh / n;
+	if(h < bh)
+		h = m->wh;
+	for(i = 0; c; c = nexttiled(c->next), i++) {
+		resize(c, x, y, w - 2 * c->bw,
+		       ((i + 1 == n) ? m->wy + m->wh - y : h) - 2 * c->bw, False);
+		if(h != m->wh)
+			y = c->y + HEIGHT(c);
+	}
+}
+