wayland: Fix handling of activation-token in org.freedesktop.Application requests
authorVlad Zahorodnii <vlad.zahorodnii@kde.org>
Thu, 20 Oct 2022 16:33:15 +0000 (19:33 +0300)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 27 Jan 2023 19:20:53 +0000 (19:20 +0000)
At the moment, GTK applications search for "desktop-startup-id" in the
platform data on Wayland , but desktop environments such as plasma set
"activation-token" property instead as indicated in the spec:

    activation-token: This should be a string of the same value as would
    be stored in the XDG_ACTIVATION_TOKEN environment variable, as specified
    by the XDG Activation protocol for Wayland.

https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#dbus

gtk/gtkapplication-wayland.c
gtk/gtkapplication.c

index 42a6e029c73977f98a974949b50185351ff4e634..510d22656c1f5a769924eda1760d77b51a32d35f 100644 (file)
@@ -104,7 +104,9 @@ gtk_application_impl_wayland_before_emit (GtkApplicationImpl *impl,
 {
   const char *startup_notification_id = NULL;
 
-  g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_notification_id);
+  g_variant_lookup (platform_data, "activation-token", "&s", &startup_notification_id);
+  if (!startup_notification_id)
+    g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_notification_id);
 
   gdk_wayland_display_set_startup_notification_id (gdk_display_get_default (), startup_notification_id);
 }
index 0088a8d45d1a4551326a509822ba374c405efd68..d8dfd5c2d1b9c19f8374c039cf8f16066eac8c12 100644 (file)
@@ -323,8 +323,12 @@ gtk_application_add_platform_data (GApplication    *application,
 
       startup_id = gdk_display_get_startup_notification_id (display);
       if (startup_id && g_utf8_validate (startup_id, -1, NULL))
-        g_variant_builder_add (builder, "{sv}", "desktop-startup-id",
-                               g_variant_new_string (startup_id));
+        {
+          g_variant_builder_add (builder, "{sv}", "activation-token",
+                                 g_variant_new_string (startup_id));
+          g_variant_builder_add (builder, "{sv}", "desktop-startup-id",
+                                 g_variant_new_string (startup_id));
+        }
     }
 }