diff --git a/client.cpp b/client.cpp index fe317b8433..c2b246c2fa 100644 --- a/client.cpp +++ b/client.cpp @@ -2453,13 +2453,13 @@ void Client::updateColorScheme() auto resetToDefault = [this]() { m_palette = QApplication::palette(); }; + QString path; if (!prop.isNull() && prop->format == 8 && prop->value_len > 0) { - QString path = QString::fromUtf8(static_cast(xcb_get_property_value(prop.data()))); - if (!path.isNull()) { - m_palette = KColorScheme::createApplicationPalette(KSharedConfig::openConfig(path)); - } else { - resetToDefault(); - } + path = QString::fromUtf8(static_cast(xcb_get_property_value(prop.data()))); + } + path = rules()->checkDecoColor(path); + if (!path.isNull()) { + m_palette = KColorScheme::createApplicationPalette(KSharedConfig::openConfig(path)); } else { resetToDefault(); } diff --git a/rules.cpp b/rules.cpp index 212bd0f1dc..d09548bb67 100644 --- a/rules.cpp +++ b/rules.cpp @@ -26,6 +26,7 @@ along with this program. If not, see . #include #include #include +#include #include #include @@ -70,6 +71,7 @@ Rules::Rules() , belowrule(UnusedSetRule) , fullscreenrule(UnusedSetRule) , noborderrule(UnusedSetRule) + , decocolorrule(UnusedForceRule) , blockcompositingrule(UnusedForceRule) , fsplevelrule(UnusedForceRule) , acceptfocusrule(UnusedForceRule) @@ -177,6 +179,8 @@ void Rules::readFromCfg(const KConfigGroup& cfg) READ_SET_RULE(below, , false); READ_SET_RULE(fullscreen, , false); READ_SET_RULE(noborder, , false); + decocolor = readDecoColor(cfg); + decocolorrule = decocolor.isEmpty() ? UnusedForceRule : readForceRule(cfg, QStringLiteral("decocolorrule")); READ_FORCE_RULE(blockcompositing, , false); READ_FORCE_RULE(fsplevel, limit0to4, 0); // fsp is 0-4 READ_FORCE_RULE(acceptfocus, , false); @@ -266,6 +270,14 @@ void Rules::write(KConfigGroup& cfg) const WRITE_SET_RULE(below,); WRITE_SET_RULE(fullscreen,); WRITE_SET_RULE(noborder,); + auto colorToString = [](const QString &value) { + if (value.endsWith(QStringLiteral(".colors"))) { + return QFileInfo(value).baseName(); + } else { + return value; + } + }; + WRITE_FORCE_RULE(decocolor, colorToString); WRITE_FORCE_RULE(blockcompositing,); WRITE_FORCE_RULE(fsplevel,); WRITE_FORCE_RULE(acceptfocus,); @@ -308,6 +320,7 @@ bool Rules::isEmpty() const && belowrule == UnusedSetRule && fullscreenrule == UnusedSetRule && noborderrule == UnusedSetRule + && decocolorrule == UnusedForceRule && blockcompositingrule == UnusedForceRule && fsplevelrule == UnusedForceRule && acceptfocusrule == UnusedForceRule @@ -344,6 +357,17 @@ NET::WindowType Rules::readType(const KConfigGroup& cfg, const QString& key) return NET::Unknown; } +QString Rules::readDecoColor(const KConfigGroup &cfg) +{ + QString themeName = cfg.readEntry("decocolor", QString()); + if (themeName.isEmpty()) { + return QString(); + } + // find the actual scheme file + return QStandardPaths::locate(QStandardPaths::GenericDataLocation, + QStringLiteral("color-schemes/") + themeName + QStringLiteral(".colors")); +} + bool Rules::matchType(NET::WindowType match_type) const { if (types != NET::AllTypesMask) { @@ -625,6 +649,7 @@ APPLY_RULE(above, KeepAbove, bool) APPLY_RULE(below, KeepBelow, bool) APPLY_RULE(fullscreen, FullScreen, bool) APPLY_RULE(noborder, NoBorder, bool) +APPLY_FORCE_RULE(decocolor, DecoColor, QString) APPLY_FORCE_RULE(blockcompositing, BlockCompositing, bool) APPLY_FORCE_RULE(fsplevel, FSP, int) APPLY_FORCE_RULE(acceptfocus, AcceptFocus, bool) @@ -692,6 +717,7 @@ void Rules::discardUsed(bool withdrawn) DISCARD_USED_SET_RULE(below); DISCARD_USED_SET_RULE(fullscreen); DISCARD_USED_SET_RULE(noborder); + DISCARD_USED_FORCE_RULE(decocolor); DISCARD_USED_FORCE_RULE(blockcompositing); DISCARD_USED_FORCE_RULE(fsplevel); DISCARD_USED_FORCE_RULE(acceptfocus); @@ -824,6 +850,7 @@ CHECK_RULE(KeepAbove, bool) CHECK_RULE(KeepBelow, bool) CHECK_RULE(FullScreen, bool) CHECK_RULE(NoBorder, bool) +CHECK_FORCE_RULE(DecoColor, QString) CHECK_FORCE_RULE(BlockCompositing, bool) CHECK_FORCE_RULE(FSP, int) CHECK_FORCE_RULE(AcceptFocus, bool) @@ -877,6 +904,7 @@ void Client::applyWindowRules() setKeepBelow(keepBelow()); setFullScreen(isFullScreen(), true); setNoBorder(noBorder()); + updateColorScheme(); // FSP // AcceptFocus : if (workspace()->mostRecentlyActivatedClient() == this diff --git a/rules.h b/rules.h index 53f6686c62..d1624d9867 100644 --- a/rules.h +++ b/rules.h @@ -77,6 +77,7 @@ public: bool checkKeepBelow(bool below, bool init = false) const; bool checkFullScreen(bool fs, bool init = false) const; bool checkNoBorder(bool noborder, bool init = false) const; + QString checkDecoColor(QString schemeFile) const; bool checkBlockCompositing(bool block) const; int checkFSP(int fsp) const; bool checkAcceptFocus(bool focus) const; @@ -144,6 +145,7 @@ public: bool applyKeepBelow(bool& below, bool init) const; bool applyFullScreen(bool& fs, bool init) const; bool applyNoBorder(bool& noborder, bool init) const; + bool applyDecoColor(QString &schemeFile) const; bool applyBlockCompositing(bool& block) const; bool applyFSP(int& fsp) const; bool applyAcceptFocus(bool& focus) const; @@ -191,6 +193,7 @@ private: static SetRule readSetRule(const KConfigGroup&, const QString& key); static ForceRule readForceRule(const KConfigGroup&, const QString& key); static NET::WindowType readType(const KConfigGroup&, const QString& key); + static QString readDecoColor(const KConfigGroup &cfg); #ifndef KCMRULES static bool checkSetRule(SetRule rule, bool init); static bool checkForceRule(ForceRule rule); @@ -255,6 +258,8 @@ private: SetRule fullscreenrule; bool noborder; SetRule noborderrule; + QString decocolor; + ForceRule decocolorrule; bool blockcompositing; ForceRule blockcompositingrule; int fsplevel;