diff options
author | okan | 2017-05-01 12:54:55 +0000 |
---|---|---|
committer | okan | 2017-05-01 12:54:55 +0000 |
commit | a43d7fb97d3e0d9463b75b78595ccf0eececa007 (patch) | |
tree | a85fadbd64dca5a71d6ac76f8960889714feccc4 /client.c | |
parent | 330b5911cc616eb9653cf2add7574885d4b91304 (diff) | |
download | cwm-a43d7fb97d3e0d9463b75b78595ccf0eececa007.tar.gz |
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 '')
-rw-r--r-- | client.c | 20 |
1 files changed, 19 insertions, 1 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.238 2017/04/26 21:10:54 okan Exp $ + * $OpenBSD: client.c,v 1.239 2017/05/01 12:54:55 okan Exp $ */ #include <sys/types.h> @@ -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); |