[mutter] backends/native: Ignore udev events while we're paused
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] backends/native: Ignore udev events while we're paused
- Date: Mon, 20 Sep 2021 16:07:16 +0000 (UTC)
commit cbfb59b828dbd095b27d44e88fc77ac024fdea74
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Mon Mar 22 17:44:11 2021 +0100
backends/native: Ignore udev events while we're paused
When the native backend is paused we still process the udev events
even though this isn't needed and may just cause unneeded events to be
triggered afterwards.
Since we'll resume with full changes on such event, we can just block
the signal hander when paused and restore it afterwards.
As per this we can cleanup also a bit the device adding signal handling
given that now we don't have to disconnect/reconnect it again.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
src/backends/native/meta-backend-native.c | 35 +++++--------------------------
src/backends/native/meta-udev.c | 12 +++++++++++
src/backends/native/meta-udev.h | 4 ++++
3 files changed, 21 insertions(+), 30 deletions(-)
---
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index 81d9629d05..2cc9add75d 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -87,8 +87,6 @@ struct _MetaBackendNative
MetaKms *kms;
gboolean is_headless;
-
- gulong udev_device_added_handler_id;
};
static GInitableIface *initable_parent_iface;
@@ -100,20 +98,11 @@ G_DEFINE_TYPE_WITH_CODE (MetaBackendNative, meta_backend_native, META_TYPE_BACKE
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
initable_iface_init))
-static void
-disconnect_udev_device_added_handler (MetaBackendNative *native);
-
static void
meta_backend_native_dispose (GObject *object)
{
MetaBackendNative *native = META_BACKEND_NATIVE (object);
- if (native->udev_device_added_handler_id)
- {
- disconnect_udev_device_added_handler (native);
- native->udev_device_added_handler_id = 0;
- }
-
if (native->kms)
meta_kms_prepare_shutdown (native->kms);
@@ -485,20 +474,6 @@ on_udev_device_added (MetaUdev *udev,
meta_backend_add_gpu (backend, META_GPU (new_gpu_kms));
}
-static void
-connect_udev_device_added_handler (MetaBackendNative *native)
-{
- native->udev_device_added_handler_id =
- g_signal_connect (native->udev, "device-added",
- G_CALLBACK (on_udev_device_added), native);
-}
-
-static void
-disconnect_udev_device_added_handler (MetaBackendNative *native)
-{
- g_clear_signal_handler (&native->udev_device_added_handler_id, native->udev);
-}
-
static gboolean
init_gpus (MetaBackendNative *native,
GError **error)
@@ -549,7 +524,9 @@ init_gpus (MetaBackendNative *native,
return FALSE;
}
- connect_udev_device_added_handler (native);
+ g_signal_connect_object (native->udev, "device-added",
+ G_CALLBACK (on_udev_device_added), native,
+ 0);
return TRUE;
}
@@ -724,8 +701,7 @@ meta_backend_native_pause (MetaBackendNative *native)
meta_seat_native_release_devices (seat);
meta_renderer_pause (renderer);
-
- disconnect_udev_device_added_handler (native);
+ meta_udev_pause (native->udev);
meta_monitor_manager_native_pause (monitor_manager_native);
}
@@ -749,10 +725,9 @@ void meta_backend_native_resume (MetaBackendNative *native)
"Backend (resume)");
meta_monitor_manager_native_resume (monitor_manager_native);
+ meta_udev_resume (native->udev);
meta_kms_resume (native->kms);
- connect_udev_device_added_handler (native);
-
meta_seat_native_reclaim_devices (seat);
meta_renderer_resume (renderer);
diff --git a/src/backends/native/meta-udev.c b/src/backends/native/meta-udev.c
index c0e0e165fd..16c44dc138 100644
--- a/src/backends/native/meta-udev.c
+++ b/src/backends/native/meta-udev.c
@@ -222,6 +222,18 @@ meta_udev_new (MetaBackendNative *backend_native)
return udev;
}
+void
+meta_udev_pause (MetaUdev *udev)
+{
+ g_signal_handler_block (udev->gudev_client, udev->uevent_handler_id);
+}
+
+void
+meta_udev_resume (MetaUdev *udev)
+{
+ g_signal_handler_unblock (udev->gudev_client, udev->uevent_handler_id);
+}
+
static void
meta_udev_finalize (GObject *object)
{
diff --git a/src/backends/native/meta-udev.h b/src/backends/native/meta-udev.h
index 7b179329eb..4d85c8f041 100644
--- a/src/backends/native/meta-udev.h
+++ b/src/backends/native/meta-udev.h
@@ -44,6 +44,10 @@ gboolean meta_udev_is_drm_device (MetaUdev *udev,
GList * meta_udev_list_drm_devices (MetaUdev *udev,
GError **error);
+void meta_udev_pause (MetaUdev *udev);
+
+void meta_udev_resume (MetaUdev *udev);
+
MetaUdev * meta_udev_new (MetaBackendNative *backend_native);
#endif /* META_UDEV_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]