From 2f90216406fcda9dda1df06349f5ede0345bd46b Mon Sep 17 00:00:00 2001 From: PumpkinXD <54535387+PumpkinXD@users.noreply.github.com> Date: Mon, 29 Dec 2025 16:34:56 +0800 Subject: [PATCH] fix(wayland): combine GLFW backend check with XDG_SESSION_TYPE detection The previous check using `glfwPlatformSupported` was insufficient as it only tests compilation support, not the active session type. This caused false positives on systems with Wayland-enabled GLFW libraries on X11 sessions. Now also verify the XDG_SESSION_TYPE environment variable to ensure an actual Wayland session is active, preventing the crash on x11. Fix: #73 --- src/main/java/net/notcoded/wayfix/WayFix.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/notcoded/wayfix/WayFix.java b/src/main/java/net/notcoded/wayfix/WayFix.java index c1a2467..30fef4f 100644 --- a/src/main/java/net/notcoded/wayfix/WayFix.java +++ b/src/main/java/net/notcoded/wayfix/WayFix.java @@ -10,6 +10,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.glfw.GLFW; +import java.util.Objects; public class WayFix { public static final Logger LOGGER = LogManager.getLogger(WayFix.class); @@ -35,7 +36,9 @@ public static boolean isWayland() { public static boolean supportsWayland() { try { - return GLFW.glfwPlatformSupported(GLFW.GLFW_PLATFORM_WAYLAND); + return GLFW.glfwPlatformSupported(GLFW.GLFW_PLATFORM_WAYLAND) && + Objects.requireNonNullElse(System.getenv("XDG_SESSION_TYPE"), + "").toLowerCase().startsWith("wayland"); } catch (NoSuchMethodError ignored) { // <3.3.0 LOGGER.warn("WayFix is disabling itself due to the LWJGL Version being too low."); LOGGER.warn("Please update to a LWJGL version such as '3.3.1' or higher.");