[mutter/wip/kms-connector-add-remove: 3/3] monitor-manager/kms: Get hotplug events from MetaKms
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/kms-connector-add-remove: 3/3] monitor-manager/kms: Get hotplug events from MetaKms
- Date: Tue, 3 Sep 2019 17:18:11 +0000 (UTC)
commit 9582f7b207a77c431771c52aa9481d14e172ffbc
Author: Jonas Ådahl <jadahl gmail com>
Date: Thu Aug 22 15:15:51 2019 +0200
monitor-manager/kms: Get hotplug events from MetaKms
This makes it clearer that MetaMonitorManagerKms keeps updated as
MetaKms updates its state.
https://gitlab.gnome.org/GNOME/mutter/merge_requests/743
src/backends/native/meta-kms.c | 19 +++++++++++++
src/backends/native/meta-monitor-manager-kms.c | 37 +++++++++-----------------
2 files changed, 31 insertions(+), 25 deletions(-)
---
diff --git a/src/backends/native/meta-kms.c b/src/backends/native/meta-kms.c
index 8397f872e..39d1f3155 100644
--- a/src/backends/native/meta-kms.c
+++ b/src/backends/native/meta-kms.c
@@ -119,6 +119,15 @@
*
*/
+enum
+{
+ RESOURCES_CHANGED,
+
+ N_SIGNALS
+};
+
+static int signals[N_SIGNALS];
+
typedef struct _MetaKmsCallbackData
{
MetaKmsCallback callback;
@@ -503,6 +512,8 @@ handle_hotplug_event (MetaKms *kms)
META_KMS_UPDATE_STATES_FLAG_HOTPLUG,
&error))
g_warning ("Updating KMS state failed: %s", error->message);
+
+ g_signal_emit (kms, signals[RESOURCES_CHANGED], 0);
}
static void
@@ -605,4 +616,12 @@ meta_kms_class_init (MetaKmsClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = meta_kms_finalize;
+
+ signals[RESOURCES_CHANGED] =
+ g_signal_new ("resources-changed",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
index 26c2ddb61..389f3f9a9 100644
--- a/src/backends/native/meta-monitor-manager-kms.c
+++ b/src/backends/native/meta-monitor-manager-kms.c
@@ -75,8 +75,7 @@ struct _MetaMonitorManagerKms
{
MetaMonitorManager parent_instance;
- guint hotplug_handler_id;
- guint removed_handler_id;
+ gulong kms_resources_changed_handler_id;
};
struct _MetaMonitorManagerKmsClass
@@ -479,16 +478,8 @@ handle_hotplug_event (MetaMonitorManager *manager)
}
static void
-on_udev_hotplug (MetaUdev *udev,
- MetaMonitorManager *manager)
-{
- handle_hotplug_event (manager);
-}
-
-static void
-on_udev_device_removed (MetaUdev *udev,
- GUdevDevice *device,
- MetaMonitorManager *manager)
+on_kms_resources_changed (MetaKms *kms,
+ MetaMonitorManager *manager)
{
handle_hotplug_event (manager);
}
@@ -498,14 +489,12 @@ meta_monitor_manager_kms_connect_hotplug_handler (MetaMonitorManagerKms *manager
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
- MetaUdev *udev = meta_backend_native_get_udev (META_BACKEND_NATIVE (backend));
-
- manager_kms->hotplug_handler_id =
- g_signal_connect_after (udev, "hotplug",
- G_CALLBACK (on_udev_hotplug), manager);
- manager_kms->removed_handler_id =
- g_signal_connect_after (udev, "device-removed",
- G_CALLBACK (on_udev_device_removed), manager);
+ MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
+ MetaKms *kms = meta_backend_native_get_kms (backend_native);
+
+ manager_kms->kms_resources_changed_handler_id =
+ g_signal_connect (kms, "resources-changed",
+ G_CALLBACK (on_kms_resources_changed), manager);
}
static void
@@ -513,12 +502,10 @@ meta_monitor_manager_kms_disconnect_hotplug_handler (MetaMonitorManagerKms *mana
{
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
- MetaUdev *udev = meta_backend_native_get_udev (META_BACKEND_NATIVE (backend));
+ MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
+ MetaKms *kms = meta_backend_native_get_kms (backend_native);
- g_signal_handler_disconnect (udev, manager_kms->hotplug_handler_id);
- manager_kms->hotplug_handler_id = 0;
- g_signal_handler_disconnect (udev, manager_kms->removed_handler_id);
- manager_kms->removed_handler_id = 0;
+ g_clear_signal_handler (&manager_kms->kms_resources_changed_handler_id, kms);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]