From 613d11434a7e950c62b68829e583fabb84c73238 Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 19 Dec 2016 14:17:26 +0000 Subject: [PATCH 1/2] When a window has a user or program specified position, ensure the edge of the final position is at least viewable and warp'able by the difference of bwidth; prevents mapping windows completely off the virtual screen. --- client.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/client.c b/client.c index 7999ac2..6cb222a 100644 --- a/client.c +++ b/client.c @@ -736,17 +736,19 @@ client_placecalc(struct client_ctx *cc) int xslack, yslack; if (cc->hint.flags & (USPosition | PPosition)) { - /* - * Ignore XINERAMA screens, just make sure it's somewhere - * in the virtual desktop. else it stops people putting xterms - * at startup in the screen the mouse doesn't start in *sigh*. - * XRandR bits mean that {x,y}max shouldn't be outside what's - * currently there. - */ - xslack = sc->view.w - cc->geom.w - cc->bwidth * 2; - yslack = sc->view.h - cc->geom.h - cc->bwidth * 2; - cc->geom.x = MIN(cc->geom.x, xslack); - cc->geom.y = MIN(cc->geom.y, yslack); + int wmax, hmax; + + wmax = DisplayWidth(X_Dpy, sc->which); + hmax = DisplayHeight(X_Dpy, sc->which); + + if (cc->geom.x + ((int)cc->bwidth * 2) >= wmax) + cc->geom.x = wmax - (cc->bwidth * 2); + if (cc->geom.x + cc->geom.w - ((int)cc->bwidth * 2) < 0) + cc->geom.x = -cc->geom.w; + if (cc->geom.y + ((int)cc->bwidth * 2) >= hmax) + cc->geom.y = hmax - (cc->bwidth * 2); + if (cc->geom.y + cc->geom.h - ((int)cc->bwidth * 2) < 0) + cc->geom.y = -cc->geom.h; } else { struct geom area; int xmouse, ymouse; From 96918a06e68bc9940a9205b2c312707f09c415bf Mon Sep 17 00:00:00 2001 From: okan Date: Thu, 5 Jan 2017 21:18:20 +0000 Subject: [PATCH 2/2] Ensure client stays inbound on key-based resize; based on logic existing in key-based client move; from Vadim Vygonets. --- kbfunc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kbfunc.c b/kbfunc.c index 134a8e7..befaf64 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -156,6 +156,10 @@ kbfunc_client_resize(void *ctx, union arg *arg, enum xev xev) cc->geom.w = cc->hint.minw; if ((cc->geom.h += my * cc->hint.inch) < cc->hint.minh) cc->geom.h = cc->hint.minh; + if (cc->geom.x + cc->geom.w < 0) + cc->geom.x = -cc->geom.w; + if (cc->geom.y + cc->geom.h < 0) + cc->geom.y = -cc->geom.h; client_resize(cc, 1); /* Make sure the pointer stays within the window. */