diff --git a/src/kcmkwin/kwinrules/kcmrules.cpp b/src/kcmkwin/kwinrules/kcmrules.cpp
index 6610ca5931..49f4de9da2 100644
--- a/src/kcmkwin/kwinrules/kcmrules.cpp
+++ b/src/kcmkwin/kwinrules/kcmrules.cpp
@@ -419,7 +419,9 @@ void KCMKWinRules::fillSettingsFromProperties(RuleSettings *settings, const QVar
settings->setDefaults();
if (wholeApp) {
- settings->setDescription(i18n("Application settings for %1", wmclass_class));
+ if (!wmclass_class.isEmpty()) {
+ settings->setDescription(i18n("Application settings for %1", wmclass_class));
+ }
// TODO maybe exclude some types? If yes, then also exclude them when searching.
settings->setTypes(NET::AllTypesMask);
settings->setTitlematch(Rules::UnimportantMatch);
@@ -439,7 +441,9 @@ void KCMKWinRules::fillSettingsFromProperties(RuleSettings *settings, const QVar
return;
}
- settings->setDescription(i18n("Window settings for %1", wmclass_class));
+ if (!wmclass_class.isEmpty()) {
+ settings->setDescription(i18n("Window settings for %1", wmclass_class));
+ }
if (type == NET::Unknown) {
settings->setTypes(NET::NormalMask);
} else {
diff --git a/src/kcmkwin/kwinrules/rulesmodel.cpp b/src/kcmkwin/kwinrules/rulesmodel.cpp
index 78894fa665..4d823784d9 100644
--- a/src/kcmkwin/kwinrules/rulesmodel.cpp
+++ b/src/kcmkwin/kwinrules/rulesmodel.cpp
@@ -697,6 +697,17 @@ void RulesModel::setSuggestedProperties(const QVariantMap &info)
const QString wmcompleteclass = QStringLiteral("%1 %2").arg(info.value("resourceName").toString(),
info.value("resourceClass").toString());
+ // This window is not providing the class according to spec (WM_CLASS on X11, appId on Wayland)
+ // Notify the user that this is a bug within the application, so there's nothing we can do
+ if (wmsimpleclass.isEmpty()) {
+ Q_EMIT showErrorMessage(i18n("Window class not available"),
+ xi18nc("@info", "This application is not providing a class for the window, "
+ "so KWin cannot use it to match and apply any rules. "
+ "If you still want to apply some rules to it, "
+ "try to match other properties like the window title instead."
+ "Please consider reporting this bug to the application's developers."));
+ }
+
m_rules["wmclass"]->setSuggestedValue(wmsimpleclass);
m_rules["wmclasshelper"]->setSuggestedValue(wmcompleteclass);