Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enhancement] `mouse_warping window` option: warp mouse on every focus change #2971

Closed
Qu4Z opened this issue Sep 19, 2017 · 6 comments

Comments

@Qu4Z
Copy link

commented Sep 19, 2017

The mouse_warping config option currently supports two values: none and output.

Would you consider a pull request to implement the window value for this option, which would warp the mouse for every non-pointer-initiated focus change? For example, when you use focus left by hitting Mod+j the focus would change as normal and the mouse would be centered on the newly focused window. If it can be implemented cleanly without adding unduly to the maintenance load, of course, but the option and x_set_warp_to already exist, so I don't think it would be too difficult (famous last words).

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.

@i3bot i3bot added the enhancement label Sep 19, 2017
@Airblader Airblader added the 4.14 label Sep 20, 2017
@Airblader

This comment has been minimized.

Copy link
Member

commented Sep 20, 2017

It sounds good to me. @stapelberg Thoughts?

@stapelberg

This comment has been minimized.

Copy link
Member

commented Sep 21, 2017

I don’t quite see how this request differes from the recently-rejected #2813? The latter says “always” instead of “window”, but (why?) does that reduce edge-cases?

@Qu4Z

This comment has been minimized.

Copy link
Author

commented Sep 21, 2017

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:

bindsym $mod-j focus left; warp mouse

That would provide the mechanism, and leave the policy to the user.

@Airblader

This comment has been minimized.

Copy link
Member

commented Sep 22, 2017

warp the mouse to the currently-focused window

This you could achieve entirely without i3 by using tools like xdotool.

@stapelberg

This comment has been minimized.

Copy link
Member

commented Sep 23, 2017

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?

I was referring to edge cases in the X11 protocol regarding focus changes, not necessarily our code base itself.

warp the mouse to the currently-focused window

This you could achieve entirely without i3 by using tools like xdotool.

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.

@stapelberg stapelberg closed this Sep 23, 2017
@oliversturm

This comment has been minimized.

Copy link

commented Feb 13, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.