change tile() to take a Position as argument

This commit is contained in:
Julien Danjou 2008-01-17 17:15:47 +01:00
parent 0940f2f81a
commit 541d0d631d
1 changed files with 37 additions and 23 deletions

View File

@ -104,11 +104,10 @@ uicb_tag_setmwfact(int screen, char *arg)
} }
static void static void
_tile(int screen, const Bool right, const Bool vertical) _tile(int screen, const Position position)
{ {
/* windows area geometry */ /* windows area geometry */
int wah = 0, waw = 0, wax = 0, way = 0; int wah = 0, waw = 0, wax = 0, way = 0;
/* new coordinates */
/* master size */ /* master size */
unsigned int mw = 0, mh = 0; unsigned int mw = 0, mh = 0;
int n, i, masterwin = 0, otherwin = 0; int n, i, masterwin = 0, otherwin = 0;
@ -138,17 +137,17 @@ _tile(int screen, const Bool right, const Bool vertical)
otherwin = 0; otherwin = 0;
if(curtags[0]->nmaster) if(curtags[0]->nmaster)
switch(position)
{ {
if(vertical) case Right:
{ case Left:
mh = masterwin ? wah / masterwin : wah; mh = masterwin ? wah / masterwin : wah;
mw = otherwin ? waw * curtags[0]->mwfact : waw; mw = otherwin ? waw * curtags[0]->mwfact : waw;
} break;
else default:
{
mh = otherwin ? wah * curtags[0]->mwfact : wah; mh = otherwin ? wah * curtags[0]->mwfact : wah;
mw = masterwin ? waw / masterwin : waw; mw = masterwin ? waw / masterwin : waw;
} break;
} }
else else
mh = mw = 0; mh = mw = 0;
@ -160,18 +159,28 @@ _tile(int screen, const Bool right, const Bool vertical)
if(!IS_TILED(c, screen)) if(!IS_TILED(c, screen))
continue; continue;
c->ismax = False;
if(i < curtags[0]->nmaster) if(i < curtags[0]->nmaster)
{ {
if(vertical) switch(position)
{ {
case Right:
geometry.y = way + i * mh; geometry.y = way + i * mh;
geometry.x = wax + (right ? 0 : waw - mw); geometry.x = wax;
} break;
else case Left:
{ geometry.y = way + i * mh;
geometry.y = way + (right ? 0 : wah - mh); geometry.x = wax + (waw - mw);
break;
case Top:
geometry.x = wax + i * mw; geometry.x = wax + i * mw;
geometry.y = way + (wah - mh);
break;
case Bottom:
default:
geometry.x = wax + i * mw;
geometry.y = way;
break;
break;
} }
geometry.width = mw - 2 * c->border; geometry.width = mw - 2 * c->border;
geometry.height = mh - 2 * c->border; geometry.height = mh - 2 * c->border;
@ -188,7 +197,7 @@ _tile(int screen, const Bool right, const Bool vertical)
if(current_col == real_ncol - 1) if(current_col == real_ncol - 1)
win_by_col += otherwin % real_ncol; win_by_col += otherwin % real_ncol;
if(vertical) if(position == Right || position == Left)
{ {
if(otherwin <= real_ncol) if(otherwin <= real_ncol)
geometry.height = wah - 2 * c->border; geometry.height = wah - 2 * c->border;
@ -202,7 +211,10 @@ _tile(int screen, const Bool right, const Bool vertical)
else else
geometry.y = way + ((i - curtags[0]->nmaster) % win_by_col) * (geometry.height + 2 * c->border); geometry.y = way + ((i - curtags[0]->nmaster) % win_by_col) * (geometry.height + 2 * c->border);
geometry.x = wax + current_col * (geometry.width + 2 * c->border) + (right ? mw : 0); geometry.x = wax + current_col * (geometry.width + 2 * c->border);
if(position == Right)
geometry.x += mw;
} }
else else
{ {
@ -218,9 +230,11 @@ _tile(int screen, const Bool right, const Bool vertical)
else else
geometry.x = wax + ((i - curtags[0]->nmaster) % win_by_col) * (geometry.width + 2 * c->border); geometry.x = wax + ((i - curtags[0]->nmaster) % win_by_col) * (geometry.width + 2 * c->border);
geometry.y = way + current_col * (geometry.height + 2 * c->border) + (right ? mh : 0); geometry.y = way + current_col * (geometry.height + 2 * c->border);
}
if(position == Bottom)
geometry.y += mh;
}
client_resize(c, geometry, globalconf.screens[screen].resize_hints); client_resize(c, geometry, globalconf.screens[screen].resize_hints);
} }
i++; i++;
@ -232,25 +246,25 @@ _tile(int screen, const Bool right, const Bool vertical)
void void
layout_tile(int screen) layout_tile(int screen)
{ {
_tile(screen, True, True); _tile(screen, Right);
} }
void void
layout_tileleft(int screen) layout_tileleft(int screen)
{ {
_tile(screen, False, True); _tile(screen, Left);
} }
void void
layout_tilebottom(int screen) layout_tilebottom(int screen)
{ {
_tile(screen, True, False); _tile(screen, Bottom);
} }
void void
layout_tiletop(int screen) layout_tiletop(int screen)
{ {
_tile(screen, False, False); _tile(screen, Top);
} }
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80