Krolyxon
Commit c8fcc3d

Branches

Refs →

nsxivc8fcc3d

Wrap the pointer when the edge of the window is reached

Author
Rob Pilling
Date
2013-03-03 18:16 +0000
Committer
Rob Pilling · 2013-03-03 22:33 +0000
Parent
408b75a
Commit
c8fcc3d3543f650dd846a89edfcd33d1674485f6

+22 −3

1 file changed

  1. M commands.c +22 −3
M commands.c View
@@ -289,10 +289,29 @@ bool i_drag(arg_t a)
289289 case MotionNotify:
290290 x = e.xmotion.x;
291291 y = e.xmotion.y;
292− if (x >= 0 && x <= win.w && y >= 0 && y <= win.h) {
293− dx += x - ox;
294− dy += y - oy;
292+
293+#define WARP(x, y) \
294+ XWarpPointer(win.env.dpy, \
295+ None, win.xwin, \
296+ 0, 0, 0, 0, \
297+ x, y); \
298+ ox = x, oy = y; \
299+ break
300+
301+ /* wrap the mouse around */
302+ if(x < 0){
303+ WARP(win.w, y);
304+ }else if(x > win.w){
305+ WARP(0, y);
306+ }else if(y < 0){
307+ WARP(x, win.h);
308+ }else if(y > win.h){
309+ WARP(x, 0);
295310 }
311+
312+ dx += x - ox;
313+ dy += y - oy;
314+
296315 ox = x;
297316 oy = y;
298317 break;