From 2172714c67d8701aa54c202e89f246f1dddac80a Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 22 Jul 2014 17:55:25 +0200 Subject: xwayland: Only disable/enable devices on capabilities change Anytime a capability is first reported, the device is created, but after that, it is only disabled/enabled. This is a closer behavior to what Xorg does on VT switch, at the expense of maybe leaving a dangling "physical" device if a capability goes for good. Otherwise, any DeviceIntPtr (re)created after server initialization will be left floating, and bad things happen when the wayland enter event handler tries to update cursor position based on a floating device. Signed-off-by: Carlos Garnacho Reviewed-by: Daniel Stone Signed-off-by: Keith Packard --- hw/xwayland/xwayland-input.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index 990cb82d8..cc5f7df05 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -491,31 +491,43 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, { struct xwl_seat *xwl_seat = data; - if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->pointer == NULL) { + if (caps & WL_SEAT_CAPABILITY_POINTER && xwl_seat->wl_pointer == NULL) { xwl_seat->wl_pointer = wl_seat_get_pointer(seat); wl_pointer_add_listener(xwl_seat->wl_pointer, &pointer_listener, xwl_seat); - xwl_seat_set_cursor(xwl_seat); - xwl_seat->pointer = - add_device(xwl_seat, "xwayland-pointer", xwl_pointer_proc); - } - else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->pointer) { + + if (xwl_seat->pointer) + EnableDevice(xwl_seat->pointer, TRUE); + else { + xwl_seat_set_cursor(xwl_seat); + xwl_seat->pointer = + add_device(xwl_seat, "xwayland-pointer", xwl_pointer_proc); + } + } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && xwl_seat->wl_pointer) { wl_pointer_release(xwl_seat->wl_pointer); - RemoveDevice(xwl_seat->pointer, FALSE); - xwl_seat->pointer = NULL; + xwl_seat->wl_pointer = NULL; + + if (xwl_seat->pointer) + DisableDevice(xwl_seat->pointer, TRUE); } - if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->keyboard == NULL) { + if (caps & WL_SEAT_CAPABILITY_KEYBOARD && xwl_seat->wl_keyboard == NULL) { xwl_seat->wl_keyboard = wl_seat_get_keyboard(seat); wl_keyboard_add_listener(xwl_seat->wl_keyboard, &keyboard_listener, xwl_seat); - xwl_seat->keyboard = - add_device(xwl_seat, "xwayland-keyboard", xwl_keyboard_proc); - } - else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && xwl_seat->keyboard) { + + if (xwl_seat->keyboard) + EnableDevice(xwl_seat->keyboard, TRUE); + else { + xwl_seat->keyboard = + add_device(xwl_seat, "xwayland-keyboard", xwl_keyboard_proc); + } + } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && xwl_seat->wl_keyboard) { wl_keyboard_release(xwl_seat->wl_keyboard); - RemoveDevice(xwl_seat->keyboard, FALSE); - xwl_seat->keyboard = NULL; + xwl_seat->wl_keyboard = NULL; + + if (xwl_seat->keyboard) + DisableDevice(xwl_seat->keyboard, TRUE); } xwl_seat->xwl_screen->expecting_event--; -- cgit v1.2.3