Re: [dev] [dvtm] Fibonacci layout patch

2010-06-01 Thread crap
 I've been using dvtm at work a lot recently so I figured I'd port the
 Fibonacci spiral/dwindle layouts to dvtm.  This patch is for 0.5.2.  I find
 it's not as useful as the Fibonacci layouts in dwm but I figure why not
 release it anyway.
 
 -Niki Yoshiuchi

Do these layouts provide any benefits? I found them rather useless actually,
even in dwm... What do you use them for, and in what way do you use them if
you don't mind sharing your experience?



Re: [dev] [dvtm] Fibonacci layout patch

2010-06-01 Thread Mate Nagy
On Tue, Jun 01, 2010 at 01:27:07PM +0200, Mate Nagy wrote:
 Using the vim splits may be cheating, but it sure is convenient.
sorry for self-reply: I thought that maybe for maximum punishment, the
fibonacci layout could support nmaster. (Also note that this is a
2560x1600 setup, that's why so much division (and nmaster) makes sense.)

Mate



Re: [dev] [dvtm] Fibonacci layout patch

2010-06-01 Thread markus schnalke
[2010-06-01 13:34] Mate Nagy mn...@port70.net
 On Tue, Jun 01, 2010 at 01:27:07PM +0200, Mate Nagy wrote:
  Using the vim splits may be cheating, but it sure is convenient.
 sorry for self-reply: I thought that maybe for maximum punishment, the
 fibonacci layout could support nmaster. (Also note that this is a
 2560x1600 setup, that's why so much division (and nmaster) makes sense.)

Thanks for your self-reply, I just wanted to ask what screen
resolution you have.


meillo



Re: [dev] [dvtm] Fibonacci layout patch

2010-06-01 Thread Niki Yoshiuchi
The biggest benefit I've found has simply been that the second client
remains the same size regardless of how many clients you have open.  That
said, I am generally using dwm on a netbook so I rarely have more than 2 or
3 clients open on a single tag.

On Tue, Jun 1, 2010 at 7:18 AM, c...@wzff.de wrote:

  I've been using dvtm at work a lot recently so I figured I'd port the
  Fibonacci spiral/dwindle layouts to dvtm.  This patch is for 0.5.2.  I
 find
  it's not as useful as the Fibonacci layouts in dwm but I figure why not
  release it anyway.
 
  -Niki Yoshiuchi

 Do these layouts provide any benefits? I found them rather useless
 actually,
 even in dwm... What do you use them for, and in what way do you use them if
 you don't mind sharing your experience?




[dev] [dvtm] Fibonacci layout patch

2010-05-31 Thread Niki Yoshiuchi
I've been using dvtm at work a lot recently so I figured I'd port the
Fibonacci spiral/dwindle layouts to dvtm.  This patch is for 0.5.2.  I find
it's not as useful as the Fibonacci layouts in dwm but I figure why not
release it anyway.

-Niki Yoshiuchi
diff --git a/config.h b/config.h
index 0ef2458..563e8e5 100644
--- a/config.h
+++ b/config.h
@@ -44,12 +44,15 @@
 #include grid.c
 #include bstack.c
 #include fullscreen.c
+#include dwindle.c
 
 Layout layouts[] = {
 	{ []=, tile },
 	{ +++, grid },
 	{ TTT, bstack },
 	{ [ ], fullscreen },
+	{ [...@], spiral },
+	{ [\\], dwindle },
 };
 
 #define MOD CTRL('g')
@@ -66,12 +69,14 @@ Key keys[] = {
 	{ MOD, 'g',   { setlayout,  { +++ }   } },
 	{ MOD, 'b',   { setlayout,  { TTT }   } },
 	{ MOD, 'm',   { setlayout,  { [ ] }   } },
+	{ MOD, 's',   { setlayout,  { [...@] }   } },
+	{ MOD, 'd',   { setlayout,  { [\\] }  } },
 	{ MOD, ' ',   { setlayout,  { NULL }} },
 	{ MOD, 'h',   { setmwfact,  { -0.05 } } },
 	{ MOD, 'l',   { setmwfact,  { +0.05 } } },
 	{ MOD, '.',   { toggleminimize, { NULL }} },
 #ifdef CONFIG_STATUSBAR
-	{ MOD, 's',   { togglebar,  { NULL }} },
+	{ MOD, 'r',   { togglebar,  { NULL }} },
 #endif
 #ifdef CONFIG_MOUSE
 	{ MOD, 'M',   { mouse_toggle,   { NULL }} },
diff --git a/fibonacci.c b/fibonacci.c
new file mode 100644
index 000..a19941f
--- /dev/null
+++ b/fibonacci.c
@@ -0,0 +1,84 @@
+static void
+fibonacci(int s) {
+	unsigned int nx, ny, nw, nh, i, n, m, nm, mod;
+	Client *c;
+
+	for(n = 0, m = 0, c = clients; c; c = c-next,n++)
+		if(c-minimized)
+			m++;
+	/* number of non minimized windows */
+	nm = n - m;
+
+	/* initial position and dimensions */
+	nx = wax;
+	ny = way;
+	nw = waw;
+	nh = (wah - m); /* leave space for the minimized clients */
+
+	/* set the mod factor, 2 for dwindle, 4 for spiral */
+	mod = s ? 4 : 2;
+
+	for(i = 0, c = clients; c; c = c-next,i++) {
+		if(!c-minimized) {
+			/* dwindle: even case, spiral: case 0*/
+			if(i % mod == 0) {
+ny += (i == 0 ? 0 : nh) * (s ? -1 : 1);
+/* TODO: first client uses the width factor, the rest divide by two */
+/* don't adjust the width for the last non-minimized client */
+if(i  nm - 1)
+	nw  /= 2;
+			}
+			/* dwindle: odd case, spiral: case 1*/
+			else if(i % mod == 1) {
+nx += nw;
+mvvline(ny, nx, ACS_VLINE, nh);
+mvaddch(ny, nx, ACS_TTEE);
+++nx;
+--nw;
+/* don't adjust the height for the last non-minimized client */
+if(i  nm - 1)
+	nh /= 2;
+			}
+			/* spiral: case 2*/
+			else if(i % mod == 2  s) {
+ny += nh;
+/* don't adjust the width for the last non-minimized client */
+if(i  nm - 1) {
+	nw  /= 2;
+	nx += nw;
+	mvvline(ny, nx, ACS_VLINE, nh);
+	mvaddch(ny, nx, ACS_TTEE);
+	++nx;
+}
+			}
+			/* spiral: case 3*/
+			else if(s) {
+nx -= nw;
+--nw;
+/* don't adjust the height for the last non-minimized client */
+if(i  nm - 1) {
+	nh /= 2;
+	ny += nh;
+}
+			}
+		} else {
+			nh = 1;
+			nw = waw;
+			nx = wax;
+			ny = way + wah - (n - i);
+		}
+
+		resize(c,nx,ny,nw,nh);
+	}
+}
+
+static void
+spiral(void) {
+	fibonacci(1);
+}
+
+static void
+dwindle(void) {
+	fibonacci(0);
+}
+