Krolyxon
Commit ce84601

Branches

Refs →

nsxivce84601

Merge pointer warping in i_drag from Rob Pilling

Author
Bert Münnich
Date
2013-03-04 19:18 +0100
Parents
408b75a c8fcc3d
Commit
ce8460108aafc98aa932832e7353271f4dab8c0c

+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;