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>
This commit is contained in:
parent
556cdf8fe8
commit
2172714c67
|
@ -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);
|
||||
|
||||
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->pointer) {
|
||||
} 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);
|
||||
|
||||
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->keyboard) {
|
||||
} 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--;
|
||||
|
|
Loading…
Reference in New Issue