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:
parent
4cf828323d
commit
5111e33948
@ -119,6 +119,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RESOURCES_CHANGED,
|
||||||
|
|
||||||
|
N_SIGNALS
|
||||||
|
};
|
||||||
|
|
||||||
|
static int signals[N_SIGNALS];
|
||||||
|
|
||||||
typedef struct _MetaKmsCallbackData
|
typedef struct _MetaKmsCallbackData
|
||||||
{
|
{
|
||||||
MetaKmsCallback callback;
|
MetaKmsCallback callback;
|
||||||
@ -503,6 +512,8 @@ handle_hotplug_event (MetaKms *kms)
|
|||||||
META_KMS_UPDATE_STATES_FLAG_HOTPLUG,
|
META_KMS_UPDATE_STATES_FLAG_HOTPLUG,
|
||||||
&error))
|
&error))
|
||||||
g_warning ("Updating KMS state failed: %s", error->message);
|
g_warning ("Updating KMS state failed: %s", error->message);
|
||||||
|
|
||||||
|
g_signal_emit (kms, signals[RESOURCES_CHANGED], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -605,4 +616,12 @@ meta_kms_class_init (MetaKmsClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = meta_kms_finalize;
|
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);
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,7 @@ struct _MetaMonitorManagerKms
|
|||||||
{
|
{
|
||||||
MetaMonitorManager parent_instance;
|
MetaMonitorManager parent_instance;
|
||||||
|
|
||||||
guint hotplug_handler_id;
|
gulong kms_resources_changed_handler_id;
|
||||||
guint removed_handler_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MetaMonitorManagerKmsClass
|
struct _MetaMonitorManagerKmsClass
|
||||||
@ -479,15 +478,7 @@ handle_hotplug_event (MetaMonitorManager *manager)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_udev_hotplug (MetaUdev *udev,
|
on_kms_resources_changed (MetaKms *kms,
|
||||||
MetaMonitorManager *manager)
|
|
||||||
{
|
|
||||||
handle_hotplug_event (manager);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
on_udev_device_removed (MetaUdev *udev,
|
|
||||||
GUdevDevice *device,
|
|
||||||
MetaMonitorManager *manager)
|
MetaMonitorManager *manager)
|
||||||
{
|
{
|
||||||
handle_hotplug_event (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);
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
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 =
|
manager_kms->kms_resources_changed_handler_id =
|
||||||
g_signal_connect_after (udev, "hotplug",
|
g_signal_connect (kms, "resources-changed",
|
||||||
G_CALLBACK (on_udev_hotplug), manager);
|
G_CALLBACK (on_kms_resources_changed), manager);
|
||||||
manager_kms->removed_handler_id =
|
|
||||||
g_signal_connect_after (udev, "device-removed",
|
|
||||||
G_CALLBACK (on_udev_device_removed), manager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -513,12 +502,10 @@ meta_monitor_manager_kms_disconnect_hotplug_handler (MetaMonitorManagerKms *mana
|
|||||||
{
|
{
|
||||||
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
|
||||||
MetaBackend *backend = meta_monitor_manager_get_backend (manager);
|
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);
|
g_clear_signal_handler (&manager_kms->kms_resources_changed_handler_id, kms);
|
||||||
manager_kms->hotplug_handler_id = 0;
|
|
||||||
g_signal_handler_disconnect (udev, manager_kms->removed_handler_id);
|
|
||||||
manager_kms->removed_handler_id = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user