[meld] windowstate: Avoid spurious dconf writes on allocate events (#247)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] windowstate: Avoid spurious dconf writes on allocate events (#247)
- Date: Wed, 21 Nov 2018 21:08:29 +0000 (UTC)
commit 01c65285709ab06d66769c4e27a83b4faacfcd87
Author: Kai Willadsen <kai willadsen gmail com>
Date: Thu Nov 22 06:53:54 2018 +1000
windowstate: Avoid spurious dconf writes on allocate events (#247)
Currently we write the window state a *lot*, because we constantly get
spammed with `size-allocate` signals when nothing has changed (e.g.,
we've scrolled a comparison). The window size is typically unchanged,
so here we add the simplest possible check before assigning to our
bound properties. In my testing, this completely eliminates the spurious
writes.
There's also the dconf part of this where it's constantly re-writing
values that haven't actually changed; see GNOME/dconf#40 for the
discussion about that.
meld/windowstate.py | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/meld/windowstate.py b/meld/windowstate.py
index 09c883c9..e11efbc5 100644
--- a/meld/windowstate.py
+++ b/meld/windowstate.py
@@ -61,10 +61,18 @@ class SavedWindowState(GObject.GObject):
def on_size_allocate(self, window, allocation):
if not (self.props.is_maximized or self.props.is_fullscreen):
width, height = window.get_size()
- self.props.width = width
- self.props.height = height
+ if width != self.props.width:
+ self.props.width = width
+ if height != self.props.height:
+ self.props.height = height
def on_window_state_event(self, window, event):
state = event.window.get_state()
- self.props.is_maximized = state & Gdk.WindowState.MAXIMIZED
- self.props.is_fullscreen = state & Gdk.WindowState.FULLSCREEN
+
+ is_maximized = state & Gdk.WindowState.MAXIMIZED
+ if is_maximized != self.props.is_maximized:
+ self.props.is_maximized = is_maximized
+
+ is_fullscreen = state & Gdk.WindowState.FULLSCREEN
+ if is_fullscreen != self.props.is_fullscreen:
+ self.props.is_fullscreen = is_fullscreen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]