Skip to content

Commit

Permalink
Fix coding style within layout files
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Andre Tanner <[email protected]>
  • Loading branch information
martanne committed Nov 30, 2012
1 parent f7495bc commit cc8f1e8
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 96 deletions.
36 changes: 18 additions & 18 deletions bstack.c
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
static void
bstack(void) {
static void bstack(void)
{
unsigned int i, m, n, nx, ny, nw, nh, mh, tw;
Client *c;

for(n = 0, m = 0, c = clients; c; c = c->next, n++)
if(c->minimized)
for (n = 0, m = 0, c = clients; c; c = c->next, n++)
if (c->minimized)
m++;

if(n == 1)
if (n == 1)
mh = wah;
else if(n - 1 == m)
else if (n - 1 == m)
mh = wah - m;
else
mh = screen.mfact * (wah - m);
/* true if there are at least 2 non minimized clients */
if(n - 1 > m)
if (n - 1 > m)
tw = waw / (n - m - 1);

nx = wax;
ny = way;
for(i = 0, c = clients; c; c = c->next, i++){
if(i == 0){ /* master */
for (i = 0, c = clients; c; c = c->next, i++) {
if (i == 0) { /* master */
nh = mh;
nw = waw;
} else { /* tile window */
if(i == 1){
} else { /* tile window */
if (i == 1) {
nx = wax;
ny += mh;
nh = (way + wah - m) - ny;
}
if(i == n - m - 1){ /* last not minimized client */
if (i == n - m - 1) { /* last not minimized client */
nw = (wax + waw) - nx;
} else if(i == n - m){ /* first minimized client */
} else if (i == n - m) { /* first minimized client */
ny += nh;
nx = wax;
nw = waw;
nh = 1;
} else if(c->minimized) { /* minimized window */
} else if (c->minimized) { /* minimized window */
nw = waw;
nh = 1;
ny++;
} else /* normal non minimized tile window */
} else /* normal non minimized tile window */
nw = tw;
if(i > 1 && !c->minimized){
if (i > 1 && !c->minimized) {
mvvline(ny, nx, ACS_VLINE, nh);
mvaddch(ny, nx, ACS_TTEE);
nx++, nw--;
}
}

resize(c,nx,ny,nw,nh);
resize(c, nx, ny, nw, nh);

if(n > 1 && i < n - m - 1)
if (n > 1 && i < n - m - 1)
nx += nw;
}
}
48 changes: 24 additions & 24 deletions fibonacci.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
static void
fibonacci(int s) {
static void fibonacci(int s)
{
unsigned int nx, ny, nw, nnw, nh, nnh, i, n, m, nm, mod;
Client *c;

for(n = 0, m = 0, c = clients; c; c = c->next,n++)
if(c->minimized)
for (n = 0, m = 0, c = clients; c; c = c->next, n++)
if (c->minimized)
m++;
/* number of non minimized windows */
nm = n - m;
Expand All @@ -18,15 +18,15 @@ fibonacci(int s) {
* variables for the next new width/height
*/
nnw = waw - nw - 1;
nnh = nh = (wah - m); /* leave space for the minimized clients */
nnh = 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) {
for (i = 0, c = clients; c; c = c->next, i++) {
if (!c->minimized) {
/* dwindle: even case, spiral: case 0 */
if (i % mod == 0) {
if (i) {
if (s) {
nh = nnh;
Expand All @@ -36,29 +36,29 @@ fibonacci(int s) {
nh = nnh;
}
/* don't adjust the width for the last non-minimized client */
if(i < nm - 1) {
nw /= 2;
if (i < nm - 1) {
nw /= 2;
nnw -= nw + 1;
}
mvaddch(ny, nx - 1, ACS_LTEE);
}
} else if(i % mod == 1) { /* dwindle: odd case, spiral: case 1*/
} else if (i % mod == 1) { /* dwindle: odd case, spiral: case 1 */
nx += nw;
mvvline(ny, nx, ACS_VLINE, nh);
mvaddch(ny, nx, ACS_TTEE);
++nx;
nw = nnw;
/* don't adjust the height for the last non-minimized client */
if(i < nm - 1) {
if (i < nm - 1) {
nh /= 2;
nnh -= nh;
}
} else if(i % mod == 2 && s) { /* spiral: case 2*/
} else if (i % mod == 2 && s) { /* spiral: case 2 */
ny += nh;
nh = nnh;
/* don't adjust the width for the last non-minimized client */
if(i < nm - 1) {
nw /= 2;
if (i < nm - 1) {
nw /= 2;
nnw -= nw + 1;
nx += nnw;
mvvline(ny, nx, ACS_VLINE, nh);
Expand All @@ -67,11 +67,11 @@ fibonacci(int s) {
} else {
mvaddch(ny, nx - 1, ACS_LTEE);
}
} else if(s) { /* spiral: case 3*/
} else if (s) { /* spiral: case 3 */
nw = nnw;
nx -= nw + 1; /* border */
nx -= nw + 1; /* border */
/* don't adjust the height for the last non-minimized client */
if(i < nm - 1) {
if (i < nm - 1) {
nh /= 2;
nnh -= nh;
ny += nnh;
Expand All @@ -85,16 +85,16 @@ fibonacci(int s) {
ny = way + wah - (n - i);
}

resize(c,nx,ny,nw,nh);
resize(c, nx, ny, nw, nh);
}
}

static void
spiral(void) {
static void spiral(void)
{
fibonacci(1);
}

static void
dwindle(void) {
static void dwindle(void)
{
fibonacci(0);
}
7 changes: 3 additions & 4 deletions fullscreen.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
static void
fullscreen(void) {
Client *c;
for(c = clients; c; c = c->next)
static void fullscreen(void)
{
for (Client *c = clients; c; c = c->next)
resize(c, wax, way, waw, wah);
}
34 changes: 19 additions & 15 deletions grid.c
Original file line number Diff line number Diff line change
@@ -1,50 +1,54 @@
static void
grid(void) {
static void grid(void)
{
unsigned int i, m, nm, n, nx, ny, nw, nh, aw, ah, cols, rows;
Client *c;

for(n = 0, m = 0, c = clients; c; c = c->next,n++)
if(c->minimized)
for (n = 0, m = 0, c = clients; c; c = c->next, n++)
if (c->minimized)
m++;
/* number of non minimized windows */
nm = n - m;
/* grid dimensions */
for(cols = 0; cols <= nm/2; cols++)
if(cols*cols >= nm)
for (cols = 0; cols <= nm / 2; cols++)
if (cols * cols >= nm)
break;
rows = (cols && (cols - 1) * cols >= nm) ? cols - 1 : cols;
/* window geoms (cell height/width) */
nh = (wah - m) / (rows ? rows : 1);
nw = waw / (cols ? cols : 1);
for(i = 0, c = clients; c; c = c->next,i++) {
if(!c->minimized){
for (i = 0, c = clients; c; c = c->next, i++) {
if (!c->minimized) {
/* if there are less clients in the last row than normal adjust the
* split rate to fill the empty space */
if(rows > 1 && i == (rows * cols) - cols && (nm - i) <= (nm % cols))
if (rows > 1 && i == (rows * cols) - cols
&& (nm - i) <= (nm % cols))
nw = waw / (nm - i);
nx = (i % cols) * nw + wax;
ny = (i / cols) * nh + way;
/* adjust height/width of last row/column's windows */
ah = (i >= cols * (rows -1)) ? wah - m - nh * rows : 0;
ah = (i >= cols * (rows - 1)) ? wah - m - nh * rows : 0;
/* special case if there are less clients in the last row */
if(rows > 1 && i == nm - 1 && (nm - i) < (nm % cols))
if (rows > 1 && i == nm - 1 && (nm - i) < (nm % cols))
/* (n % cols) == number of clients in the last row */
aw = waw - nw * (nm % cols);
else
aw = ((i + 1) % cols == 0) ? waw - nw * cols : 0;
if(i % cols){
aw = ((i + 1) % cols ==
0) ? waw - nw * cols : 0;
if (i % cols) {
mvvline(ny, nx, ACS_VLINE, nh + ah);
/* if we are on the first row, or on the last one and there are fewer clients
* than normal whose border does not match the line above, print a top tree char
* otherwise a plus sign. */
if(i <= cols || (i >= rows * cols - cols && nm % cols && (cols - (nm % cols)) % 2))
if (i <= cols
|| (i >= rows * cols - cols && nm % cols
&& (cols - (nm % cols)) % 2))
mvaddch(ny, nx, ACS_TTEE);
else
mvaddch(ny, nx, ACS_PLUS);
nx++, aw--;
}
} else {
if(i == nm){ /* first minimized client */
if (i == nm) { /* first minimized client */
ny = way + wah - m;
nx = wax;
nw = waw;
Expand Down
30 changes: 15 additions & 15 deletions tile.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
static void
tile(void) {
static void tile(void)
{
unsigned int i, m, n, nx, ny, nw, nh, nm, mw, th;
Client *c;

for(n = 0, m = 0, c = clients; c; c = c->next, n++)
if(c->minimized)
for (n = 0, m = 0, c = clients; c; c = c->next, n++)
if (c->minimized)
m++;
nm = n - m;
/* window geoms */
mw = (n == 1 || n - 1 == m) ? waw : screen.mfact * waw;
/* check if there are at least 2 non minimized clients */
if(n - 1 > m)
if (n - 1 > m)
th = (wah - m) / (nm - 1);

nx = wax;
ny = way;
for(i = 0, c = clients; c; c = c->next, i++) {
if(i == 0) { /* master */
for (i = 0, c = clients; c; c = c->next, i++) {
if (i == 0) { /* master */
nw = mw;
nh = (n - 1 > m) ? wah : wah - m;
} else { /* tile window */
if(!c->minimized){
if(i == 1) {
} else { /* tile window */
if (!c->minimized) {
if (i == 1) {
ny = way;
nx += mw;
nw = waw - mw;
Expand All @@ -30,21 +30,21 @@ tile(void) {
nx++, nw--;
}
/* remainder */
if(m == 0 && i + 1 == n) /* no minimized clients */
if (m == 0 && i + 1 == n) /* no minimized clients */
nh = (way + wah) - ny;
else if(i == nm - 1) /* last not minimized client */
else if (i == nm - 1) /* last not minimized client */
nh = (way + wah - (n - i - 1)) - ny;
else
nh = th;
} else {
nh = 1;
ny = way + wah - (n - i);
}
if(i > 1 && nm > 1)
if (i > 1 && nm > 1)
mvaddch(ny, nx - 1, ACS_LTEE);
}
resize(c,nx,ny,nw,nh);
if(n > 1 && th != wah)
resize(c, nx, ny, nw, nh);
if (n > 1 && th != wah)
ny += nh;
}
}
Loading

0 comments on commit cc8f1e8

Please sign in to comment.