[geary] Unneccessary dconf updates on window move



commit 3825ce5d7eba6cfe672c7f947d35f091869c3c41
Author: Jakob Unterwurzacher <jakobunt gmail com>
Date:   Sat Feb 22 11:00:19 2014 +0100

    Unneccessary dconf updates on window move
    
    Writing the window_{width,height,maximized} variables triggers
    a dconf database update. This is an expensive operation as
    dconf writes down a full copy of the database and renames
    over the old one. dconf does not check for unchanged values.
    
    configure_event() is called for every pixel of a window move,
    and writes the window_* variables - those do not change during
    a move. Check by running
    "dconf watch /org/yorba/geary/" and moving the window or just
    listen to the hard disk grinding.
    
    This patch checks if the values have changed before writing
    them out, which fixes the issue and provides a
    disk-grinding-free window move experience.
    
    Closes: bgo #724953

 src/client/components/main-window.vala |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 7bce867..31fdc14 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -94,15 +94,23 @@ public class MainWindow : Gtk.ApplicationWindow {
     }
     
     public override bool configure_event(Gdk.EventConfigure event) {
-        // Get window dimensions.
-        window_maximized = ((get_window().get_state() & Gdk.WindowState.MAXIMIZED) != 0);
-        if (!window_maximized) {
+        // Get window state and dimensions.
+        // Note: A window move triggers this event with no changed values.
+        bool maximized = ((get_window().get_state() & Gdk.WindowState.MAXIMIZED) != 0);
+        // Writing the window_* variables triggers a dconf database update. Only write if
+        // the value has changed.
+        if(window_maximized != maximized)
+            window_maximized = maximized;
+
+        if (!maximized) {
+            // can't use properties as out variables
             int width, height;
             get_size(out width, out height);
             
-            // can't use properties as out variables
-            window_width = width;
-            window_height = height;
+            if(window_width != width)
+                window_width = width;
+            if(window_height != height)
+                window_height = height;
         }
         
         return base.configure_event(event);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]