[PATCH weston v2 3/5] compositor-wayland: Properly release input resources when caps change
Derek Foreman
derekf at osg.samsung.com
Fri Nov 6 13:56:08 PST 2015
We should use wl_*_release when available instead of destroy, and we
should update weston's internal input tracking with weston_seat_releases
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
Changes from v1:
wl_seat version is now tracked independently for each seat instead
of assuming it's the same for every seat.
src/compositor-wayland.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 0f3a1a7..d7bc55a 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -178,6 +178,7 @@ struct wayland_input {
uint32_t key_serial;
uint32_t enter_serial;
bool has_focus;
+ int seat_version;
struct wayland_output *output;
struct wayland_output *keyboard_focus;
@@ -1630,8 +1631,12 @@ input_handle_capabilities(void *data, struct wl_seat *seat,
&pointer_listener, input);
weston_seat_init_pointer(&input->base);
} else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->parent.pointer) {
- wl_pointer_destroy(input->parent.pointer);
+ if (input->seat_version >= WL_POINTER_RELEASE_SINCE_VERSION)
+ wl_pointer_release(input->parent.pointer);
+ else
+ wl_pointer_destroy(input->parent.pointer);
input->parent.pointer = NULL;
+ weston_seat_release_pointer(&input->base);
}
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->parent.keyboard) {
@@ -1640,8 +1645,12 @@ input_handle_capabilities(void *data, struct wl_seat *seat,
wl_keyboard_add_listener(input->parent.keyboard,
&keyboard_listener, input);
} else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->parent.keyboard) {
- wl_keyboard_destroy(input->parent.keyboard);
+ if (input->seat_version >= WL_KEYBOARD_RELEASE_SINCE_VERSION)
+ wl_keyboard_release(input->parent.keyboard);
+ else
+ wl_keyboard_destroy(input->parent.keyboard);
input->parent.keyboard = NULL;
+ weston_seat_release_keyboard(&input->base);
}
}
@@ -1657,9 +1666,10 @@ static const struct wl_seat_listener seat_listener = {
};
static void
-display_add_seat(struct wayland_backend *b, uint32_t id, uint32_t version)
+display_add_seat(struct wayland_backend *b, uint32_t id, uint32_t available_version)
{
struct wayland_input *input;
+ uint32_t version = MIN(available_version, 4);
input = zalloc(sizeof *input);
if (input == NULL)
@@ -1668,7 +1678,8 @@ display_add_seat(struct wayland_backend *b, uint32_t id, uint32_t version)
weston_seat_init(&input->base, b->compositor, "default");
input->backend = b;
input->parent.seat = wl_registry_bind(b->parent.registry, id,
- &wl_seat_interface, MIN(version, 4));
+ &wl_seat_interface, version);
+ input->seat_version = version;
wl_list_insert(b->input_list.prev, &input->link);
wl_seat_add_listener(input->parent.seat, &seat_listener, input);
--
2.6.1
More information about the wayland-devel
mailing list