Commit e7fd068a authored by Jonas Ådahl's avatar Jonas Ådahl Committed by Georges Basile Stavracas Neto

monitor-manager/kms: Use 'hotplug' event from MetaUdev

Instead of dealing with udev details here, use the newly added 'hotplug'
event emitted from MetaUdev.

#548
!525
parent 171e5fc3
......@@ -86,6 +86,7 @@ struct _MetaMonitorManagerKms
GUdevClient *udev;
guint uevent_handler_id;
guint hotplug_handler_id;
};
struct _MetaMonitorManagerKmsClass
......@@ -444,6 +445,35 @@ handle_gpu_hotplug (MetaMonitorManagerKms *manager_kms,
g_signal_emit (manager_kms, signals[GPU_ADDED], 0, gpu_kms);
}
static void
on_udev_hotplug (MetaUdev *udev,
MetaMonitorManager *manager)
{
handle_hotplug_event (manager);
}
static void
meta_monitor_manager_kms_connect_hotplug_handler (MetaMonitorManagerKms *manager_kms)
{
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 (udev, "hotplug", G_CALLBACK (on_udev_hotplug), manager);
}
static void
meta_monitor_manager_kms_disconnect_hotplug_handler (MetaMonitorManagerKms *manager_kms)
{
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));
g_signal_handler_disconnect (udev, manager_kms->hotplug_handler_id);
manager_kms->hotplug_handler_id = 0;
}
static void
on_uevent (GUdevClient *client,
const char *action,
......@@ -471,11 +501,6 @@ on_uevent (GUdevClient *client,
if (!g_strcmp0 (seat_id, device_seat))
handle_gpu_hotplug (manager_kms, device);
}
if (!g_udev_device_get_property_as_boolean (device, "HOTPLUG"))
return;
handle_hotplug_event (manager);
}
static void
......@@ -499,6 +524,7 @@ void
meta_monitor_manager_kms_pause (MetaMonitorManagerKms *manager_kms)
{
meta_monitor_manager_kms_disconnect_uevent_handler (manager_kms);
meta_monitor_manager_kms_disconnect_hotplug_handler (manager_kms);
}
void
......@@ -507,6 +533,7 @@ meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms)
MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
meta_monitor_manager_kms_connect_hotplug_handler (manager_kms);
handle_hotplug_event (manager);
}
......@@ -713,6 +740,7 @@ meta_monitor_manager_kms_initable_init (GInitable *initable,
manager_kms->udev = g_udev_client_new (subsystems);
meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
meta_monitor_manager_kms_connect_hotplug_handler (manager_kms);
if (!init_gpus (manager_kms, error))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment