gdk/wayland: Prefer wl_output_release() over wl_output_destroy()

By using wl_output_release(), GDK lets the compositor to clean up the
output global more nicely.

For example, currently, most compositors remove the global and then
destroy it later after N seconds expire. With this, the compositor could
experiment with destroying the output global once all its resources are
destroyed.
This commit is contained in:
Vlad Zahorodnii 2022-11-22 12:04:12 +02:00
parent 200f31f285
commit 261bcd40bd
2 changed files with 7 additions and 3 deletions

View File

@ -397,8 +397,8 @@ gdk_registry_handle_global (void *data,
else if (strcmp (interface, "wl_output") == 0)
{
output =
wl_registry_bind (display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 2));
gdk_wayland_display_add_output (display_wayland, id, output, MIN (version, 2));
wl_registry_bind (display_wayland->wl_registry, id, &wl_output_interface, MIN (version, 3));
gdk_wayland_display_add_output (display_wayland, id, output, MIN (version, 3));
_gdk_wayland_display_async_roundtrip (display_wayland);
}
else if (strcmp (interface, "wl_seat") == 0)

View File

@ -48,7 +48,11 @@ gdk_wayland_monitor_finalize (GObject *object)
g_free (monitor->name);
g_clear_pointer (&monitor->xdg_output, zxdg_output_v1_destroy);
g_clear_pointer (&monitor->output, wl_output_destroy);
if (wl_output_get_version (monitor->output) >= WL_OUTPUT_RELEASE_SINCE_VERSION)
g_clear_pointer (&monitor->output, wl_output_release);
else
g_clear_pointer (&monitor->output, wl_output_destroy);
G_OBJECT_CLASS (gdk_wayland_monitor_parent_class)->finalize (object);
}