remote-desktop-session: Don't recreate virtual device over and over

In 'remote-desktop-session: Create virtual input devices on demand' the
intention was to create input devices on-demand, but during a
refactorization of the code, instead the virtual input device was
recreated over and over. Lets fix that.

Fixes: a0af52caf0
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1799
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1858>
This commit is contained in:
Jonas Ådahl 2021-05-07 15:01:44 +02:00 committed by Marge Bot
parent 2f651c337e
commit a49dc78396

View File

@ -153,24 +153,29 @@ ensure_virtual_device (MetaRemoteDesktopSession *session,
MetaBackend *backend = meta_remote_desktop_get_backend (remote_desktop);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
ClutterVirtualInputDevice **virtual_device_ptr = NULL;
switch (device_type)
{
case CLUTTER_POINTER_DEVICE:
session->virtual_pointer =
clutter_seat_create_virtual_device (seat, CLUTTER_POINTER_DEVICE);
virtual_device_ptr = &session->virtual_pointer;
break;
case CLUTTER_KEYBOARD_DEVICE:
session->virtual_keyboard =
clutter_seat_create_virtual_device (seat, CLUTTER_KEYBOARD_DEVICE);
virtual_device_ptr = &session->virtual_keyboard;
break;
case CLUTTER_TOUCHSCREEN_DEVICE:
session->virtual_touchscreen =
clutter_seat_create_virtual_device (seat, CLUTTER_TOUCHSCREEN_DEVICE);
virtual_device_ptr = &session->virtual_touchscreen;
break;
default:
g_assert_not_reached ();
}
g_assert (virtual_device_ptr);
if (*virtual_device_ptr)
return;
*virtual_device_ptr = clutter_seat_create_virtual_device (seat, device_type);
}
static gboolean