1
0
Fork 0

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
This commit is contained in:
Jonas Ådahl 2019-08-22 15:15:51 +02:00
parent 4cf828323d
commit 5111e33948
2 changed files with 30 additions and 24 deletions

View file

@ -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);
}

View file

@ -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));
MetaBackendNative *backend_native = META_BACKEND_NATIVE (backend);
MetaKms *kms = meta_backend_native_get_kms (backend_native);
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);
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