[mutter] backends/native: Emit signals for virtual devices



commit 9b0392e9882a820fd97101d0df1bf1a96471cc02
Author: Olivier Fourdan <ofourdan redhat com>
Date:   Tue Feb 4 18:06:29 2020 +0100

    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

 src/backends/native/meta-virtual-input-device-native.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/backends/native/meta-virtual-input-device-native.c 
b/src/backends/native/meta-virtual-input-device-native.c
index 829570b03..d3214e224 100644
--- a/src/backends/native/meta-virtual-input-device-native.c
+++ b/src/backends/native/meta-virtual-input-device-native.c
@@ -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 =


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]