From 391aae2dea1a48460d066ac8abd2da865f6ad2c3 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 13 May 2011 23:54:11 +0200 Subject: [PATCH] Client/Layout: Add without-resizehint geo in client struct for split resize use, improve split size of clients. --- src/client.c | 8 ++++---- src/layout.c | 15 +++++++++++---- src/structs.h | 12 +++++------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/client.c b/src/client.c index 8e91e36..1b04b02 100644 --- a/src/client.c +++ b/src/client.c @@ -885,7 +885,7 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar) c->ogeo.y = c->geo.y = my; c->ogeo.width = c->geo.width = wa->width; c->ogeo.height = c->geo.height = wa->height; - c->free_geo = c->pgeo = c->geo; + c->free_geo = c->pgeo = c->wrgeo = c->geo; c->tag = seltag[c->screen]; c->focusontag = -1; cfactor_clean(c); @@ -1021,7 +1021,6 @@ void client_moveresize(Client *c, XRectangle geo, Bool r) { int os, e; - XRectangle fg; if(!c) return; @@ -1046,7 +1045,8 @@ client_moveresize(Client *c, XRectangle geo, Bool r) c->flags &= ~MaxFlag; - fg = geo; + /* Set geo without resizehint applied */ + c->wrgeo = geo; /* Apply geometry hints */ if(r) @@ -1064,7 +1064,7 @@ client_moveresize(Client *c, XRectangle geo, Bool r) && c->tag != MAXTAG + 1) c->tag = seltag[c->screen]; - frame_moveresize(c, fg); + frame_moveresize(c, c->wrgeo); XMoveResizeWindow(dpy, c->win, BORDH, TBARH, c->geo.width, c->geo.height); diff --git a/src/layout.c b/src/layout.c index e1321c7..291b47f 100644 --- a/src/layout.c +++ b/src/layout.c @@ -885,21 +885,28 @@ layout_split_client(Client *c, Bool p) cfactor_clean(c); - geo = sgeo = c->geo; + /* Use geometry without resizehint applied on it */ + geo = sgeo = c->wrgeo; /* Vertical */ if(p) { geo.width /= 2; - sgeo.width = (sgeo.width / 2) - (BORDH * 2); sgeo.x = FRAMEW(geo.x + geo.width); - } + sgeo.width = (sgeo.width / 2) - (BORDH * 2); + + /* Remainder */ + sgeo.width += (c->wrgeo.x + c->wrgeo.width) - (sgeo.x + sgeo.width); + } /* Horizontal */ else { geo.height = (geo.height / 2) - TBARH; - sgeo.height = (sgeo.height / 2) - BORDH; sgeo.y = FRAMEH(geo.y + geo.height); + sgeo.height = (sgeo.height / 2) - BORDH; + + /* Remainder */ + sgeo.height += (c->wrgeo.y + c->wrgeo.height) - (sgeo.y + sgeo.height); } tags[c->screen][c->tag].layout.sgeo = sgeo; diff --git a/src/structs.h b/src/structs.h index 242faf0..5d03d83 100644 --- a/src/structs.h +++ b/src/structs.h @@ -189,13 +189,11 @@ struct Client /* Screen */ int screen; /* Window attribute */ - XRectangle geo, pgeo; - XRectangle tmp_geo; - XRectangle frame_geo; - /* Old window attribute */ - XRectangle ogeo; - /* Free window attribute */ - XRectangle free_geo; + XRectangle geo, pgeo; /* Window geo, tiling pure geo */ + XRectangle tmp_geo, wrgeo; /* Temporary geo, without resizehint geo */ + XRectangle frame_geo; /* Frame geo */ + XRectangle ogeo; /* Old window attribute */ + XRectangle free_geo; /* Free window attribute */ /* Tile size factors */ int tilefact[4]; /* For resizehint usage */