[gtk/wip/carlosg/for-master] gdk/wayland: Update to gtk_shell1 version 3




commit 745cbc6c9158a6dc3cc675262b78c61535a79362
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Nov 18 00:38:15 2020 +0100

    gdk/wayland: Update to gtk_shell1 version 3
    
    Bring in line with gtk3, in terms of startup notification and
    activation support.

 gdk/wayland/gdkapplaunchcontext-wayland.c | 15 ++++++++++++++-
 gdk/wayland/gdkdisplay-wayland.c          |  2 +-
 gdk/wayland/gdksurface-wayland.c          | 18 ++++++++++++------
 gdk/wayland/protocol/gtk-shell.xml        | 14 ++++++++++++--
 4 files changed, 39 insertions(+), 10 deletions(-)
---
diff --git a/gdk/wayland/gdkapplaunchcontext-wayland.c b/gdk/wayland/gdkapplaunchcontext-wayland.c
index cb6cf9a12b..ed9e69b0eb 100644
--- a/gdk/wayland/gdkapplaunchcontext-wayland.c
+++ b/gdk/wayland/gdkapplaunchcontext-wayland.c
@@ -34,7 +34,20 @@ gdk_wayland_app_launch_context_get_startup_notify_id (GAppLaunchContext *context
                                                       GAppInfo          *info,
                                                       GList             *files)
 {
-  return NULL;
+  GdkWaylandDisplay *display;
+  gchar *id = NULL;
+
+  g_object_get (context, "display", &display, NULL);
+
+  if (display->gtk_shell_version >= 3)
+    {
+      id = g_uuid_string_random ();
+      gtk_shell1_notify_launch (display->gtk_shell, id);
+    }
+
+  g_object_unref (display);
+
+  return id;
 }
 
 static void
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 0e3cc00b75..39799e2762 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -94,7 +94,7 @@
 
 #define MIN_SYSTEM_BELL_DELAY_MS 20
 
-#define GTK_SHELL1_VERSION       2
+#define GTK_SHELL1_VERSION       3
 #define OUTPUT_VERSION_WITH_DONE 2
 #define NO_XDG_OUTPUT_DONE_SINCE_VERSION 3
 
diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c
index 73c59779ff..3e58937a89 100644
--- a/gdk/wayland/gdksurface-wayland.c
+++ b/gdk/wayland/gdksurface-wayland.c
@@ -3232,14 +3232,20 @@ gdk_wayland_surface_focus (GdkSurface *surface,
   if (!impl->display_server.gtk_surface)
     return;
 
-  /* We didn't have an event to fetch a time from, meaning we have nothing valid
-   * to send. This should rather be translated to a 'needs-attention' request or
-   * something.
-   */
   if (timestamp == GDK_CURRENT_TIME)
-    return;
+    {
+      GdkWaylandDisplay *display_wayland =
+        GDK_WAYLAND_DISPLAY (gdk_surface_get_display (surface));
 
-  gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
+      if (display_wayland->gtk_shell_version >= 3)
+        {
+          gtk_surface1_request_focus (impl->display_server.gtk_surface,
+                                      display_wayland->startup_notification_id);
+          g_clear_pointer (&display_wayland->startup_notification_id, g_free);
+        }
+    }
+  else
+    gtk_surface1_present (impl->display_server.gtk_surface, timestamp);
 }
 
 static void
diff --git a/gdk/wayland/protocol/gtk-shell.xml b/gdk/wayland/protocol/gtk-shell.xml
index 8191fa9cfb..fb91940b30 100644
--- a/gdk/wayland/protocol/gtk-shell.xml
+++ b/gdk/wayland/protocol/gtk-shell.xml
@@ -1,6 +1,6 @@
 <protocol name="gtk">
 
-  <interface name="gtk_shell1" version="2">
+  <interface name="gtk_shell1" version="3">
     <description summary="gtk specific extensions">
       gtk_shell is a protocol extension providing additional features for
       clients implementing it.
@@ -28,9 +28,14 @@
     <request name="system_bell">
       <arg name="surface" type="object" interface="gtk_surface1" allow-null="true"/>
     </request>
+
+    <!-- Version 3 additions -->
+    <request name="notify_launch" since="3">
+      <arg name="startup_id" type="string"/>
+    </request>
   </interface>
 
-  <interface name="gtk_surface1" version="2">
+  <interface name="gtk_surface1" version="3">
     <request name="set_dbus_properties">
       <arg name="application_id" type="string" allow-null="true"/>
       <arg name="app_menu_path" type="string" allow-null="true"/>
@@ -72,6 +77,11 @@
     <event name="configure_edges" since="2">
       <arg name="constraints" type="array"/>
     </event>
+
+    <!-- Version 3 additions -->
+    <request name="request_focus" since="3">
+      <arg name="startup_id" type="string" allow-null="true"/>
+    </request>
   </interface>
 
 </protocol>


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