summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorPeter Hofmann <scm@uninformativ.de>2013-09-07 17:06:47 +0200
committerPeter Hofmann <scm@uninformativ.de>2013-09-07 17:10:59 +0200
commitb98a48576e380e6f3f953b3d01b25172449e14d7 (patch)
tree3afd92270f0c8cef934ff8f842acffe5878fcb4c /commands.c
parent26a624a543f2e723550996d76d90ccbb7b954aeb (diff)
downloadnsxiv-b98a48576e380e6f3f953b3d01b25172449e14d7.tar.zst
Warp pointer on first/last pixel
Previously, the pointer would get warped when it had left the window. This doesn't work when sxiv is run in fullscreen mode (or similar -- see dwm's monocle mode): The pointer can never leave the window in such situations. To fix this, warp the pointer when it's on the first/last pixel. To avoid an endless warping loop, the new position must be at least one pixel away from the next warp position.
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/commands.c b/commands.c
index 09ba926..ff95f36 100644
--- a/commands.c
+++ b/commands.c
@@ -352,14 +352,14 @@ bool i_drag(arg_t a)
y = e.xmotion.y;
/* wrap the mouse around */
- if (x < 0) {
- WARP(win.w, y);
- } else if (x > win.w) {
- WARP(0, y);
- } else if (y < 0) {
- WARP(x, win.h);
- } else if (y > win.h) {
- WARP(x, 0);
+ if (x <= 0) {
+ WARP(win.w - 2, y);
+ } else if (x >= win.w - 1) {
+ WARP(1, y);
+ } else if (y <= 0) {
+ WARP(x, win.h - 2);
+ } else if (y >= win.h - 1) {
+ WARP(x, 1);
}
dx += x - ox;
dy += y - oy;