[PATCH weston 3/4] compositor-wayland: Properly release input resources when caps change
Derek Foreman
derekf at osg.samsung.com
Fri Oct 9 09:28:45 PDT 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>
---
src/compositor-wayland.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index dbbc1ad..b25f4ea 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -72,6 +72,7 @@ struct wayland_backend {
int use_pixman;
int sprawl_across_outputs;
+ int seat_version;
struct theme *theme;
cairo_device_t *frame_device;
@@ -1620,6 +1621,7 @@ input_handle_capabilities(void *data, struct wl_seat *seat,
enum wl_seat_capability caps)
{
struct wayland_input *input = data;
+ struct wayland_backend *backend = input->backend;
if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->parent.pointer) {
input->parent.pointer = wl_seat_get_pointer(seat);
@@ -1628,8 +1630,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 (backend->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) {
@@ -1638,8 +1644,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 (backend->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);
}
}
@@ -1823,6 +1833,7 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t name,
&_wl_fullscreen_shell_interface, 1);
} else if (strcmp(interface, "wl_seat") == 0) {
display_add_seat(b, name, version);
+ b->seat_version = version;
} else if (strcmp(interface, "wl_output") == 0) {
wayland_backend_register_output(b, name);
} else if (strcmp(interface, "wl_shm") == 0) {
--
2.5.3
More information about the wayland-devel
mailing list