wayland/output: Remove wl_output global when making it inert
This will make clients immediately aware of the output disappearing, while still allowing for a grace period of 10 seconds for attempting to bind to it before it turning into a protocol error. This API added as part of wayland 1.18. This requires us to not add the output resource to the output resource list, if the output was made inert. This effectively makes the resource useless, but that is harmless, since shortly after, the client will clean it up anyway. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
This commit is contained in:
parent
257ccf5e80
commit
c0bc821f62
1 changed files with 10 additions and 9 deletions
|
@ -312,15 +312,16 @@ bind_output (struct wl_client *client,
|
|||
#endif
|
||||
|
||||
resource = wl_resource_create (client, &wl_output_interface, version, id);
|
||||
wayland_output->resources = g_list_prepend (wayland_output->resources, resource);
|
||||
|
||||
wl_resource_set_user_data (resource, wayland_output);
|
||||
wl_resource_set_destructor (resource, output_resource_destroy);
|
||||
|
||||
monitor = wayland_output->monitor;
|
||||
if (!monitor)
|
||||
return;
|
||||
|
||||
wayland_output->resources = g_list_prepend (wayland_output->resources,
|
||||
resource);
|
||||
wl_resource_set_user_data (resource, wayland_output);
|
||||
wl_resource_set_destructor (resource, output_resource_destroy);
|
||||
|
||||
#ifdef WITH_VERBOSE_MODE
|
||||
logical_monitor = meta_monitor_get_logical_monitor (monitor);
|
||||
meta_verbose ("Binding monitor %p/%s (%u, %u, %u, %u) x %f",
|
||||
|
@ -430,6 +431,8 @@ make_output_resources_inert (MetaWaylandOutput *wayland_output)
|
|||
{
|
||||
GList *l;
|
||||
|
||||
wl_global_remove (wayland_output->global);
|
||||
|
||||
for (l = wayland_output->resources; l; l = l->next)
|
||||
{
|
||||
struct wl_resource *output_resource = l->data;
|
||||
|
@ -531,12 +534,10 @@ meta_wayland_output_finalize (GObject *object)
|
|||
{
|
||||
MetaWaylandOutput *wayland_output = META_WAYLAND_OUTPUT (object);
|
||||
|
||||
wl_global_destroy (wayland_output->global);
|
||||
g_warn_if_fail (!wayland_output->resources);
|
||||
g_warn_if_fail (!wayland_output->xdg_output_resources);
|
||||
|
||||
/* Make sure the wl_output destructor doesn't try to access MetaWaylandOutput
|
||||
* after we have freed it.
|
||||
*/
|
||||
make_output_resources_inert (wayland_output);
|
||||
wl_global_destroy (wayland_output->global);
|
||||
|
||||
G_OBJECT_CLASS (meta_wayland_output_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue