gamescope icon indicating copy to clipboard operation
gamescope copied to clipboard

--force-grab-cursor confines cursor to an area that doesn't correspond with on-screen image

Open WhyNotHugo opened this issue 11 months ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Are you using any gamescope patches or a forked version of gamescope?

  • [x] The issue occurs on upstream gamescope without any modifications

Current Behavior

I'm playing StarCraft II, which only supports 16:9 on a 21:9 monitor

I run it with:

gamescope --force-grab-cursor -W 3440 -H 1440 -w 2560 -h 1440 -- …

The game itself renders on the left of the screen, with a large black space on the right (that's fine, I prefer a black space instead of a stretched game).

However, when using the --force-grab-cursor, the mouse cursor is confined to an area in the centre of my screen. As a result, I can't reach the left of the screen (but can reach half of the black area on the right).

If I remove --force-grab-cursor, I can reach any part of the screen, but then I can't trigger in-game functionality which requires putting the cursor on the right of the screen (because the cursor moves out into the black area).

Steps To Reproduce

  1. gamescope --force-grab-cursor -W 3440 -H 1440 -w 2560 -h 1440 -- flatpak run net.lutris.Lutris
  2. I'm reproducing this with StarCraft II. I don't know if this happens with other games.
  3. Move the mouse around to determine the area to which it is confined.

If you don't have a 21:9 monitor, I guess you can reproduce this with something like (untested):

gamescope --force-grab-cursor -W 3440 -H 1440 -w 1800 -h 1440 -- …

Hardware information

> cat /etc/os-release
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.22.0_alpha20250108
PRETTY_NAME="Alpine Linux edge"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues"
> lspci -nn | grep VGA
03:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 31 [Radeon RX 7900 XT/7900 XTX/7900 GRE/7900M] [1002:744c] (rev cc)
> vulkaninfo --summary | grep driverInfo
	driverInfo         = Mesa 24.3.4

See this gist for CPU info (it's over 600 lines and likely not relevant).

Software information

- Desktop environment: sway version 1.10.1
- Session type: wayland
- Gamescope version: gamescope 3.16.1
- Gamescope launch command(s): see above

Which gamescope backends have the issue you are reporting?

  • [x] Wayland (default for nested gamescope)
  • [ ] DRM (default for embedded gamescope, i.e. gamescope-session)
  • [ ] SDL
  • [ ] OpenVR

Logging, screenshots, or anything else

Start-up logs:

> gamescope --force-grab-cursor -W 3440 -H 1440 -w 2560 -h 1440 -- flatpak run net.lutris.Lutris
[gamescope] [Info]  console: gamescope version  (gcc 14.2.0)
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
[gamescope] [Info]  scriptmgr: Loading scripts from: '/usr/share/gamescope/scripts'
[gamescope] [Info]  scriptmgr: Loading scripts from: '/usr/share/gamescope/scripts/00-gamescope'
[gamescope] [Info]  scriptmgr: Loading scripts from: '/usr/share/gamescope/scripts/00-gamescope/common'
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/common/inspect.lua' (id: 0)
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/common/modegen.lua' (id: 1)
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/common/util.lua' (id: 2)
[gamescope] [Info]  scriptmgr: Loading scripts from: '/usr/share/gamescope/scripts/00-gamescope/displays'
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/displays/asus.rogally.lcd.lua' (id: 3)
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/displays/deckhd.steamdeck.deckhd-lcd.lua' (id: 4)
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/displays/valve.steamdeck.lcd.lua' (id: 5)
[gamescope] [Info]  scriptmgr: Running script file '/usr/share/gamescope/scripts/00-gamescope/displays/valve.steamdeck.oled.lua' (id: 6)
[gamescope] [Info]  scriptmgr: Loading scripts from: '/etc/gamescope/scripts'
[gamescope] [Warn]  scriptmgr: Directory '/etc/gamescope/scripts' does not exist
[gamescope] [Info]  scriptmgr: Loading scripts from: '/home/hugo/.config/gamescope/scripts'
[gamescope] [Warn]  scriptmgr: Directory '/home/hugo/.config/gamescope/scripts' does not exist
ATTENTION: default value of option vk_khr_present_wait overridden by environment.
[gamescope] [Info]  vulkan: selecting physical device 'AMD Radeon RX 7900 XT (RADV NAVI31)': queue family 1 (general queue family 0)
[gamescope] [Info]  vulkan: physical device supports DRM format modifiers
[gamescope] [Info]  wlserver: [backend/headless/backend.c:67] Creating headless backend
[gamescope] [Info]  xdg_backend: Seat name: seat0
[gamescope] [Info]  vulkan: supported DRM formats for sampling usage:
[gamescope] [Info]  vulkan:   AR24 (0x34325241)
[gamescope] [Info]  vulkan:   XR24 (0x34325258)
[gamescope] [Info]  vulkan:   AB24 (0x34324241)
[gamescope] [Info]  vulkan:   XB24 (0x34324258)
[gamescope] [Info]  vulkan:   RG16 (0x36314752)
[gamescope] [Info]  vulkan:   NV12 (0x3231564E)
[gamescope] [Info]  vulkan:   AB4H (0x48344241)
[gamescope] [Info]  vulkan:   XB4H (0x48344258)
[gamescope] [Info]  vulkan:   AB48 (0x38344241)
[gamescope] [Info]  vulkan:   XB48 (0x38344258)
[gamescope] [Info]  vulkan:   AB30 (0x30334241)
[gamescope] [Info]  vulkan:   XB30 (0x30334258)
[gamescope] [Info]  vulkan:   AR30 (0x30335241)
[gamescope] [Info]  vulkan:   XR30 (0x30335258)
[gamescope] [Info]  wlserver: Using explicit sync when available
[gamescope] [Info]  wlserver: Running compositor on wayland display 'gamescope-0'
[gamescope] [Info]  wlserver: [backend/headless/backend.c:17] Starting headless backend
[gamescope] [Info]  wlserver: Successfully initialized libei for input emulation!
[gamescope] [Info]  wlserver: [xwayland/server.c:107] Starting Xwayland on :1
[gamescope] [Info]  pipewire: stream state changed: connecting
[gamescope] [Info]  pipewire: stream state changed: paused
[gamescope] [Info]  pipewire: stream available on node ID: 95
[gamescope] [Info]  xwm: Embedded, no cursor set. Using left_ptr by default.
[gamescope] [Info]  vblank: Using timerfd.
[gamescope] [Info]  edid: Patching res 800x1280 -> 2560x1440
…

WhyNotHugo avatar Feb 15 '25 21:02 WhyNotHugo

The game with which I'm reproducing this is StarCraft II. Apparently it doesn't happen with non-game windows (e.g.: with Lutris launcher itself). Updated reproduction steps accordingly.

WhyNotHugo avatar Feb 16 '25 00:02 WhyNotHugo

having a similar issue on cs2. trying to play stretched with a resolution of 1920x1440 on my monitor of resolution 2560x1440. The cursor escapes the window when it should be "force grabbed" and it also sometimes leaves the window at a line not at the edge of the window.

fxzzi avatar Apr 03 '25 17:04 fxzzi

Can confirm this happens to me too.

I'm on Sway with wlroots and if I run the game without --force-grab-cursor the size of the mouse area is correct (AKA, the mouse corresponds 1:1 in game with where it is on the monitor. However, here I have the problem of the cursor leaving the game and exiting to my second monitor, or hitting the monitor's "edge" and ceasing input. AKA, the cursor is not properly grabbed and input is only read while the cursor is over the game.

If I run with --force-grab-cursor, there will be an offset, where the mouse cursor in game is displaying correctly, but the actual cursor's position is offset. Further testing confirms that the "grab area" is MUCH smaller than the actual game window, to the point of it being almost a 1280x720 "window" inside the 2560x1440 game window, where the mouse lives. Go outside this "mini window" and you will find the cursor hopping over to your second monitor.

If the game is ran in a smaller window, not fullscreen, then you will see how poorly the in-game cursor and actual cursor align, with the in-game cursor being nowhere near the game border when it actually pops outside onto the desktop.

This problem ENTIRELY goes away if I disable my second monitor (using DPMS off).

This happens consistently in every game I have tried so far (although all games I've done this on are ran via Proton. I've tested Proton 9 and Proton-GE. Both exhibit the same problem).

Having to disable my second monitor just to use gamescope is a huge annoyance, and unfortunately, I can't play without gamescope because even though mouse-grabbing works properly, I will have numerous graphical artifacts, such as flickering when trying to play.

Tested with both gamescope 3.16.1 and 3.16.3 (gcc 14.2.1)

The-Toblin avatar Apr 10 '25 10:04 The-Toblin

Probably related to #1177 Using --force-composition solves the alignment and the cursor problem but it causes lots of glitches and flickering in full screen in my case.

--backend sdl Solves the problem as well for me, specifically using --expose-wayland -f --force-grab-cursor --backend sdl since i'm on wayland.

carlinux avatar May 05 '25 12:05 carlinux