gdk/wayland: Prefer wl_output_release() over wl_output_destroy()
authorVlad Zahorodnii <vlad.zahorodnii@kde.org>
Tue, 22 Nov 2022 10:04:12 +0000 (12:04 +0200)
committerVlad Zahorodnii <vlad.zahorodnii@kde.org>
Tue, 22 Nov 2022 12:12:22 +0000 (14:12 +0200)
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
gdk/wayland/gdkmonitor-wayland.c

index a848a45b6db5c4486b35ea60481b21f9809920b7..bfda69ce822b6ad49cc1429e0926951708bb1941 100644 (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)
index b4523e016e3b0658ca97900c9fffa677b441a807..3db7810f266b0c6de66f3a571fc97e42b1361243 100644 (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);
 }