Split: Improve arrange_closed with _split_check_row

This commit is contained in:
Martin Duquesnoy 2011-05-21 17:14:52 +02:00
parent 468ecfdcb8
commit a44505c1a9
4 changed files with 45 additions and 13 deletions

View File

@ -199,7 +199,7 @@ cfactor_arrange_two(Client *c1, Client *c2, Position p, int fac)
Bool
cfactor_check_2pc(XRectangle g1, XRectangle g2, Position p)
{
if(p < Top)
if(LDIR(p))
return (g1.height == g2.height);
else
return (g1.width == g2.width);

View File

@ -151,10 +151,10 @@ client_get_next_with_direction(Client *bc, Position pos)
return NULL;
/* Start place of pointer for faster scanning */
x = bc->geo.x + ((pos == Right) ? bc->geo.width : 0);
y = bc->geo.y + ((pos == Bottom) ? bc->geo.height : 0);
y += ((pos < Top) ? bc->geo.height / 2 : 0);
x += ((pos > Left) ? bc->geo.width / 2 : 0);
x = bc->frame_geo.x + ((pos == Right) ? bc->frame_geo.width : 0);
y = bc->frame_geo.y + ((pos == Bottom) ? bc->frame_geo.height : 0);
y += ((pos < Top) ? bc->frame_geo.height / 2 : 0);
x += ((pos > Left) ? bc->frame_geo.width / 2 : 0);
/* Scan in right direction to next(p) physical client */
for(; (c = client_gb_pos(bc, x, y)) == bc; x += scanfac[pos][0], y += scanfac[pos][1]);

View File

@ -37,7 +37,7 @@
static void
_split_arrange_size(XRectangle g, XRectangle *cg, Position p)
{
if(p < Top)
if(LDIR(p))
cg->width += FRAMEW(g.width);
else
cg->height += FRAMEH(g.height);
@ -56,12 +56,43 @@ _split_arrange_size(XRectangle g, XRectangle *cg, Position p)
static Bool
_split_check_row(XRectangle g1, XRectangle g2, Position p)
{
if(p < Top)
if(LDIR(p))
return (g1.y >= g2.y && (g1.y + g1.height) <= (g2.y + g2.height));
else
return (g1.x >= g2.x && (g1.x + g1.width) <= (g2.x + g2.width));
}
/** Check if row direction is available to resize from it
*\param c Client pointer
*\param g Client pointer
*\param p Position
*\return True if available
*/
static Bool
_split_check_row_dir(Client *c, Client *g, Position p)
{
int s, cs;
XRectangle cgeo;
Client *cc;
cs = (LDIR(p) ? g->frame_geo.height : g->frame_geo.width);
for(s = 0, cgeo = c->frame_geo, cc = tiled_client(c->screen, clients);
cc; cc = tiled_client(c->screen, cc->next))
if(cfactor_parentrow(cgeo, cc->frame_geo, RPOS(p))
&& _split_check_row(cc->frame_geo, g->frame_geo, p))
{
s += (LDIR(p) ? cc->frame_geo.height : cc->frame_geo.width);
if(s == cs)
return True;
if(s > cs)
return False;
}
return False;
}
/** Arrange clients after a client close
*\param ghost Ghost client
*/
@ -77,7 +108,7 @@ split_arrange_closed(Client *ghost)
if(tags[screen][seltag[screen]].layout.func != split)
return;
/* Use ghost client to fix holes in tile
/* Use ghost client properties to fix holes in tile
* .--. ~ ~
* /xx \ ~ ~
* ~~\O _ (____ ~
@ -116,19 +147,19 @@ split_arrange_closed(Client *ghost)
* |_____|_____| -> -> |___________|
*/
for(p = Right; p < Bottom + 1 && !b; ++p)
if((c = client_get_next_with_direction(ghost, p)))
if((c = client_get_next_with_direction(ghost, p)) && _split_check_row_dir(c, ghost, p))
{
for(cgeo = c->frame_geo, cc = tiled_client(c->screen, clients);
cc; cc = tiled_client(c->screen, cc->next))
{
if(cfactor_parentrow(cgeo, cc->frame_geo, RPOS(p))
&& _split_check_row(cc->frame_geo, ghost->frame_geo, p))
if(cfactor_parentrow(cgeo, cc->frame_geo, RPOS(p)) &&
_split_check_row(cc->frame_geo, ghost->frame_geo, p))
{
_split_arrange_size(ghost->wrgeo, &cc->wrgeo, p);
cfactor_clean(cc);
client_moveresize(cc, (cc->pgeo = cc->wrgeo), tags[screen][cc->tag].resizehint);
b = True;
}
}
}
return;
}

View File

@ -110,6 +110,7 @@
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
#define MAXCLIST (64)
#define RPOS(x) (x % 2 ? x - 1 : x + 1)
#define LDIR(x) (x < Top)
/* barwin.c */
BarWindow *barwin_create(Window parent,