[mutter] wayland/gtk-shell: Add an explicit gtk-shell surface release request



commit c9aa43aa7a40bb0a74c9d98836599825441fc154
Author: Sebastian Keller <skeller gnome org>
Date:   Tue Jun 9 04:22:31 2020 +0200

    wayland/gtk-shell: Add an explicit gtk-shell surface release request
    
    Previously the wl_resource and MetaWaylandGtkSurface corresponding to
    any client gtk_surface have been kept around until the exit of the
    client due to the client side destroy method not signaling the
    destruction to the server. Ideally the protocol would have specified a
    destroy request marked as destructor to handle this automatically,
    however this is no longer possible due to the destroy method being
    implicitly generated in the absence of an explicit request in the
    protocol. Adding a destroy request marked as destructor now would
    generate a new destroy method that unconditionally would send the
    request to the server, which would break clients running on servers not
    supporting that request.
    
    So instead of modifying the destroy request add a new "release"
    destructor, that indicates to the server that it can release the
    resource. This can be optionally be used by clients depending on the
    server protocol version.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>

 src/wayland/meta-wayland-gtk-shell.c | 8 ++++++++
 src/wayland/meta-wayland-versions.h  | 2 +-
 src/wayland/protocol/gtk-shell.xml   | 7 +++++--
 3 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/wayland/meta-wayland-gtk-shell.c b/src/wayland/meta-wayland-gtk-shell.c
index 1fc74787b9..12e1b0e4a9 100644
--- a/src/wayland/meta-wayland-gtk-shell.c
+++ b/src/wayland/meta-wayland-gtk-shell.c
@@ -208,12 +208,20 @@ gtk_surface_request_focus (struct wl_client   *client,
     }
 }
 
+static void
+gtk_surface_release (struct wl_client   *client,
+                     struct wl_resource *resource)
+{
+  wl_resource_destroy (resource);
+}
+
 static const struct gtk_surface1_interface meta_wayland_gtk_surface_interface = {
   gtk_surface_set_dbus_properties,
   gtk_surface_set_modal,
   gtk_surface_unset_modal,
   gtk_surface_present,
   gtk_surface_request_focus,
+  gtk_surface_release
 };
 
 static void
diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h
index 7a750413f1..bf891d99a1 100644
--- a/src/wayland/meta-wayland-versions.h
+++ b/src/wayland/meta-wayland-versions.h
@@ -43,7 +43,7 @@
 #define META_WL_SEAT_VERSION                5
 #define META_WL_OUTPUT_VERSION              2
 #define META_XSERVER_VERSION                1
-#define META_GTK_SHELL1_VERSION             3
+#define META_GTK_SHELL1_VERSION             4
 #define META_WL_SUBCOMPOSITOR_VERSION       1
 #define META_ZWP_POINTER_GESTURES_V1_VERSION    1
 #define META_ZXDG_EXPORTER_V1_VERSION       1
diff --git a/src/wayland/protocol/gtk-shell.xml b/src/wayland/protocol/gtk-shell.xml
index fb91940b30..1aab593c42 100644
--- a/src/wayland/protocol/gtk-shell.xml
+++ b/src/wayland/protocol/gtk-shell.xml
@@ -1,6 +1,6 @@
 <protocol name="gtk">
 
-  <interface name="gtk_shell1" version="3">
+  <interface name="gtk_shell1" version="4">
     <description summary="gtk specific extensions">
       gtk_shell is a protocol extension providing additional features for
       clients implementing it.
@@ -35,7 +35,7 @@
     </request>
   </interface>
 
-  <interface name="gtk_surface1" version="3">
+  <interface name="gtk_surface1" version="4">
     <request name="set_dbus_properties">
       <arg name="application_id" type="string" allow-null="true"/>
       <arg name="app_menu_path" type="string" allow-null="true"/>
@@ -82,6 +82,9 @@
     <request name="request_focus" since="3">
       <arg name="startup_id" type="string" allow-null="true"/>
     </request>
+
+    <!-- Version 4 additions -->
+    <request name="release" type="destructor" since="4"/>
   </interface>
 
 </protocol>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]