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

Add new "mouse_warping" setting: remembered. #5083

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Commits on Aug 12, 2022

  1. Add new "mouse_warping" setting: remembered. (Addresses i3#4981.)

    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.
    pete- committed Aug 12, 2022
    Configuration menu
    Copy the full SHA
    f1916f7 View commit details
    Browse the repository at this point in the history