mojira.dev
MC-307253

The mouse cursor does not consistently reset to the center of the window on Wayland

When running Minecraft with the recently added native Wayland support, enabled using: -DMC_DEBUG_PREFER_WAYLAND,

The mouse cursor is expected to reset to the center of the screen when opening certain GUIs (e.g., pause menu, chest, inventory).

However, this behavior is inconsistent: Sometimes the cursor correctly resets to the center (as expected).

Other times it remains at its previous position instead.

Steps to reproduce:

1, A Linux installation with a Wayland compositor.

2, Launch Minecraft with,

-DMC_DEBUG_ENABLED

-DMC_DEBUG_PREFER_WAYLAND

3, Join a world or server.

4, Open the pause menu or anything that shows the mouse cursor, like a chest, the chat etc.

5, Observe the mouse cursor’s position

The cursor should always reset to the center of the screen when opening GUI screens. But the cursor only sometimes resets to the center; other times it stays where it was previously.

This behavior appears completely inconsistent/random.

Solutions:

Since you are already modernizing the game's code, consider migrating input/window handling to SDL, which provides a more stable and consistent Wayland behavior, and it's also universally compatible. Works both with Linux (Wayland and X11), MacOS, Windows. This was also mentioned as a suggestion here.

https://feedback.minecraft.net/hc/en-us/community/posts/44503913285005-Wayland-Cursor-Lock-Broken-on-Linux-Add-SDL-Input-Support-Instead-of-GLFW

Or, apply some cursor patches like they did here, https://github.com/BoyOrigin/glfw-wayland (This was also the way to unnofficialy run the game natively on Wayland before 26.1/26.1.1)

Environment

Linux (Wayland), JVM Minecraft debug flag '-DMC_DEBUG_PREFER_WAYLAND'

Linked issues

Comments 2

Hi! Are you still able to reproduce this issue in 26.3-snapshot-4 or newer?

Hi, I was running into a similar issue on 26.3-snapshot-4 as explained in this bug report:

MC-310162

So a similar bug still exists in the newest snapshot. However, I did not launch the game with any additional JVM Flags now that SDL is used.

Astr4x

(Unassigned)

Plausible

Platform HC

Normal

Input

26.1.1

Retrieved