backends/native: Emit signals for virtual devices

When creating a virtual device for the native backend, no "device-added"
is emitted.

Similarly, no "device-removed" signal is emitted either when the virtual
device is disposed.

However, the backend plugs into the "device-added" signal to set the
monitor device. Without the "device-added" signal being emitted, the
monitor associated with a virtual device remains NULL.

That later will cause a crash in `meta_idle_monitor_reset_idlettime()`
called from `handle_idletime_for_event()` when processing events from a
virtual device because the device monitor is NULL.

Make sure to emit the "device-added" signal when creating a virtual
device, and the "device-removed" when the virtual device is disposed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1037
This commit is contained in:
Olivier Fourdan 2020-02-04 18:06:29 +01:00
parent aa0aa89a1e
commit 9b0392e988

View File

@ -644,6 +644,10 @@ meta_virtual_input_device_native_constructed (GObject *object)
stage = meta_seat_native_get_stage (virtual_evdev->seat);
_clutter_input_device_set_stage (virtual_evdev->device, stage);
g_signal_emit_by_name (virtual_evdev->seat,
"device-added",
virtual_evdev->device);
}
static void
@ -656,6 +660,10 @@ meta_virtual_input_device_native_finalize (GObject *object)
GObjectClass *object_class;
release_pressed_buttons (virtual_device);
g_signal_emit_by_name (virtual_evdev->seat,
"device-removed",
virtual_evdev->device);
g_clear_object (&virtual_evdev->device);
object_class =