Hyprland icon indicating copy to clipboard operation
Hyprland copied to clipboard

Mouse grabbing is broken for multi-head configurations and for fractional scaling.

Open pshirshov opened this issue 2 years ago • 6 comments

Hyprland Version

d126d2c09204a09b0b10ce4f999520fc901fbf0a

Bug or Regression?

Bug

Description

I tried to play DotA 2 under Hyprland.

I have a multi-head 4K setup with the following settings:

monitor=DP-1, 3840x2160@144, 2560x0, 1.5, bitdepth,10, vrr,1
monitor=DP-3, 3840x2160@60, 0x0, 1.5
monitor=DP-2, 3840x2160@60, 5120x0, 1.5

xwayland {
  force_zero_scaling = true
}

I'm trying to run the game on DP-1.

DotA is an XWayland app and it grabs the mouse cursor. And there are two problems with that:

  1. The game always locks a region which is 1.5x bigger than its window. So, if the window is 800x600, it would lock 1200x900 area. It only happens whenforce_zero_scaling=true.
  2. The game always locks an area on DP-3 (which starts at 0x0 coordinates in Hyprland). So, the mouse pointer gets restricted in a completely irrelevant area either completely outside of the game window or just overlapping with it. This happens regardless of force_zero_scaling setting.

Any combination of game settings doesn't help.

Please help.

Notes:

  1. Gamescope doesn't help because mouse grabbing seems to be broken in it: https://github.com/ValveSoftware/gamescope/issues/955
  2. The game works just fine under Plasma. Mouse is locked exactly to the game window boundaries.
  3. While the coordinates of the pointer lock area are wrong (the pointer should be restricted to DP-1 but it gets locked on DP-2), the relative coordinates of the lock area seem to be correct. So, if I place my game window top left corner at 100x200 on DP-1, the pointer lock area would be placed at 100x200 on DP-2.

How to reproduce

Run DotA 2 on a second display in a dual-head setup, start a match with bots and proceed to the arena.

Your mouse won't be able to interact with the game, it would be restricted to a irrelevant area.

It doesn't matter if the game is in fullscreen or windowed. force_zero_scaling would make things even worse.

Crash reports, logs, images, videos

No response

pshirshov avatar Sep 17 '23 12:09 pshirshov

lol, right, I probably forgot that it should convert the coordinate space.

vaxerski avatar Sep 19 '23 10:09 vaxerski

see #3381, check if that fixes the issue

vaxerski avatar Sep 20 '23 10:09 vaxerski

I'm away from my workstation for a week, will do once I'm back.

Thank you.

pshirshov avatar Sep 20 '23 11:09 pshirshov

@vaxerski : the situation got better, but there is still a problem.

So, now the pointer lock area is positioned correctly, it always starts at the top-left corner of the game window. That's a very good thing.

The bad thing is that now the lock area is exactly 2.5 times bigger than it should be (previously it was just 1.5 times bigger). So, the cursor still can leave the game window :( This only happens with configurations with scaling enabled and forced zero xwayland scaling.

Thank you for your hard work.

pshirshov avatar Sep 28 '23 21:09 pshirshov

Issue (at least the second part) is still present, same thing happening to me. Tested in openmw and fallout 1, both xwayland. Removing force_zero_scaling=true fixes it like above. Any further progress on whats causing this past those commits?

UmJammerRammy avatar Mar 02 '24 10:03 UmJammerRammy

I believe I encounter a similar issue, where the lock area on my external monitor is half the size of the external monitor (actually, not half, but proportional to the width of the monitor the client runs on compared to the width of my full monitor layout).

So, my laptop screen has a resolution of 2880x1800 and my external monitor of 2560x1440.

  • When I run an application grabbing the mouse on the external monitor (set up on the right), the mouse is grabbed within the right 45 % of the window (2560/(2800+2560)).
  • Interestingly, if I move the game to my laptop screen on the left, the cursor is immedialy locked within the left 55 % of the window 2800/(2800+2560).

The same behavior happens height-wise.

It seems like my whole monitor layout is crammed onto a single screen to calculate the lock area.

If I disable my laptop screen with hypctl keyword, the behavior instantly goes back to normal (the grab area fits the whole client).

I'll see if I can capture a video of the two monitors to showcase this.

Edit: I work around this by starting my mouse-grabbing application (cloud gaming client) through cage. There, when the mouse is grabbed, it properly covers the whole client.

apognu avatar Oct 10 '24 06:10 apognu