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

Mouse stuck when changing screen focus after startup #3527

Open
man9ourah opened this issue Dec 14, 2021 · 0 comments
Open

Mouse stuck when changing screen focus after startup #3527

man9ourah opened this issue Dec 14, 2021 · 0 comments
Milestone

Comments

@man9ourah
Copy link

Output of awesome --version:

awesome v4.3-1248-g78c8f552 (Too long)
 • Compiled against Lua 5.3.3 (running with Lua 5.3)
 • API level: 4
 • D-Bus support: yes
 • xcb-errors support: no
 • execinfo support: yes
 • xcb-randr version: 1.6
 • LGI version: 0.9.2
 • Transparency enabled: yes
 • Custom search paths: no

How to reproduce the issue:

  • Two monitor setup, default awesomewm configuration.
  • Right after startup, use awful.screen.focus_relative(1) to switch to second screen.
  • Call same function again to switch back but then the mouse will get stuck right in the middle of the two screens and wont move to either unless it is moved physically.

Actual result:

I applied the following patches on awesome code to see some debug information, and pinpoint where the problem is; it simply outputs the current mouse position, new mouse position, and the applied mouse position whenever we want to change the screen focus.

diff --git a/lib/awful/screen.lua b/lib/awful/screen.lua
index 8e6207ec..894928be 100644
--- a/lib/awful/screen.lua
+++ b/lib/awful/screen.lua
@@ -98,7 +98,10 @@ function screen.focus(_screen)
 
     -- screen and pos for current screen
     local s = get_screen(capi.mouse.screen)
-    local pos
+    local pos = capi.mouse.coords()
+
+    gdebug.print_warning("--------------------Screen focus--------------------")
+    gdebug.print_warning(string.format("Current pos:\tscreen=%d,x=%d,y=%d\n", s.index, pos.x, pos.y))
 
     if not _screen.mouse_per_screen then
         -- This is the first time we enter this screen,
@@ -114,11 +117,14 @@ function screen.focus(_screen)
         pos = _screen.mouse_per_screen
     end
 
+    gdebug.print_warning(string.format("New pos:\tscreen=%d,x=%d,y=%d\n", _screen.index, pos.x, pos.y))
+
     -- save pointer position of current screen
     s.mouse_per_screen = capi.mouse.coords()
 
-   -- move cursor without triggering signals mouse::enter and mouse::leave
-    capi.mouse.coords(pos, true)
+    -- move cursor without triggering signals mouse::enter and mouse::leave
+    pos = capi.mouse.coords(pos, true)
+    gdebug.print_warning(string.format("Applied pos:\tscreen=%d,x=%d,y=%d\n", _screen.index, pos.x, pos.y))
 
     local c = client.focus.history.get(_screen, 0)
     if c then
