From 6792903c4f492c31cfcd8b9f0dd6ca0d7c8bef1d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 2 Aug 2019 22:41:00 +0200 Subject: [PATCH] udev: Add device-removed signal Add a device-removed signal which gets emitted when a GPU is removed. https://gitlab.gnome.org/GNOME/mutter/merge_requests/713 --- src/backends/native/meta-udev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/backends/native/meta-udev.c b/src/backends/native/meta-udev.c index 719466131..7c8080a56 100644 --- a/src/backends/native/meta-udev.c +++ b/src/backends/native/meta-udev.c @@ -31,6 +31,7 @@ enum { HOTPLUG, DEVICE_ADDED, + DEVICE_REMOVED, N_SIGNALS }; @@ -163,6 +164,8 @@ on_uevent (GUdevClient *client, if (g_str_equal (action, "add")) g_signal_emit (udev, signals[DEVICE_ADDED], 0, device); + else if (g_str_equal (action, "remove")) + g_signal_emit (udev, signals[DEVICE_REMOVED], 0, device); if (g_udev_device_get_property_as_boolean (device, "HOTPLUG")) g_signal_emit (udev, signals[HOTPLUG], 0); @@ -221,4 +224,11 @@ meta_udev_class_init (MetaUdevClass *klass) 0, NULL, NULL, NULL, G_TYPE_NONE, 1, G_UDEV_TYPE_DEVICE); + signals[DEVICE_REMOVED] = + g_signal_new ("device-removed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, + G_UDEV_TYPE_DEVICE); }