From bc53ee806cf4fbccbc456513d822742205542585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kondor=20D=C3=A1niel?= Date: Sun, 13 Apr 2025 14:01:26 +0200 Subject: [PATCH 1/2] panel/menu: launch apps with a valid xdg-activation token Creating a Gdk::AppLaunchContext from the current display and providing it to Gio::AppInfo::launch() takes care of this. --- src/panel/widgets/menu.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/panel/widgets/menu.cpp b/src/panel/widgets/menu.cpp index 00759611..2c6231f5 100644 --- a/src/panel/widgets/menu.cpp +++ b/src/panel/widgets/menu.cpp @@ -118,7 +118,8 @@ WfMenuMenuItem::WfMenuMenuItem(WayfireMenu *_menu, Glib::RefPtrsignal_activate().connect( [this, action] () { - m_app_info->launch_action(action); + auto ctx = Gdk::Display::get_default()->get_app_launch_context(); + m_app_info->launch_action(action, ctx); menu->hide_menu(); }); m_action_menu.append(*menu_item); @@ -161,7 +162,8 @@ WfMenuMenuItem::WfMenuMenuItem(WayfireMenu *_menu, Glib::RefPtrlaunch(std::vector>()); + auto ctx = Gdk::Display::get_default()->get_app_launch_context(); + m_app_info->launch(std::vector>(), ctx); menu->hide_menu(); } From 6e660c41f58a9f4a53407ad9aefb54d31ab3dc1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kondor=20D=C3=A1niel?= Date: Mon, 21 Apr 2025 13:16:01 +0200 Subject: [PATCH 2/2] panel/launchers: try to use xdg-activation --- src/panel/widgets/launchers.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/panel/widgets/launchers.cpp b/src/panel/widgets/launchers.cpp index aaf2fb96..c03b3d2d 100644 --- a/src/panel/widgets/launchers.cpp +++ b/src/panel/widgets/launchers.cpp @@ -33,6 +33,11 @@ bool WfLauncherButton::initialize(std::string name, std::string icon, std::strin } keyfile.set_string("Desktop Entry", "Name", label); + /* needed for xdg-activation to work, see: + * https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gdesktopappinfo.c?ref_type=heads#L1970 + * https://gitlab.gnome.org/GNOME/glib/-/blob/main/gio/gdesktopappinfo.c?ref_type=heads#L2957 + */ + keyfile.set_string("Desktop Entry", "StartupNotify", "true"); // Hand off to have a custom launcher app_info = Gio::DesktopAppInfo::create_from_keyfile(keyfile); @@ -69,7 +74,8 @@ void WfLauncherButton::launch() { if (app_info) { - app_info->launch(std::vector>()); + auto ctx = Gdk::Display::get_default()->get_app_launch_context(); + app_info->launch(std::vector>(), ctx); } }