diff --git a/src/xdgactivationv1.cpp b/src/xdgactivationv1.cpp index e15fa201ce..9048e25f2a 100644 --- a/src/xdgactivationv1.cpp +++ b/src/xdgactivationv1.cpp @@ -17,6 +17,7 @@ #include "wayland_server.h" #include "window.h" #include "workspace.h" +#include #include using namespace KWaylandServer; @@ -31,6 +32,25 @@ static bool isPrivilegedInWindowManagement(const ClientConnection *client) return requestedInterfaces.contains(QLatin1String("org_kde_plasma_window_management")); } +static const QString windowDesktopFileName(Window *window) +{ + QString ret = window->desktopFileName(); + if (!ret.isEmpty()) { + return ret; + } + + // Fallback to StartupWMClass for legacy apps + const auto resourceName = window->resourceName(); + const auto service = KApplicationTrader::query([&resourceName](const KService::Ptr &service) { + return service->property("StartupWMClass") == resourceName; + }); + + if (!service.isEmpty()) { + ret = service.constFirst()->desktopEntryName(); + } + return ret; +} + XdgActivationV1Integration::XdgActivationV1Integration(XdgActivationV1Interface *activation, QObject *parent) : QObject(parent) { @@ -41,7 +61,7 @@ XdgActivationV1Integration::XdgActivationV1Integration(XdgActivationV1Interface } // We check that it's not the app that we are trying to activate - if (window->desktopFileName() != m_currentActivationToken->applicationId) { + if (windowDesktopFileName(window) != m_currentActivationToken->applicationId) { // But also that the new one has been requested after the token was requested if (window->lastUsageSerial() < m_currentActivationToken->serial) { return;