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

awful.screen.focus moves mouse to incorrect position after chaning re-enabling monitors with xrandr #3516

Open
MaciekChudek opened this issue Nov 24, 2021 · 1 comment

Comments

@MaciekChudek
Copy link

MaciekChudek commented Nov 24, 2021

Output of awesome --version:

awesome v4.3 (Too long)
 • Compiled against Lua 5.3.6 (running with Lua 5.3)
 • D-Bus support: ✔
 • execinfo support: ✔
 • xcb-randr version: 1.6
 • LGI version: 0.9.2

Output of xrandr -v:

xrandr program version       1.5.1
Server reports RandR version 1.6

How to reproduce the issue:

  • connect and enable multiple monitors
  • define shortcut to focus screens using awful.screen.focus()
    awful.key({ modkey,}, "w", function () awful.screen.focus(1) end, {description="Focus left screen", group="Focus"}),
    awful.key({ modkey,}, "e", function () awful.screen.focus(2) end, {description="Focus middle screen", group="Focus"}),
    awful.key({ modkey,}, "r", function () awful.screen.focus(3) end, {description="Focus right screen", group="Focus"}),
  • ensure screen ordering with screen[i]:swap()
  • shortcuts correctly shift focus and mouse cursor to last position on screen
  • disable some screens with xrandr
xrandr --output $LEFT --off --output $MIDDLE --off
  • enable those screens with xrandr
xrandr --output $MIDDLE --left-of $RIGHT --output $LEFT --left-of $MIDDLE
  • shortcuts now position mouse in between monitors, though keyboard focus still correctly shifts to selected screen
    Actual result:

awful.screen.focus positions mouse between screens

Expected result:

awful.screen.focus continues to position mouse in last known position, even after adding/removing screens with xrandr

Suggested solution:

Reset last known mouse position on screens when added/removed. For example screen.mouse_per_screen = false, but this property is encapsulated and not accessible to users. Alternatively, provide a parameter that allows users to choose whether to restore mouse position on screen focus (screen.lua line 105: if not _screen.mouse_per_screen and not restore_mouse_position then)

@MaciekChudek
Copy link
Author

After more digging, it looks like the cause is the mouse moving to screen edge automatically when monitors are added/removed, and this position being remembered and restored by awful.screen.focus. This can be solved by giving users the option to not return the mouse to its former position, which currently is mandatory.

I created a pull request with this functionality: #3517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant