# [dwm] spiral2 (problems)

From: pancake <pancake_AT_youterm.com>
Date: Thu, 26 Jul 2007 00:48:04 +0200

I've dupped the "spiral" function renamed to "spiral2". The aim
is to adapt the spiral algorithm to support masterw and nmaster.

Now I'm tired and have no time to work more for today..i'm locked.

The problems I'm having are:
- both column widths are always equal
- second column only exists when nmaster%2 == 0

Can anybody take a look on this source and lightme about how to
fix this?

Don't blame me for the source. it's almost for sketch O:)

Thanks!!

------------dwm.h------------------------
void spiral2(void); /* arranges all windows in a spiral with nmaster and masterw support */

-----------layout.c--------------------
void
spiral2(void) {
unsigned int i, n, nx, ny, nw, nh, mw, mh, tw, th;
int xx = ((nmaster%4)-1);
Client *c;

for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
n++;

nx = 0;
ny = way+(i*(wah/nmaster));
nh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
nw = (n > nmaster) ? (waw * masterw) / 1000 : waw;

for(i = 0, c = clients; c; c = c->next)
if(isvisible(c)) {
unban(c);
if(c->isfloating)
continue;
c->ismax = False;

if (i<nmaster) {
ny = way+(i*(wah/nmaster));
nh = (n > nmaster) ? wah / nmaster : wah / (n > 0 ? n : 1);
} else {
if (i==nmaster) {
nx = 0;
ny = way;
nh = wah;
}
if (i<n-1) {
if((i+xx) % 2 == 0)
nw/=2;
else
nh /= 2;
if((i+xx) % 4 == 2)
nx += nw;
else if((i+xx) % 4 == 3)
ny += nh;
}
if((i+xx) % 4 == 0)
ny -= nh;
else if((i+xx) % 4 == 1)
nx += nw;
else if((i+xx) % 4 == 2)
ny += nh;
else
nx -= nw;
}
resize(c, nx, ny, nw - (2 * c->border), nh - 2 * c ->border, False);
i++;
}
else
ban(c);
focus(NULL);
restack();
}

--pancake
Received on Thu Jul 26 2007 - 00:48:13 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 14:47:00 UTC