From 1ba4fde1015fc6da19dfbfdf0f77f1071416e215 Mon Sep 17 00:00:00 2001 From: Boyan Ding Date: Mon, 4 Aug 2014 21:16:34 +0800 Subject: [PATCH] xwayland: Activate and enable device on first capability reporting Commit 2172714c changed behavior of capability handling, but it only solved part of the problem. If Xwayland is launched without a capability (e.g. no pointer device is connected when Xwayland was spinned up), and later that capability comes, the device added will not be automatically initialized. This patch initializes the device when the capability is reported for the first time, thus avoiding the problem. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=81819 Signed-off-by: Boyan Ding Reviewed-by: Daniel Stone --- hw/xwayland/xwayland-input.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index a29ba782f..010d28c43 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -692,13 +692,13 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, wl_pointer_add_listener(xwl_seat->wl_pointer, &pointer_listener, xwl_seat); - if (xwl_seat->pointer) - EnableDevice(xwl_seat->pointer, TRUE); - else { + if (xwl_seat->pointer == NULL) { xwl_seat_set_cursor(xwl_seat); xwl_seat->pointer = add_device(xwl_seat, "xwayland-pointer", xwl_pointer_proc); + ActivateDevice(xwl_seat->pointer, TRUE); } + EnableDevice(xwl_seat->pointer, TRUE); } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) { wl_pointer_release(xwl_seat->wl_pointer); xwl_seat->wl_pointer = NULL; @@ -712,12 +712,12 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, wl_keyboard_add_listener(xwl_seat->wl_keyboard, &keyboard_listener, xwl_seat); - if (xwl_seat->keyboard) - EnableDevice(xwl_seat->keyboard, TRUE); - else { + if (xwl_seat->keyboard == NULL) { xwl_seat->keyboard = add_device(xwl_seat, "xwayland-keyboard", xwl_keyboard_proc); + ActivateDevice(xwl_seat->keyboard, TRUE); } + EnableDevice(xwl_seat->keyboard, TRUE); } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && xwl_seat->wl_keyboard) { wl_keyboard_release(xwl_seat->wl_keyboard); xwl_seat->wl_keyboard = NULL;