summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2014-07-22 17:55:25 +0200
committerKeith Packard <keithp@keithp.com>2014-07-24 16:52:41 -0700
commit2172714c67d8701aa54c202e89f246f1dddac80a (patch)
tree796c60b31a1ce65d17603835506da5fd047bd8ab
parent556cdf8fe870bc23e0393c0eed15c86f49a0b9f8 (diff)
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 <carlosg@gnome.org> Reviewed-by: Daniel Stone <daniel@fooishbar.org> Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--hw/xwayland/xwayland-input.c42
1 files 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--;