Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
163 changes: 163 additions & 0 deletions src/nmaster-ncol.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
enum {MaxMon = 8};
static int nmasters[MaxMon];
static int initnm = 0;

static void
initnmaster(void) {
int i;

if(initnm)
return;
for(i = 0; i < MaxMon; i++)
nmasters[i] = nmaster;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/nmaster-ncol.c:12:17: error: use of undeclared identifier 'nmaster'; did you mean
      'nmasters'?
                nmasters[i] = nmaster;
                              ^~~~~~~
                              nmasters

initnm = 1;
}

static void
incnmaster(const Arg *arg) {
if(!arg)
return;
nmasters[0] += arg->i;
if(nmasters[0] < 0)
nmasters[0] = 0;
arrange();
}

static void
setnmaster(const Arg *arg) {
if(!arg)
return;
nmasters[0] = arg->i > 0 ? arg->i : 0;
arrange();
}

static void
ntile() {
int x, y, h, w, mw, nm;
unsigned int i, n;
Client *c;

initnmaster();
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
c = nexttiled(clients);
nm = nmasters[0];
if(nm > n)
nm = n;
/* master */
if(nm > 0) {
mw = mfact * ww;
h = wh / nm;
if(h < bh)
h = wh;
y = wy;
for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
resize(c, wx, y, (n == nm ? ww : mw) - 2 * c->bw,
((i + 1 == nm) ? wy + wh - y : h) - 2 * c->bw);
if(h != wh)
y = c->y + HEIGHT(c);
}
n -= nm;
} else
mw = 0;
if(n == 0)
return;
/* tile stack */
x = wx + mw;
y = wy;
w = ww - mw;
h = wh / n;
if(h < bh)
h = wh;
for(i = 0; c; c = nexttiled(c->next), i++) {
resize(c, x, y, w - 2 * c->bw,
((i + 1 == n) ? wy + wh - y : h) - 2 * c->bw);
if(h != wh)
y = c->y + HEIGHT(c);
}
}

static void
ncol() {
int x, y, h, w, mw, nm;
unsigned int i, n;
Client *c;

initnmaster();
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
c = nexttiled(clients);
nm = nmasters[0];
if(nm > n)
nm = n;
/* master */
if(nm > 0) {
mw = (n == nm) ? ww : mfact * ww;
w = mw / nm;
x = wx;
for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
resize(c, x, wy, w - 2 * c->bw, wh - 2 * c->bw);
x = c->x + WIDTH(c);
}
n -= nm;
} else
mw = 0;
if(n == 0)
return;
/* tile stack */
x = wx + mw;
y = wy;
w = ww - mw;
h = wh / n;
if(h < bh)
h = wh;
for(i = 0; c; c = nexttiled(c->next), i++) {
resize(c, x, y, w - 2 * c->bw,
((i + 1 == n) ? wy + wh - y : h) - 2 * c->bw);
if(h != wh)
y = c->y + HEIGHT(c);
}
}

static void
nbstack() {
int x, y, h, w, mh, nm;
unsigned int i, n;
Client *c;

initnmaster();
for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next), n++);
c = nexttiled(clients);
nm = nmasters[0];
if(nm > n)
nm = n;
/* master */
if(nm > 0) {
mh = mfact * wh;
w = ww / nm;
if(w < bh)
w = ww;
x = wx;
for(i = 0; i < nm; i++, c = nexttiled(c->next)) {
resize(c, x, wy, ((i + 1 == nm) ? wx + ww - x : w) - 2 * c->bw,
(n == nm ? wh : mh) - 2 * c->bw);
if(w != ww)
x = c->x + WIDTH(c);
}
n -= nm;
} else
mh = 0;
if(n == 0)
return;
/* tile stack */
x = wx;
y = wy + mh;
w = ww / n;
h = wh - mh;
if(w < bh)
w = ww;
for(i = 0; c; c = nexttiled(c->next), i++) {
resize(c, x, y, ((i + 1 == n) ? wx + ww - x : w) - 2 * c->bw,
h - 2 * c->bw);
if(w != ww)
x = c->x + WIDTH(c);
}
}