aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorokan2019-02-23 19:17:17 +0000
committerokan2019-02-23 19:17:17 +0000
commitcd6bd49abd762f448b4b352b69e2cc9f9ca5dfef (patch)
treef9fa596271edd603cba7487a8af66736f8f56a95
parent3b330d5a2142c41654cee607c6e630bbc6781974 (diff)
downloadcwm-cd6bd49abd762f448b4b352b69e2cc9f9ca5dfef.tar.gz
simplify screen 'area' usage for initial client placement
-rw-r--r--client.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/client.c b/client.c
index 3432d26..fc02996 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $OpenBSD: client.c,v 1.250 2019/02/22 20:52:13 okan Exp $
+ * $OpenBSD: client.c,v 1.251 2019/02/23 19:17:17 okan Exp $
*/
#include <sys/types.h>
@@ -754,7 +754,6 @@ static void
client_placecalc(struct client_ctx *cc)
{
struct screen_ctx *sc = cc->sc;
- int xslack, yslack;
if (cc->hint.flags & (USPosition | PPosition)) {
if (cc->geom.x >= sc->view.w)
@@ -772,33 +771,29 @@ client_placecalc(struct client_ctx *cc)
cc->geom.y += cc->obwidth * 2;
}
} else {
- struct geom area;
- int xmouse, ymouse;
+ struct geom area;
+ int xmouse, ymouse, xslack, yslack;
xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
area = screen_area(sc, xmouse, ymouse, CWM_GAP);
- area.w += area.x;
- area.h += area.y;
- xmouse = MAX(xmouse, area.x) - cc->geom.w / 2;
- ymouse = MAX(ymouse, area.y) - cc->geom.h / 2;
- xmouse = MAX(xmouse, area.x);
- ymouse = MAX(ymouse, area.y);
+ xmouse = MAX(MAX(xmouse, area.x) - cc->geom.w / 2, area.x);
+ ymouse = MAX(MAX(ymouse, area.y) - cc->geom.h / 2, area.y);
- xslack = area.w - cc->geom.w - cc->bwidth * 2;
- yslack = area.h - cc->geom.h - cc->bwidth * 2;
+ xslack = area.x + area.w - cc->geom.w - cc->bwidth * 2;
+ yslack = area.y + area.h - cc->geom.h - cc->bwidth * 2;
if (xslack >= area.x) {
cc->geom.x = MAX(MIN(xmouse, xslack), area.x);
} else {
cc->geom.x = area.x;
- cc->geom.w = area.w;
+ cc->geom.w = area.x + area.w;
}
if (yslack >= area.y) {
cc->geom.y = MAX(MIN(ymouse, yslack), area.y);
} else {
cc->geom.y = area.y;
- cc->geom.h = area.h;
+ cc->geom.h = area.y + area.h;
}
}
}