From 96a522adbd9a5e197877964beb4fd07281dcac02 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 10 Aug 2023 10:36:14 +0300 Subject: [PATCH] kwin: merge window rules into global rules config prior to 93a4a9263b47217b14e67c2296687901ecf76c4e it was done by a separate program (kwin_update_default_rules) Signed-off-by: Ivailo Monev --- kwin/CONFIGURING | 35 ++--------------------------------- kwin/rules.cpp | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/kwin/CONFIGURING b/kwin/CONFIGURING index 4a277414..f243c824 100644 --- a/kwin/CONFIGURING +++ b/kwin/CONFIGURING @@ -33,39 +33,8 @@ setting Maximum size, changing it to Force and entering "1600,1200" as the maximum size, which will make KWin force this size as the maximum size. To create such window-specific setting automatically without a need of doing -it manually for every user (for example when doing a large deployment), follow -these steps: - -- Back up your $KDEHOME/share/config/kwinrulesrc ($KDEHOME usually being $HOME/.kde) - and remove it -- Run 'dcop kwin default reconfigure' -- Create manually all window-specific settings that should be included (see above) -- When done, check in Window-specific settings configuration module - (Alt+F3/Configure window behavior/Window-specific settings) that all rules are - included -- Create a copy of $KDEHOME/share/config/kwinrulesrc and restore the original one -- Rename the copy (i.e. the newly created kwinrulesrc) to have its unique name - (e.g. foobar_fix_maxsize in this example case) -- Be careful with manual modifications of the file, especially make sure the count= - field in the [General] group is updated if needed -- Create a file for kconfig_update like this (named kwin_foobar_fix_maxsize.upd - in this example): - -# kwin_foobar_fix_maxsize.upd start # -Id=foobar_fix_maxsize -File=kwinrules_update -Group=Dummy -Options=overwrite -ScriptArguments=foobar_fix_maxsize -Script=kwin_update_default_rules - -# kwin_foobar_fix_maxsize.upd end # - -- The kconfig_file (kwin_foobar_fix_maxsize.upd) is to be placed - in $KDEDIR/share/apps/kconf_update/ -- The file with the window-specific settings (foobar_fix_maxsize) is to be placed - in $KDEDIR/share/apps/kwin/default_rules/ - +it manually for every user create file with the window-specific settings in +$KDEDIR/share/apps/kwin/default_rules/ All KDE user accounts should have these new window-specific settings added automatically during next KDE startup (or within few seconds if they are active). diff --git a/kwin/rules.cpp b/kwin/rules.cpp index bf5d174b..a2c43a18 100644 --- a/kwin/rules.cpp +++ b/kwin/rules.cpp @@ -21,12 +21,13 @@ along with this program. If not, see . #include "rules.h" #include +#include +#include #include #include -#include #include -#include #include +#include #ifndef KCMRULES #include "client.h" @@ -973,13 +974,21 @@ void RuleBook::load() deleteAll(); KConfig cfg("kwinrulesrc", KConfig::NoGlobals); int count = cfg.group("General").readEntry("count", 0); - for (int i = 1; - i <= count; - ++i) { + for (int i = 1; i <= count; ++i) { KConfigGroup cg(&cfg, QString::number(i)); Rules* rule = new Rules(cg); m_rules.append(rule); } + const QStringList kwinrules = KGlobal::dirs()->findAllResources("data", "kwin/default_rules/*.kwinrules"); + foreach (const QString &kwinrule, kwinrules) { + KConfig cfg(kwinrule, KConfig::NoGlobals); + int count = cfg.group("General").readEntry("count", 0); + for (int i = 1; i <= count; ++i) { + KConfigGroup cg(&cfg, QString::number(i)); + Rules* rule = new Rules(cg); + m_rules.append(rule); + } + } } void RuleBook::save()