nsxivb98a485
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.
+8 −8
1 file changed
- M commands.c +8 −8
| @@ -352,14 +352,14 @@ bool i_drag(arg_t a) | |||
| 352 | 352 | y = e.xmotion.y; | |
| 353 | 353 | ||
| 354 | 354 | /* wrap the mouse around */ | |
| 355 | − | if (x < 0) { | |
| 356 | − | WARP(win.w, y); | |
| 357 | − | } else if (x > win.w) { | |
| 358 | − | WARP(0, y); | |
| 359 | − | } else if (y < 0) { | |
| 360 | − | WARP(x, win.h); | |
| 361 | − | } else if (y > win.h) { | |
| 362 | − | WARP(x, 0); | |
| 355 | + | if (x <= 0) { | |
| 356 | + | WARP(win.w - 2, y); | |
| 357 | + | } else if (x >= win.w - 1) { | |
| 358 | + | WARP(1, y); | |
| 359 | + | } else if (y <= 0) { | |
| 360 | + | WARP(x, win.h - 2); | |
| 361 | + | } else if (y >= win.h - 1) { | |
| 362 | + | WARP(x, 1); | |
| 363 | 363 | } | |
| 364 | 364 | dx += x - ox; | |
| 365 | 365 | dy += y - oy; | |