mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-02 17:26:17 +01:00
gdesktopappinfo: Set XDG_ACTIVATION_TOKEN/activation-token startup ID key
See: * https://gitlab.freedesktop.org/xdg/xdg-specs/-/blob/master/desktop-entry/desktop-entry-spec.xml#L1061-1068 * https://wayland.app/protocols/xdg-activation-v1 * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/xdg-activation/x11-interoperation.rst Fixes: #2709
This commit is contained in:
parent
24e1bfba16
commit
627f2738e0
@ -577,9 +577,9 @@ g_app_info_get_icon (GAppInfo *appinfo)
|
|||||||
* environment variable with the path of the launched desktop file and
|
* environment variable with the path of the launched desktop file and
|
||||||
* `GIO_LAUNCHED_DESKTOP_FILE_PID` to the process id of the launched
|
* `GIO_LAUNCHED_DESKTOP_FILE_PID` to the process id of the launched
|
||||||
* process. This can be used to ignore `GIO_LAUNCHED_DESKTOP_FILE`,
|
* process. This can be used to ignore `GIO_LAUNCHED_DESKTOP_FILE`,
|
||||||
* should it be inherited by further processes. The `DISPLAY` and
|
* should it be inherited by further processes. The `DISPLAY`,
|
||||||
* `DESKTOP_STARTUP_ID` environment variables are also set, based
|
* `XDG_ACTIVATION_TOKEN` and `DESKTOP_STARTUP_ID` environment
|
||||||
* on information provided in @context.
|
* variables are also set, based on information provided in @context.
|
||||||
*
|
*
|
||||||
* Returns: %TRUE on successful launch, %FALSE otherwise.
|
* Returns: %TRUE on successful launch, %FALSE otherwise.
|
||||||
**/
|
**/
|
||||||
@ -1594,10 +1594,18 @@ g_app_launch_context_get_display (GAppLaunchContext *context,
|
|||||||
* @files: (element-type GFile): a #GList of of #GFile objects
|
* @files: (element-type GFile): a #GList of of #GFile objects
|
||||||
*
|
*
|
||||||
* Initiates startup notification for the application and returns the
|
* Initiates startup notification for the application and returns the
|
||||||
* `DESKTOP_STARTUP_ID` for the launched operation, if supported.
|
* `XDG_ACTIVATION_TOKEN` or `DESKTOP_STARTUP_ID` for the launched operation,
|
||||||
|
* if supported.
|
||||||
*
|
*
|
||||||
* Startup notification IDs are defined in the
|
* The returned token may be referred to equivalently as an ‘activation token’
|
||||||
* [FreeDesktop.Org Startup Notifications standard](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt).
|
* (using Wayland terminology) or a ‘startup sequence ID’ (using X11 terminology).
|
||||||
|
* The two [are interoperable](https://gitlab.freedesktop.org/wayland/wayland-protocols/-/blob/main/staging/xdg-activation/x11-interoperation.rst).
|
||||||
|
*
|
||||||
|
* Activation tokens are defined in the [XDG Activation Protocol](https://wayland.app/protocols/xdg-activation-v1),
|
||||||
|
* and startup notification IDs are defined in the
|
||||||
|
* [freedesktop.org Startup Notification Protocol](http://standards.freedesktop.org/startup-notification-spec/startup-notification-latest.txt).
|
||||||
|
*
|
||||||
|
* Support for the XDG Activation Protocol was added in GLib 2.76.
|
||||||
*
|
*
|
||||||
* Returns: (nullable): a startup notification ID for the application, or %NULL if
|
* Returns: (nullable): a startup notification ID for the application, or %NULL if
|
||||||
* not supported.
|
* not supported.
|
||||||
|
@ -304,6 +304,9 @@ app_get_platform_data (void)
|
|||||||
if ((startup_id = g_getenv ("DESKTOP_STARTUP_ID")))
|
if ((startup_id = g_getenv ("DESKTOP_STARTUP_ID")))
|
||||||
g_variant_builder_add (&builder, "{sv}", "desktop-startup-id", g_variant_new_string (startup_id));
|
g_variant_builder_add (&builder, "{sv}", "desktop-startup-id", g_variant_new_string (startup_id));
|
||||||
|
|
||||||
|
if ((startup_id = g_getenv ("XDG_ACTIVATION_TOKEN")))
|
||||||
|
g_variant_builder_add (&builder, "{sv}", "activation-token", g_variant_new_string (startup_id));
|
||||||
|
|
||||||
return g_variant_builder_end (&builder);
|
return g_variant_builder_end (&builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2895,7 +2895,10 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info,
|
|||||||
G_APP_INFO (info),
|
G_APP_INFO (info),
|
||||||
launched_files);
|
launched_files);
|
||||||
if (sn_id)
|
if (sn_id)
|
||||||
envp = g_environ_setenv (envp, "DESKTOP_STARTUP_ID", sn_id, TRUE);
|
{
|
||||||
|
envp = g_environ_setenv (envp, "DESKTOP_STARTUP_ID", sn_id, TRUE);
|
||||||
|
envp = g_environ_setenv (envp, "XDG_ACTIVATION_TOKEN", sn_id, TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full (launched_files, g_object_unref);
|
g_list_free_full (launched_files, g_object_unref);
|
||||||
@ -3032,7 +3035,10 @@ g_desktop_app_info_make_platform_data (GDesktopAppInfo *info,
|
|||||||
|
|
||||||
sn_id = g_app_launch_context_get_startup_notify_id (launch_context, G_APP_INFO (info), launched_files);
|
sn_id = g_app_launch_context_get_startup_notify_id (launch_context, G_APP_INFO (info), launched_files);
|
||||||
if (sn_id)
|
if (sn_id)
|
||||||
g_variant_builder_add (&builder, "{sv}", "desktop-startup-id", g_variant_new_take_string (sn_id));
|
{
|
||||||
|
g_variant_builder_add (&builder, "{sv}", "desktop-startup-id", g_variant_new_string (sn_id));
|
||||||
|
g_variant_builder_add (&builder, "{sv}", "activation-token", g_variant_new_take_string (g_steal_pointer (&sn_id)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_list_free_full (launched_files, g_object_unref);
|
g_list_free_full (launched_files, g_object_unref);
|
||||||
|
@ -226,13 +226,24 @@ test_application_before_emit (GApplication *application,
|
|||||||
GVariant *platform_data)
|
GVariant *platform_data)
|
||||||
{
|
{
|
||||||
const gchar *startup_id;
|
const gchar *startup_id;
|
||||||
|
gsize i;
|
||||||
|
|
||||||
g_assert (!saw_startup_id);
|
g_assert (!saw_startup_id);
|
||||||
|
|
||||||
if (!g_variant_lookup (platform_data, "desktop-startup-id", "&s", &startup_id))
|
const gchar *startup_id_keys[] = {
|
||||||
return;
|
"desktop-startup-id",
|
||||||
|
"activation-token",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; startup_id_keys[i] != NULL; i++)
|
||||||
|
{
|
||||||
|
if (!g_variant_lookup (platform_data, startup_id_keys[i], "&s", &startup_id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
g_assert_cmpstr (startup_id, ==, "expected startup id");
|
||||||
|
}
|
||||||
|
|
||||||
g_assert_cmpstr (startup_id, ==, "expected startup id");
|
|
||||||
saw_startup_id = TRUE;
|
saw_startup_id = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user