From e20eff277bc8fe4663dcba646f18706d88f4d1d0 Mon Sep 17 00:00:00 2001 From: Jin Liu Date: Thu, 4 Jan 2024 19:54:03 +0800 Subject: [PATCH] Fix Wayland cursor-shape-v1 cursor not updating According to https://wayland.app/protocols/cursor-shape-v1#wp_cursor_shape_device_v1:request:set_shape > The serial parameter must match the latest wl_pointer.enter or > zwp_tablet_tool_v2.proximity_in serial number sent to the client. So we can't use wl.serial or wl.pointer_serial, because they are also updated in other places. --- glfw/wl_init.c | 2 +- glfw/wl_platform.h | 2 +- glfw/wl_window.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/glfw/wl_init.c b/glfw/wl_init.c index 1b91fd605..7653cf1ff 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -99,7 +99,7 @@ static void pointerHandleEnter(void* data UNUSED, return; } window->wl.decorations.focus = focus; - _glfw.wl.serial = serial; _glfw.wl.input_serial = serial; _glfw.wl.pointer_serial = serial; + _glfw.wl.serial = serial; _glfw.wl.input_serial = serial; _glfw.wl.pointer_serial = serial; _glfw.wl.pointer_enter_serial = serial; _glfw.wl.pointerFocus = window; window->wl.hovered = true; diff --git a/glfw/wl_platform.h b/glfw/wl_platform.h index 60b77efbe..f3a546227 100644 --- a/glfw/wl_platform.h +++ b/glfw/wl_platform.h @@ -295,7 +295,7 @@ typedef struct _GLFWlibraryWayland struct wl_surface* cursorSurface; GLFWCursorShape cursorPreviousShape; - uint32_t serial, input_serial, pointer_serial, keyboard_enter_serial; + uint32_t serial, input_serial, pointer_serial, pointer_enter_serial, keyboard_enter_serial; int32_t keyboardRepeatRate; monotonic_t keyboardRepeatDelay; diff --git a/glfw/wl_window.c b/glfw/wl_window.c index 331e9cc12..0782de39d 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -200,7 +200,7 @@ setCursorImage(_GLFWwindow* window, bool on_theme_change) { if (_glfw.wl.wp_cursor_shape_device_v1) { int which = glfw_cursor_shape_to_wayland_cursor_shape(cursorWayland->shape); if (which > -1) { - wp_cursor_shape_device_v1_set_shape(_glfw.wl.wp_cursor_shape_device_v1, _glfw.wl.serial, (uint32_t)which); + wp_cursor_shape_device_v1_set_shape(_glfw.wl.wp_cursor_shape_device_v1, _glfw.wl.pointer_enter_serial, (uint32_t)which); return; } }