Commit 81ff7737 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

activation: Fix activation notification of Xwayland clients

Most xwayland clients don't know their desktop file name, so use the
StartupWMClass field in their desktop files as means to inferring their
desktop file name.

BUG: 455265


(cherry picked from commit c68a0f5d)
parent ff373197
Pipeline #206642 canceled with stage
......@@ -17,6 +17,7 @@
#include "wayland_server.h"
#include "window.h"
#include "workspace.h"
#include <KApplicationTrader>
#include <KDesktopFile>
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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment