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
Add new "mouse_warping" setting: remembered. #5083
base: next
Are you sure you want to change the base?
Conversation
When the "mouse_warping" configuration is set to "remembered" and the user switches focus to a different output, the mouse will be warped to the location it had when last on that particular output. This entails defining a new setting for the "mouse_warping" configuration parameter; adding "remembered_x" and "remembered_y" fields to struct xoutput; initializing those fields for the fake_output, xinerama, and xrandr cases; and honoring the remembered values when the warping the mouse while the config directive is active. Most of those additions are straightforward; the most involved is the latter, which comprises the changes in src/x.c. The code that initializes the remembered_x and remembered_y fields lives in three files (src/fake_outputs.c, src/xinerama.c, and two places in src/xrandr.c). I'm pretty sure I've covered all the functions where they need to be initialized, but I'm not sure I've put it in the best place *within* those functions. I also noticed two potentially-uninuitive behaviors while this config setting is active: - When rapidly changing outputs (eg, by pounding "workspace_back_and_forth"), eventually the remembered x and y values are forgotten. My guess is this due to how Xorg/xcb process events and may be out of the purview of i3, but I don't know enough to say for sure. - Consider the case where I have two workspaces, 1 and 2, on different outputs; workspace 1 has two windows, A and B; the mouse is sitting on Window A but focus is on Window B. Switch to workspace 2. Switch back to Workspace 1. The result is that the pointer is moved to its remembered location on Window A and Window B is focused, but then focus is immediately shifted to Window A. I'm not sure what the "correct" behavior ought to be in this case. I can see an argument that the behavior described above is actually desired or resaonable. I can also see how one would want Window B to remain focused, even though the pointer should lie within Window A after warping. The latter might require adding a "which container was focused" field to the data structure representing each workspace. I would greatly appreciate input/feedback on all aspects of this work.
Hi, this work is a great idea and something much needed for people who constantly switch back and forth. I can't remember how many times I've neede it. One quick suggestion , in your original comment, you should consider putting the conceptual part above the implementation part (window a window b stuff above remembered_x) , hopefully more people would be likely to comment. So i think window focus and mouse focus should both be remembered in your last example. That would be the ideal scenario IMHO. If window changes focus personally I'm not likely to use it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work overall 👍. Sorry for the late response.
I agree that focus should be preserved (mouse should be able to be above non-focused window). This is usually done with x_mask_event_mask(~XCB_EVENT_MASK_ENTER_WINDOW);
in other places.
Also, some debugging & understanding regarding the mouse position being lost after rapidly changing outputs would be appreciated.
When the "mouse_warping" configuration is set to "remembered" and the user
switches focus to a different output, the mouse will be warped to the location
it had when last on that particular output.
This entails defining a new setting for the "mouse_warping" configuration
parameter; adding "remembered_x" and "remembered_y" fields to struct xoutput;
initializing those fields for the fake_output, xinerama, and xrandr cases; and
honoring the remembered values when the warping the mouse while the config
directive is active.
Most of those additions are straightforward; the most involved is the latter,
which comprises the changes in src/x.c.
The code that initializes the remembered_x and remembered_y fields lives in
three files (src/fake_outputs.c, src/xinerama.c, and two places in
src/xrandr.c). I'm pretty sure I've covered all the functions where they need
to be initialized, but I'm not sure I've put it in the best place within
those functions.
I also noticed two potentially-uninuitive behaviors while this config setting
is active:
When rapidly changing outputs (eg, by pounding "workspace_back_and_forth"),
eventually the remembered x and y values are forgotten. My guess is this
due to how Xorg/xcb process events and may be out of the purview of i3, but
I don't know enough to say for sure.
Consider the case where I have two workspaces, 1 and 2, on different
outputs; workspace 1 has two windows, A and B; the mouse is sitting on
Window A but focus is on Window B. Switch to workspace 2. Switch back to
Workspace 1. The result is that the pointer is moved to its remembered
location on Window A and Window B is focused, but then focus is immediately
shifted to Window A.
I'm not sure what the "correct" behavior ought to be in this case. I can
see an argument that the behavior described above is actually desired or
resaonable. I can also see how one would want Window B to remain focused,
even though the pointer should lie within Window A after warping. The
latter might require adding a "which container was focused" field to the
data structure representing each workspace.
I would greatly appreciate input/feedback on all aspects of this work.
Closes #1146
Closes #4981