mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 07:30:42 -05:00
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>
This commit is contained in:
parent
9cb35e2c80
commit
cbfb59b828
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user