Client/Cfactor: Fix cfactor resizing in case of padding + 2 client resized and improve resizhint behaviour

This commit is contained in:
Martin Duquesnoy 2011-05-13 23:10:00 +02:00
parent 1b02cfed3e
commit f147bbbaf0
4 changed files with 61 additions and 28 deletions

View File

@ -32,7 +32,7 @@
#include "wmfs.h"
#define RPOS(x) (x % 2 ? p - 1 : p + 1)
#define RPOS(x) (x % 2 ? x - 1 : x + 1)
char scanfac[4][2] =
{
@ -64,10 +64,9 @@ cfactor_clean(Client *c)
XRectangle
cfactor_geo(XRectangle geo, int fact[4], int *err)
{
XRectangle cgeo = { 0, 0, 0, 0 };
XRectangle cgeo = geo;
*err = 0;
cgeo = geo;
/* Right factor */
cgeo.width += fact[Right];
@ -155,13 +154,37 @@ _cfactor_arrange_row(Client *c, Position p, int fac)
static void
cfactor_arrange_two(Client *c1, Client *c2, Position p, int fac)
{
c1->tilefact[p] += fac;
c2->tilefact[RPOS(p)] -= fac;
/* Needed in case of padding */
if(conf.client.padding)
{
c1->flags |= FLayFlag;
c2->flags |= FLayFlag;
}
client_moveresize(c1, c1->geo, tags[c1->screen][c1->tag].resizehint);
client_moveresize(c2, c2->geo, tags[c2->screen][c2->tag].resizehint);
return;
}
/* Check 2 clients parenting compatibility
*\param g1 client1 geo
*\param g2 client2 geo
*\param p Direction of resizing
*\returm 1/0
*/
static Bool
cfactor_check_2pc(XRectangle g1, XRectangle g2, Position p)
{
if(p < Top)
return (g1.height == g2.height);
else
return (g1.width == g2.width);
}
/** Get c parents of row and resize, exception checking same size before arranging row
@ -173,8 +196,8 @@ cfactor_arrange_two(Client *c1, Client *c2, Position p, int fac)
static void
cfactor_arrange_row(Client *c, Client *gc, Position p, int fac)
{
if(((p == Right || p == Left) && gc->geo.height == c->geo.height)
|| ((p == Top || p == Bottom) && gc->geo.width == c->geo.width))
if(cfactor_check_2pc(c->frame_geo, gc->frame_geo, p))
cfactor_arrange_two(c, gc, p, fac);
else
{

View File

@ -533,8 +533,8 @@ client_urgent(Client *c, Bool u)
for(cc = clients; cc; cc = cc->next)
if(!ishide(cc, selscreen) && (cc->flags & TileFlag) && cc != c)
if(cc->frame_geo.x <= x && cc->frame_geo.x + cc->frame_geo.width >= x
&& cc->frame_geo.y <= y && cc->frame_geo.y + cc->frame_geo.height >= y)
if(cc->frame_geo.x < x && cc->frame_geo.x + cc->frame_geo.width > x
&& cc->frame_geo.y < y && cc->frame_geo.y + cc->frame_geo.height > y)
return cc;
return c;
@ -1021,42 +1021,50 @@ void
client_moveresize(Client *c, XRectangle geo, Bool r)
{
int os, e;
XRectangle fg;
if(!c)
return;
os = c->screen;
/* Apply padding and cfactor */
if(c->flags & TileFlag)
{
geo = cfactor_geo(c->pgeo, c->tilefact, &e);
if(e)
printf("EE: &e\n");
if(r)
client_geo_hints(&geo, c);
if(conf.client.padding && (c->flags & FLayFlag))
{
geo.x += conf.client.padding;
geo.y += conf.client.padding;
geo.width -= conf.client.padding * 2;
geo.height -= conf.client.padding * 2;
c->flags &= ~FLayFlag;
}
}
c->flags &= ~MaxFlag;
if(conf.client.padding && c->flags & TileFlag && c->flags & FLayFlag)
{
geo.x += conf.client.padding;
geo.y += conf.client.padding;
geo.width -= conf.client.padding * 2;
geo.height -= conf.client.padding * 2;
fg = geo;
c->flags &= ~FLayFlag;
}
/* Apply geometry hints */
if(r)
client_geo_hints(&geo, c);
c->geo = geo;
if(c->flags & FreeFlag || !(c->flags & (TileFlag | LMaxFlag)) || conf.keep_layout_geo)
/* Sett free_geo */
if(c->flags & FreeFlag || !(c->flags & (TileFlag | LMaxFlag))
|| conf.keep_layout_geo)
c->free_geo = c->geo;
/* Check to set new screen if needed */
if((c->screen = screen_get_with_geo(c->geo.x, c->geo.y)) != os
&& c->tag != MAXTAG + 1)
c->tag = seltag[c->screen];
frame_moveresize(c, c->geo);
frame_moveresize(c, fg);
XMoveResizeWindow(dpy, c->win, BORDH, TBARH, c->geo.width, c->geo.height);

View File

@ -887,17 +887,19 @@ layout_split_client(Client *c, Bool p)
geo = sgeo = c->geo;
/* Vertical */
if(p)
{
geo.x += (geo.width / 2);
geo.width /= 2;
sgeo.width = (sgeo.width / 2) - (BORDH * 2);
sgeo.x = FRAMEW(geo.x + geo.width);
}
/* Horizontal */
else
{
geo.y += (geo.height / 2);
geo.height /= 2;
sgeo.height = (sgeo.height / 2) - (BORDH + TBARH);
geo.height = (geo.height / 2) - TBARH;
sgeo.height = (sgeo.height / 2) - BORDH;
sgeo.y = FRAMEH(geo.y + geo.height);
}
tags[c->screen][c->tag].layout.sgeo = sgeo;

6
wmfsrc
View File

@ -126,7 +126,7 @@
expose_name = "EXPOSE"
expose_layout = "tile_left"
# Border around the tag buttons.
border = true
@ -191,7 +191,7 @@
# same as above but for the screen
#default_open_screen = 1
# Space between tiled clients
# Space between tiled clients (px)
padding = 0
# Modifier for mouse use
@ -334,7 +334,7 @@
# Swap current client with the previous.
[key] mod = {"Alt", "Shift"} key = "t" func = "client_swap_prev" [/key]
# Set the selected client as Master
[key] mod = {"Control"} key = "m" func = "client_set_master" [/key]