Bug 487047 - [xwayland] cursor does not reset to center in games
Summary: [xwayland] cursor does not reset to center in games
Status: REPORTED
Alias: None
Product: kwin
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 6.1.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-15 06:19 UTC by madness742
Modified: 2024-09-16 20:25 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Video footage of the cursor bug in Counter Strike 2. (3.28 MB, video/mp4)
2024-05-15 06:19 UTC, madness742
Details

Note You need to log in before you can comment on or make changes to this bug.
Description madness742 2024-05-15 06:19:56 UTC
Created attachment 169494 [details]
Video footage of the cursor bug in Counter Strike 2.

SUMMARY
When opening a menu in a game, the mouse isn't always reset to center, it will if the camera angle in-game doesn't change and the menu is closed and reopened. It feels inconsistent and I'm often looking for my cursor on screen.

STEPS TO REPRODUCE
1. Launch a game from Steam (Proton/Native).
2. Open up a menu where the cursor normally would be centered on the screen.
3. Observe current cursor position.
4. Exit the menu.
5. Move mouse around in-game.
6. Open up the menu again.
7. Observe updated cursor position.

OBSERVED RESULT
The cursor changes location when bringing up the menu after moving the camera angle in-game.

EXPECTED RESULT
The cursor should be centered upon opening the menu after moving the camera angle in-game.

SOFTWARE/OS VERSIONS
Linux: OpenSUSE Tumbleweed 
(available in About System)
KDE Plasma Version: 6.0.4
KDE Frameworks Version: 6.2.0
Qt Version: 6.7.0
Kernel Version: 6.8.8.1-default (64 bit)

ADDITIONAL INFORMATION

Affected games:
- Counter Strike 1.6
- Counter Strike 2
- Cyberpunk 2077
- Ratchet and Clank Rift Apart

*This does not happen when starting KDE in a X11 session from SDDM!*
*All steam games I've tried so far are affected by this*

- I have tried updating to KDE unstable from openSUSE repo (KDE 6.1).
- I have tried running the game in gamescope with `--force-grab-cursor` parameter.
- I have tried using `QT_QPA_PLATFORM=xcb` when starting Steam.
- I have tried using `QT_QPA_PLATFORM=xcb` as a launch parameter for the game.
- I have tried forcing a software cursor by using `KWIN_FORCE_SW_CURSOR=1`.
- I have tried using an older version of KDE in Kubuntu 24.04 LTS.
- I have tried using Steam from Flatpak and openSUSE repo.
- I have tired disabling and unplugging all my other monitors.
- I have tried disabling the integrated GPU.
- I have tried launching Steam from TTY.
- I have tried setting scaling to 100%.
- I have tried setting Legacy applications scaling to 'Apply scaling themselves' and 'Scaled by the system'.

Graphics:
  Device-1: AMD Navi 31 [Radeon RX 7900 XT/7900 XTX/7900M] driver: amdgpu
    v: kernel
  Display: wayland server: X.org v: 1.21.1.12 with: Xwayland v: 23.2.6
    compositor: kwin_wayland driver: X: loaded: modesetting unloaded: fbdev,vesa
    dri: radeonsi gpu: amdgpu resolution: 2560x1440
  API: OpenGL v: 4.6 compat-v: 4.5 vendor: amd mesa v: 24.0.5 renderer: AMD
    Radeon RX 7900 XTX (radeonsi navi31 LLVM 18.1.5 DRM 3.57 6.8.8-1-default)
Comment 1 madness742 2024-08-22 21:35:57 UTC
UPDATE:

I have tested Nobara, Fedora, openSUSE Tumbleweed, Arch and Kubuntu in the meantime.

X11 and Wayland behave the same now. Gamescope, even in a TTY or when passing the `--force-grab-cursor` parameter, also behaves the same. 

- Counter-Strike 2 (Native/SDL_VIDEO_DRIVER=x11): Cursor gets centered in-game after an update. Steam overlay does not center cursor upon opening.
- Counter-Strike 2 (Native/SDL_VIDEO_DRIVER=wayland): Breaks steam overlay
- Counter-Strike 2 (Proton Experimental): Cursor in steam overlay gets centered when playing on a map.

- Ratchet & Clank: Rift Apart (Proton Experimental): Cursor in steam overlay and when opening in-game map does not get centered. It does however center the cursor in the weapon wheel menu.

- Cyberpunk 2077 (Proton Experimental): Cursor in steam overlay gets both centered in-game and on the start menu. Every other menu (journal, maps, inventory) in the game  will randomly not get centered, but instead get placed on the left edge or right edge.

Current system stats:
Arch Linux
KDE Plasma: 6.1.4
KDE Frameworks: 6.5.0
Qt: 6.7.2
Kernel: 6.10.6-arch1-1(64-bit)
Comment 2 Retalak 2024-09-16 20:25:43 UTC
(In reply to madness742 from comment #1)
> UPDATE:
> 
> I have tested Nobara, Fedora, openSUSE Tumbleweed, Arch and Kubuntu in the
> meantime.
> 
> X11 and Wayland behave the same now. Gamescope, even in a TTY or when
> passing the `--force-grab-cursor` parameter, also behaves the same. 
> 
> - Counter-Strike 2 (Native/SDL_VIDEO_DRIVER=x11): Cursor gets centered
> in-game after an update. Steam overlay does not center cursor upon opening.
> - Counter-Strike 2 (Native/SDL_VIDEO_DRIVER=wayland): Breaks steam overlay
> - Counter-Strike 2 (Proton Experimental): Cursor in steam overlay gets
> centered when playing on a map.
> 
> - Ratchet & Clank: Rift Apart (Proton Experimental): Cursor in steam overlay
> and when opening in-game map does not get centered. It does however center
> the cursor in the weapon wheel menu.
> 
> - Cyberpunk 2077 (Proton Experimental): Cursor in steam overlay gets both
> centered in-game and on the start menu. Every other menu (journal, maps,
> inventory) in the game  will randomly not get centered, but instead get
> placed on the left edge or right edge.
> 
> Current system stats:
> Arch Linux
> KDE Plasma: 6.1.4
> KDE Frameworks: 6.5.0
> Qt: 6.7.2
> Kernel: 6.10.6-arch1-1(64-bit)

I believe this is the same bug that people (including myself until now) are incorrectly contributing to Minecraft here:
https://bugs.mojang.com/browse/MC-263682

It looks exactly the same as your example video in CS2, randomly my mouse will be on the far right side of the screen when opening the inventory in Minecraft. It makes Minecraft in particular pretty unplayable.