Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[enhancement] `mouse_warping window` option: warp mouse on every focus change #2971
Would you consider a pull request to implement the
On a largish monitor (say, 27"), if you have a lot of windows open, your keyboard focus can end up quite a distance from where the mouse is, which can be annoying when you then need to use the mouse on the focused window. This would implement mouse-follows-focus, basically, to complement the existing focus-follows-mouse.
Ah, thank you for the link to the other issue. I'd searched for mouse warping issues to see whether it had been previously discussed, but since I'd filtered it down to enhancements-only I didn't catch it.
By "edge-cases" are you referring to the relatively large number of files/functions that are touched by the patch tohojo provided? Or do you find the user-visible behaviour inherently edge-casey/complex?
As an alternative, would you accept a patch adding a command to warp the mouse to the currently-focused window? This should be substantially simpler, and could be used to implement the behaviour I'm after in config, something like:
That would provide the mechanism, and leave the policy to the user.
I was referring to edge cases in the X11 protocol regarding focus changes, not necessarily our code base itself.
Indeed, I think the best course of action here would be to use xdotool. If it turns out that external tools fundamentally cannot do warping sensibly for whichever reason, but i3 could, then we can revisit adding this feature to i3 itself.
In case it helps someone, I wrote this small script:
#!/bin/bash XDT=/usr/bin/xdotool WINDOW=`$XDT getwindowfocus` # this brings in variables WIDTH and HEIGHT eval `xdotool getwindowgeometry --shell $WINDOW` TX=`expr $WIDTH / 2` TY=`expr $HEIGHT / 2` $XDT mousemove -window $WINDOW $TX $TY
The script moves the mouse to the center of the focused window, I execute it as a chained statement for key bindings that move window focus.