Skip to content

Commit

Permalink
notification: Add platform data to ActionInvoked signal
Browse files Browse the repository at this point in the history
Apps may not implement the `org.freedesktop.Application` interface so
they won't get the platform data. We can do a little better and add the
platform data to the `ActionInvoked` signal.
  • Loading branch information
jsparber committed Mar 1, 2024
1 parent 7531ebf commit 2d8d831
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,27 @@ 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);

if (activation_token)
{
/* Used by `GTK` */
g_variant_builder_add (&pdata, "{sv}",
g_variant_builder_add (&pdata_builder, "{sv}",
"desktop-startup-id", g_variant_new_string (activation_token));
/* Used by `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,
Expand All @@ -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);
Expand All @@ -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",
Expand Down

0 comments on commit 2d8d831

Please sign in to comment.