diff --git a/src/notification.c b/src/notification.c index ebf092a..74af808 100644 --- a/src/notification.c +++ b/src/notification.c @@ -109,10 +109,11 @@ activate_action (GDBusConnection *connection, gpointer data) { g_autofree char *object_path = NULL; - GVariantBuilder pdata, parms; + GVariantBuilder pdata_builder, parms; + g_autoptr(GVariant) pdata = NULL; object_path = app_path_for_id (app_id); - g_variant_builder_init (&pdata, G_VARIANT_TYPE_VARDICT); + g_variant_builder_init (&pdata_builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_init (&parms, G_VARIANT_TYPE ("av")); if (parameter) g_variant_builder_add (&parms, "v", parameter); @@ -120,13 +121,15 @@ activate_action (GDBusConnection *connection, if (activation_token) { /* Used by `GTK` < 4.10 */ - g_variant_builder_add (&pdata, "{sv}", + g_variant_builder_add (&pdata_builder, "{sv}", "desktop-startup-id", g_variant_new_string (activation_token)); /* Used by `GTK` and `QT` */ - g_variant_builder_add (&pdata, "{sv}", + g_variant_builder_add (&pdata_builder, "{sv}", "activation-token", g_variant_new_string (activation_token)); } + pdata = g_variant_ref_sink (g_variant_builder_end (&pdata_builder)); + if (name && g_str_has_prefix (name, "app.")) { g_dbus_connection_call (connection, @@ -137,7 +140,7 @@ activate_action (GDBusConnection *connection, g_variant_new ("(s@av@a{sv})", name + 4, g_variant_builder_end (&parms), - g_variant_builder_end (&pdata)), + pdata), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); @@ -151,12 +154,15 @@ activate_action (GDBusConnection *connection, object_path, "org.freedesktop.Application", "Activate", - g_variant_new ("(@a{sv})", - g_variant_builder_end (&pdata)), + g_variant_new ("(@a{sv})", pdata), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL); + /* The application may not implement the `org.freedesktop.Application`, so + * add the platform data also to the `ActionInvoked` signal */ + g_variant_builder_add (&parms, "v", pdata); + g_dbus_connection_emit_signal (connection, NULL, "/org/freedesktop/portal/desktop",