[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin/Plasma/5.12] /: Do not save kwinrulesrc on every window opening/closing
From:       Martin_Flöser <null () kde ! org>
Date:       2018-05-20 13:40:45
Message-ID: E1fKOZp-0002KM-FB () code ! kde ! org
[Download RAW message or body]

Git commit 9a02ed4d360ffa18c3c406ab0eb1d01ccc9c0901 by Martin Flöser.
Committed on 20/05/2018 at 13:40.
Pushed by graesslin into branch 'Plasma/5.12'.

Do not save kwinrulesrc on every window opening/closing

Summary:
Our rule handling has had a grave error for years. Whenever a window
with a rule was openend or closed the kwinrulesrc was written back to
disk.

The reason for this behavior is that temporary rules need to be discarded
once they were used. For that there is a method discardUsed which invokes
requestDiskStorage whenever a rule for the window was found. But it did
not check whether there was a rule requiring this.

This change modifies the discardUsed to track whether it changed a rule
and only writes back in case there was a change.

BUG: 393911
FIXED-IN: 5.12.6

Test Plan: Only compile tested

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12749

M  +13   -5    rules.cpp
M  +1    -1    rules.h

https://commits.kde.org/kwin/9a02ed4d360ffa18c3c406ab0eb1d01ccc9c0901

diff --git a/rules.cpp b/rules.cpp
index 031dde354..e728b06bb 100644
--- a/rules.cpp
+++ b/rules.cpp
@@ -686,17 +686,22 @@ bool Rules::discardTemporary(bool force)
 
 #define DISCARD_USED_SET_RULE( var ) \
     do { \
-        if ( var##rule == ( SetRule ) ApplyNow || ( withdrawn && var##rule == ( \
SetRule ) ForceTemporarily )) \ +        if ( var##rule == ( SetRule ) ApplyNow || ( \
withdrawn && var##rule == ( SetRule ) ForceTemporarily )) { \  var##rule = \
UnusedSetRule; \ +            changed = true; \
+        } \
     } while ( false )
 #define DISCARD_USED_FORCE_RULE( var ) \
     do { \
-        if ( withdrawn && var##rule == ( ForceRule ) ForceTemporarily ) \
+        if ( withdrawn && var##rule == ( ForceRule ) ForceTemporarily ) { \
             var##rule = UnusedForceRule; \
+            changed = true; \
+        } \
     } while ( false )
 
-void Rules::discardUsed(bool withdrawn)
+bool Rules::discardUsed(bool withdrawn)
 {
+    bool changed = false;
     DISCARD_USED_FORCE_RULE(placement);
     DISCARD_USED_SET_RULE(position);
     DISCARD_USED_SET_RULE(size);
@@ -732,6 +737,8 @@ void Rules::discardUsed(bool withdrawn)
     DISCARD_USED_FORCE_RULE(strictgeometry);
     DISCARD_USED_SET_RULE(shortcut);
     DISCARD_USED_FORCE_RULE(disableglobalshortcuts);
+
+    return changed;
 }
 #undef DISCARD_USED_SET_RULE
 #undef DISCARD_USED_FORCE_RULE
@@ -1115,8 +1122,9 @@ void RuleBook::discardUsed(AbstractClient* c, bool withdrawn)
             it != m_rules.end();
        ) {
         if (c->rules()->contains(*it)) {
-            updated = true;
-            (*it)->discardUsed(withdrawn);
+            if ((*it)->discardUsed(withdrawn)) {
+                updated = true;
+            }
             if ((*it)->isEmpty()) {
                 c->removeRule(*it);
                 Rules* r = *it;
diff --git a/rules.h b/rules.h
index 007ce5b71..8ad459d0f 100644
--- a/rules.h
+++ b/rules.h
@@ -115,7 +115,7 @@ public:
     void write(KConfigGroup&) const;
     bool isEmpty() const;
 #ifndef KCMRULES
-    void discardUsed(bool withdrawn);
+    bool discardUsed(bool withdrawn);
     bool match(const AbstractClient* c) const;
     bool update(AbstractClient*, int selection);
     bool isTemporary() const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic