From 1ce855b0b1c8c7418ef2925d75f3b7f366ff5cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Mon, 1 Sep 2025 18:43:26 +0200 Subject: [PATCH] Wayland: Fix missing checks for optional protocol --- README.md | 2 ++ src/wl_window.c | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9bad25a0f..89aaaac95 100644 --- a/README.md +++ b/README.md @@ -146,6 +146,8 @@ information on what to include when reporting a bug. from a modal to the content area - [Wayland] Bugfix: free modules at end of terminate function to resolve potential segmentation fault (#2744) + - [Wayland] Bugfix: Confining or disabling the cursor could segfault on + compositors without `pointer-constraints-unstable-v1` - [X11] Bugfix: Running without a WM could trigger an assert (#2593,#2601,#2631) - [X11] Bugfix: Occasional crash when an idle display awakes (#2766) - [X11] Bugfix: Prevent BadWindow when creating small windows with a content scale diff --git a/src/wl_window.c b/src/wl_window.c index 4220d17e0..1bb32f5f0 100644 --- a/src/wl_window.c +++ b/src/wl_window.c @@ -2974,10 +2974,16 @@ static void lockPointer(_GLFWwindow* window) if (!_glfw.wl.relativePointerManager) { _glfwInputError(GLFW_FEATURE_UNAVAILABLE, - "Wayland: The compositor does not support pointer locking"); + "Wayland: The compositor does not support relative pointer motion"); return; } + if (!_glfw.wl.pointerConstraints) + { + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The compositor does not support locking the pointer"); + } + window->wl.relativePointer = zwp_relative_pointer_manager_v1_get_relative_pointer( _glfw.wl.relativePointerManager, @@ -3025,6 +3031,12 @@ static const struct zwp_confined_pointer_v1_listener confinedPointerListener = static void confinePointer(_GLFWwindow* window) { + if (!_glfw.wl.pointerConstraints) + { + _glfwInputError(GLFW_FEATURE_UNAVAILABLE, + "Wayland: The compositor does not support confining the pointer"); + } + window->wl.confinedPointer = zwp_pointer_constraints_v1_confine_pointer( _glfw.wl.pointerConstraints,