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
21.83k stars 909 forks source link

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

Open pshirshov opened 1 year ago

pshirshov commented 1 year 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 1 year ago

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

vaxerski commented 1 year ago

see #3381, check if that fixes the issue

pshirshov commented 1 year ago

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

Thank you.

pshirshov commented 1 year 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 8 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?

apognu commented 1 month ago

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.

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.