summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBert Münnich <ber.t@gmx.com>2013-03-04 19:18:58 +0100
committerBert Münnich <ber.t@gmx.com>2013-03-04 19:18:58 +0100
commitce8460108aafc98aa932832e7353271f4dab8c0c (patch)
treee06656b17d5e41a33ea97479ff4f58e8291b1db8
parent408b75a0b4fd16b833c01f6030d799c0148eacf4 (diff)
parentc8fcc3d3543f650dd846a89edfcd33d1674485f6 (diff)
downloadnsxiv-ce8460108aafc98aa932832e7353271f4dab8c0c.tar.zst
Merge pointer warping in i_drag from Rob Pilling
-rw-r--r--commands.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/commands.c b/commands.c
index 7274475..7ec7b88 100644
--- a/commands.c
+++ b/commands.c
@@ -289,10 +289,29 @@ bool i_drag(arg_t a)
case MotionNotify:
x = e.xmotion.x;
y = e.xmotion.y;
- if (x >= 0 && x <= win.w && y >= 0 && y <= win.h) {
- dx += x - ox;
- dy += y - oy;
+
+#define WARP(x, y) \
+ XWarpPointer(win.env.dpy, \
+ None, win.xwin, \
+ 0, 0, 0, 0, \
+ x, y); \
+ ox = x, oy = y; \
+ break
+
+ /* 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);
}
+
+ dx += x - ox;
+ dy += y - oy;
+
ox = x;
oy = y;
break;