@@ -1019,4 +1025,4 @@ object.properties(capi.screen, {
 
 return screen

diff --git a/mouse.c b/mouse.c
index 42d0b382..a43bd097 100644
--- a/mouse.c
+++ b/mouse.c
@@ -138,6 +138,7 @@ mouse_query_pointer_root(int16_t *x, int16_t *y, xcb_window_t *child, uint16_t *
 static inline void
 mouse_warp_pointer(xcb_window_t window, int16_t x, int16_t y)
 {
+    warn("Setting mouse to mouseX:%d, mouseY:%d with DistWindow:%d\n", x, y, window);
     xcb_warp_pointer(globalconf.connection, XCB_NONE, window,
                      0, 0, 0, 0, x, y);
 }

The output of the above is the following:

2021-12-14 14:48:59 W: awesome: --------------------Screen focus--------------------
2021-12-14 14:48:59 W: awesome: Current pos:	screen=1,x=320,y=240
2021-12-14 14:48:59 W: awesome: New pos:	screen=2,x=2695,y=-160
2021-12-14 14:48:59 W: awesome: mouse_warp_pointer:141: Setting mouse to mouseX:2695, mouseY:-160 with DistWindow:614
2021-12-14 14:48:59 W: awesome: Applied pos:	screen=2,x=2695,y=0

2021-12-14 14:49:00 W: awesome: --------------------Screen focus--------------------
2021-12-14 14:49:00 W: awesome: Current pos:	screen=2,x=2695,y=0
2021-12-14 14:49:00 W: awesome: New pos:	screen=1,x=320,y=240
2021-12-14 14:49:00 W: awesome: mouse_warp_pointer:141: Setting mouse to mouseX:320, mouseY:240 with DistWindow:614
2021-12-14 14:49:00 W: awesome: Applied pos:	screen=1,x=2560,y=240

2021-12-14 14:49:01 W: awesome: --------------------Screen focus--------------------
2021-12-14 14:49:01 W: awesome: Current pos:	screen=2,x=2560,y=240
2021-12-14 14:49:01 W: awesome: New pos:	screen=1,x=320,y=240
2021-12-14 14:49:01 W: awesome: mouse_warp_pointer:141: Setting mouse to mouseX:320, mouseY:240 with DistWindow:614
2021-12-14 14:49:01 W: awesome: Applied pos:	screen=1,x=2560,y=240

2021-12-14 14:49:03 W: awesome: --------------------Screen focus--------------------
2021-12-14 14:49:03 W: awesome: Current pos:	screen=2,x=2560,y=240
2021-12-14 14:49:03 W: awesome: New pos:	screen=1,x=320,y=240
2021-12-14 14:49:03 W: awesome: mouse_warp_pointer:141: Setting mouse to mouseX:320, mouseY:240 with DistWindow:614
2021-12-14 14:49:03 W: awesome: Applied pos:	screen=1,x=2560,y=240

As you can see, after the first xcb_warp_pointer .. no matter what pos we provide it will always apply screen=1,x=2560,y=240.

Expected result:

While debugging the issue myself, I am not sure if it is a awesomewm or a X11; in either way I would really appreciate help to know what triggers the bug in my case and how does everybody else (with different WMs for example) avoid it. Also if it is a know issue with X11.

Appendix:

I will give more detail here about my setup:

My screens setup is as follows:
(Dimensions on the sides and the red circle is where the mouse gets stuck)

text4769

I have an nvidia and the following in my xorg.conf.d/20-nvidia.conf

Section "ServerLayout"
    Identifier      "desktop_layout"
    Screen          0 "nvidia"
    Inactive        "intel"
EndSection

Section "Device"
    Identifier      "nvidia"
    Driver          "nvidia"
    BusID           "PCI:1:0:0"
EndSection

Section "Device"
    Identifier      "intel"
    Driver          "modesetting"
    BusID           "PCI:0:2:0"
    Option          "AccelMethod" "none"
EndSection

Section "Screen"
    Identifier "nvidia"
    Device "nvidia"
    Option "AllowEmptyInitialConfiguration"
EndSection

Section "Screen"
    Identifier "intel"
    Device "intel"
EndSection

and on sddm Xsetup:

# # For nvidia
xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
xrandr --dpi 96

# Apply our screen setup
xrandr --output HDMI-1-2 --mode 2560x1080 --primary --output DP-1-1  --mode 1920x1080 --rotate left --right-of HDMI-1-2 --output eDP-1-1 --off
xrandr --output HDMI-1-2 --pos 0x330 --output DP-1-1 --pos 2560x0

Also, I know similar issues exists in X11 that are related to the mouse, but I am not sure if I am triggering the same bug. In any how, I am not changing the acceleration or any of the settings except Xcursor.size: 16.

Since the issue also happens with the default awesomewm config, I think no need to provide my rc.lua file but let me know if you need it.

It is worth mentioning that the issue disappears once I move the mouse (physically) back and forth a couple of times between the screens. So the issue only happen right after start up but never after.

Thanks!

@Elv13 Elv13 added this to the v4.4 milestone Jan 1, 2024
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

2 participants