ref: bab0c799de34fbba25ec08aae60bb40f2d394a67
parent: 44f57781df714328b2bda786131f7cfe76651aed
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Fri Jul 8 18:25:52 EDT 2022
wayland: release pointer/keyboard on seat capabilities change
--- a/gui-wl/wl-cb.c
+++ b/gui-wl/wl-cb.c
@@ -375,15 +375,25 @@
seat_handle_capabilities(void *data, struct wl_seat *seat, uint32_t capabilities)
{
Wlwin *wl;
+ int pointer, keyboard;
wl = data;
- if(capabilities & WL_SEAT_CAPABILITY_POINTER) {
+ pointer = capabilities & WL_SEAT_CAPABILITY_POINTER;
+ if(pointer && wl->pointer == nil){
wl->pointer = wl_seat_get_pointer(seat);
wl_pointer_add_listener(wl->pointer, &pointer_listener, wl);
+ }else if(!pointer && wl->pointer != nil){
+ wl_pointer_release(wl->pointer);
+ wl->pointer = nil;
}
- if(capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
- struct wl_keyboard *keyboard = wl_seat_get_keyboard(seat);
- wl_keyboard_add_listener(keyboard, &keyboard_listener, wl);
+
+ keyboard = capabilities & WL_SEAT_CAPABILITY_KEYBOARD;
+ if(keyboard && wl->keyboard == nil){
+ wl->keyboard = wl_seat_get_keyboard(seat);
+ wl_keyboard_add_listener(wl->keyboard, &keyboard_listener, wl);
+ }else if(!keyboard && wl->keyboard != nil){
+ wl_keyboard_release(wl->keyboard);
+ wl->keyboard = nil;
}
}
--- a/gui-wl/wl-inc.h
+++ b/gui-wl/wl-inc.h
@@ -63,6 +63,7 @@
struct wl_data_device_manager *data_device_manager;
struct wl_data_device *data_device;
struct wl_pointer *pointer;
+ struct wl_keyboard *keyboard;
/* Keyboard state */
struct xkb_state *xkb_state;
struct xkb_context *xkb_context;