hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
19.57k stars 824 forks source link

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

Open pshirshov opened 11 months ago

pshirshov commented 11 months ago

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

vaxerski commented 11 months ago

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

vaxerski commented 11 months ago

see #3381, check if that fixes the issue

pshirshov commented 11 months ago

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

Thank you.

pshirshov commented 11 months ago

@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.

UmJammerRammy commented 6 months ago

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?