From 016714a6685d384b3849a570f39f27943c6106dc Mon Sep 17 00:00:00 2001 From: Dave Akers Date: Thu, 3 Apr 2025 21:31:59 +0000 Subject: [PATCH] app: [Wayland] use correct serial for wl_pointer_set_cursor, take 2 To fix #644 the serial passed to wl_pointer_set_cursor must come from the pointer enter event. To do this we need a place to keep the serial so I've added a field to the wlSeat struct to hold on to it. Ref: https://wayland.app/protocols/wayland#wl_pointer:request:set_cursor Ref: https://wayland-book.com/seat/pointer.html Fixes: https://todo.sr.ht/~eliasnaur/gio/644 Signed-off-by: Dave Akers --- app/os_wayland.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/os_wayland.go b/app/os_wayland.go index 4d589a7f..e68d3e13 100644 --- a/app/os_wayland.go +++ b/app/os_wayland.go @@ -116,6 +116,8 @@ type wlSeat struct { // The most recent input serial. serial C.uint32_t + // The most recent pointer enter serial. + pointerSerial C.uint32_t pointerFocus *window keyboardFocus *window @@ -851,6 +853,7 @@ func gio_onTouchCancel(data unsafe.Pointer, touch *C.struct_wl_touch) { func gio_onPointerEnter(data unsafe.Pointer, pointer *C.struct_wl_pointer, serial C.uint32_t, surf *C.struct_wl_surface, x, y C.wl_fixed_t) { s := callbackLoad(data).(*wlSeat) s.serial = serial + s.pointerSerial = serial w := callbackLoad(unsafe.Pointer(surf)).(*window) w.seat = s s.pointerFocus = w @@ -1169,7 +1172,7 @@ func (w *window) updateCursor() { if ptr == nil { return } - w.setCursor(ptr, w.seat.serial) + w.setCursor(ptr, w.seat.pointerSerial) } func (w *window) setCursor(pointer *C.struct_wl_pointer, serial C.uint32_t) {