godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.14k stars 19.95k forks source link

MOUSE_MODE_CONFINED does not confine cursor in some cases. #85496

Open odecay opened 8 months ago

odecay commented 8 months ago

Godot version

4.1.3.stable

System information

Godot v4.1.3.stable unknown - Arch Linux #1 ZEN SMP PREEMPT_DYNAMIC Mon, 20 Nov 2023 23:17:26 +0000 - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 6700 XT (RADV NAVI22) () - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

After setting mouse mode to MOUSE_MODE_CONFINED, the cursor very often is able to exit the window. The cursor can escape the window upward 100% of the time and less often when moving to either side or down. MOUSE_MODE_CONFINED_HIDDEN works as expected, debugged via printing mouse event positions. MOUSE_MODE_CONFINED also works as expected if the window is set to Borderless mode from project settings.

(Additionally I am on KDE Wayland which doesn't seem to have shown in my copied system information above)

Steps to reproduce

Press Enter to toggle MOUSE_MODE_CONFINED, move mouse cursor up over top of window exiting confined area, no mouse motion events received after cursor exits window.

Press Escape to toggle MOUSE_MODE_CONFINED_HIDDEN, move cursor up, cursor is properly confined.

Minimal reproduction project

cursor_lock_repro.zip

lucassene commented 8 months ago

In 4.2, MOUSE_MODE_CONFINED_HIDDEN, doesn't exit the screen on the left or top but can leave the screen on the right and bottom sides. The game is in fullscreen mode via Project Settings, and I have a 2nd monitor.