diff options
author | okan | 2016-12-19 14:17:26 +0000 |
---|---|---|
committer | okan | 2016-12-19 14:17:26 +0000 |
commit | 5ac58b2ef78cec185ee3ca219a9dd171f02313c2 (patch) | |
tree | 8a26a9daf2481e45fb2678636ad2cfd56b4464f1 /client.c | |
parent | b8454619a8fb11bcba893d94f1d0b329987e2b89 (diff) | |
download | cwm-5ac58b2ef78cec185ee3ca219a9dd171f02313c2.tar.gz |
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.
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -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.232 2016/12/06 21:59:33 okan Exp $ + * $OpenBSD: client.c,v 1.233 2016/12/19 14:17:26 okan Exp $ */ #include <sys/types.h> @@ -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; |