Wayland: Release input devices where possible

On systems with wl_seat verison 3 or later, use release instead of
destroy on input devices when they are disconnected.
This commit is contained in:
Camilla Löwy 2026-01-26 17:34:58 +01:00
parent 7b370d8df0
commit 0aa77a9a3a

View File

@ -1926,7 +1926,11 @@ static void seatHandleCapabilities(void* userData,
} }
else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer) else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
{ {
if (wl_pointer_get_version(_glfw.wl.pointer) >= WL_POINTER_RELEASE_SINCE_VERSION)
wl_pointer_release(_glfw.wl.pointer);
else
wl_pointer_destroy(_glfw.wl.pointer); wl_pointer_destroy(_glfw.wl.pointer);
_glfw.wl.pointer = NULL; _glfw.wl.pointer = NULL;
} }
@ -1937,7 +1941,11 @@ static void seatHandleCapabilities(void* userData,
} }
else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard) else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
{ {
if (wl_keyboard_get_version(_glfw.wl.keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION)
wl_keyboard_release(_glfw.wl.keyboard);
else
wl_keyboard_destroy(_glfw.wl.keyboard); wl_keyboard_destroy(_glfw.wl.keyboard);
_glfw.wl.keyboard = NULL; _glfw.wl.keyboard = NULL;
} }
} }