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;
|
MetaKms *kms;
|
||||||
|
|
||||||
gboolean is_headless;
|
gboolean is_headless;
|
||||||
|
|
||||||
gulong udev_device_added_handler_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static GInitableIface *initable_parent_iface;
|
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,
|
G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE,
|
||||||
initable_iface_init))
|
initable_iface_init))
|
||||||
|
|
||||||
static void
|
|
||||||
disconnect_udev_device_added_handler (MetaBackendNative *native);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_backend_native_dispose (GObject *object)
|
meta_backend_native_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
MetaBackendNative *native = META_BACKEND_NATIVE (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)
|
if (native->kms)
|
||||||
meta_kms_prepare_shutdown (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));
|
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
|
static gboolean
|
||||||
init_gpus (MetaBackendNative *native,
|
init_gpus (MetaBackendNative *native,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -549,7 +524,9 @@ init_gpus (MetaBackendNative *native,
|
|||||||
return FALSE;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -724,8 +701,7 @@ meta_backend_native_pause (MetaBackendNative *native)
|
|||||||
|
|
||||||
meta_seat_native_release_devices (seat);
|
meta_seat_native_release_devices (seat);
|
||||||
meta_renderer_pause (renderer);
|
meta_renderer_pause (renderer);
|
||||||
|
meta_udev_pause (native->udev);
|
||||||
disconnect_udev_device_added_handler (native);
|
|
||||||
|
|
||||||
meta_monitor_manager_native_pause (monitor_manager_native);
|
meta_monitor_manager_native_pause (monitor_manager_native);
|
||||||
}
|
}
|
||||||
@ -749,10 +725,9 @@ void meta_backend_native_resume (MetaBackendNative *native)
|
|||||||
"Backend (resume)");
|
"Backend (resume)");
|
||||||
|
|
||||||
meta_monitor_manager_native_resume (monitor_manager_native);
|
meta_monitor_manager_native_resume (monitor_manager_native);
|
||||||
|
meta_udev_resume (native->udev);
|
||||||
meta_kms_resume (native->kms);
|
meta_kms_resume (native->kms);
|
||||||
|
|
||||||
connect_udev_device_added_handler (native);
|
|
||||||
|
|
||||||
meta_seat_native_reclaim_devices (seat);
|
meta_seat_native_reclaim_devices (seat);
|
||||||
meta_renderer_resume (renderer);
|
meta_renderer_resume (renderer);
|
||||||
|
|
||||||
|
@ -222,6 +222,18 @@ meta_udev_new (MetaBackendNative *backend_native)
|
|||||||
return udev;
|
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
|
static void
|
||||||
meta_udev_finalize (GObject *object)
|
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,
|
GList * meta_udev_list_drm_devices (MetaUdev *udev,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void meta_udev_pause (MetaUdev *udev);
|
||||||
|
|
||||||
|
void meta_udev_resume (MetaUdev *udev);
|
||||||
|
|
||||||
MetaUdev * meta_udev_new (MetaBackendNative *backend_native);
|
MetaUdev * meta_udev_new (MetaBackendNative *backend_native);
|
||||||
|
|
||||||
#endif /* META_UDEV_H */
|
#endif /* META_UDEV_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user