From 261bcd40bd0f5f66f3eeb7fa97df14c8c3dccbd6 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 22 Nov 2022 12:04:12 +0200 Subject: [PATCH] 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. --- gdk/wayland/gdkdisplay-wayland.c | 4 ++-- gdk/wayland/gdkmonitor-wayland.c | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index a848a45b6d..bfda69ce82 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -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) diff --git a/gdk/wayland/gdkmonitor-wayland.c b/gdk/wayland/gdkmonitor-wayland.c index b4523e016e..3db7810f26 100644 --- a/gdk/wayland/gdkmonitor-wayland.c +++ b/gdk/wayland/gdkmonitor-wayland.c @@ -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); } -- 2.30.2