Commit 735f350c authored by Mladen Milinkovic's avatar Mladen Milinkovic Committed by Nicolas Fella
Browse files

Handle multiple desktop files with different StartupWMClass

Some system installed apps define common/default StartupWMClass in
system-installed .desktop file.

Application then create extra .desktop files in user's local
applications directory with additional (more specific) StartupWMClass
entry.

This patch will match specific window class (WM_CLASS instance name)
before matching common window class (WM_CLASS class name).

See: https://www.x.org/releases/X11R7.7/doc/xorg-docs/icccm/icccm.html#WM_CLASS_Property

BUG: 358277
(cherry picked from commit 1e6180d8)
parent 8a18babc
Pipeline #247791 passed with stage
in 8 minutes and 21 seconds
......@@ -249,13 +249,6 @@ QUrl windowUrlFromMetadata(const QString &appId, quint32 pid, KSharedConfig::Ptr
// window with the given string as its WM class or WM name hint.
//
// Source: https://specifications.freedesktop.org/startup-notification-spec/startup-notification-0.1.txt
if (services.isEmpty()) {
services = KApplicationTrader::query([&appId](const KService::Ptr &service) {
return service->property(QStringLiteral("StartupWMClass")).toString().compare(appId, Qt::CaseInsensitive) == 0;
});
sortServicesByMenuId(services, appId);
}
if (services.isEmpty() && !xWindowsWMClassName.isEmpty()) {
services = KApplicationTrader::query([&xWindowsWMClassName](const KService::Ptr &service) {
return service->property(QStringLiteral("StartupWMClass")).toString().compare(xWindowsWMClassName, Qt::CaseInsensitive) == 0;
......@@ -263,6 +256,13 @@ QUrl windowUrlFromMetadata(const QString &appId, quint32 pid, KSharedConfig::Ptr
sortServicesByMenuId(services, xWindowsWMClassName);
}
if (services.isEmpty()) {
services = KApplicationTrader::query([&appId](const KService::Ptr &service) {
return service->property(QStringLiteral("StartupWMClass")).toString().compare(appId, Qt::CaseInsensitive) == 0;
});
sortServicesByMenuId(services, appId);
}
// Evaluate rewrite rules from config.
if (services.isEmpty()) {
KConfigGroup rewriteRulesGroup(rulesConfig, QStringLiteral("Rewrite Rules"));
......
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