diff options
author | okan <okan> | 2017-05-01 12:54:55 +0000 |
---|---|---|
committer | okan <okan> | 2017-05-01 12:54:55 +0000 |
commit | 3d6ff6dabfba7bb863970a7780c3e6ba19f06612 (patch) | |
tree | e415231568ace9565ed7fd33618db1b6ea27b6ca /client.c | |
parent | 4d85e2e2a606f822f84fff544ec375270c44be34 (diff) | |
download | cwm-3d6ff6dabfba7bb863970a7780c3e6ba19f06612.tar.gz cwm-3d6ff6dabfba7bb863970a7780c3e6ba19f06612.tar.xz cwm-3d6ff6dabfba7bb863970a7780c3e6ba19f06612.zip |
Clean up, unify and accurately calculate edge distance with client move/resize
actions, so as to not lose windows off the edge. inspired by diffs (and feedback) from Vadim Vygonets.
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/client.c b/client.c index e013d30..72f0183 100644 --- a/client.c +++ b/client.c @@ -471,6 +471,24 @@ client_config(struct client_ctx *cc) } void +client_ptr_inbound(struct client_ctx *cc, int getpos) +{ + if (getpos) + xu_ptr_getpos(cc->win, &cc->ptr.x, &cc->ptr.y); + + if (cc->ptr.x < 0) + cc->ptr.x = 0; + else if (cc->ptr.x > cc->geom.w - 1) + cc->ptr.x = cc->geom.w - 1; + if (cc->ptr.y < 0) + cc->ptr.y = 0; + else if (cc->ptr.y > cc->geom.h - 1) + cc->ptr.y = cc->geom.h - 1; + + client_ptrwarp(cc); +} + +void client_ptrwarp(struct client_ctx *cc) { xu_ptr_setpos(cc->win, cc->ptr.x, cc->ptr.y); |