Krolyxon
Commit b98a485

Branches

Refs →

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.
Author
Peter Hofmann
Date
2013-09-07 17:06 +0200
Committer
Peter Hofmann · 2013-09-07 17:10 +0200
Parent
26a624a
Commit
b98a48576e380e6f3f953b3d01b25172449e14d7

+8 −8

1 file changed

  1. M commands.c +8 −8
M commands.c View
@@ -352,14 +352,14 @@ bool i_drag(arg_t a)
352352 y = e.xmotion.y;
353353
354354 /* 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);
363363 }
364364 dx += x - ox;
365365 dy += y - oy;