From 6b30262cf78de2beaf03fe248f290be8f4da5b35 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 23 Aug 2007 21:17:43 +0200 Subject: [PATCH] Redraw the window only if allocation changed. Patch by benzea, with a little cleanup and comments by me. --- sugar/graphics/palette.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py index 70abc2e1..15cd661b 100644 --- a/sugar/graphics/palette.py +++ b/sugar/graphics/palette.py @@ -104,6 +104,7 @@ class Palette(gtk.Window): self.set_resizable(False) self.connect('realize', self._realize_cb) + self._old_alloc = None self._full_request = [0, 0] self._cursor_x = 0 self._cursor_y = 0 @@ -219,7 +220,20 @@ class Palette(gtk.Window): def do_size_allocate(self, allocation): gtk.Window.do_size_allocate(self, allocation) - self.queue_draw() + + if self._old_alloc is None or \ + self._old_alloc.x != allocation.x or \ + self._old_alloc.y != allocation.y or \ + self._old_alloc.width != allocation.width or \ + self._old_alloc.height != allocation.height: + self.queue_draw() + + # We need to store old allocation because when size_allocate + # is called widget.allocation is already updated. + # gtk.Window resizing is different from normal containers: + # the X window is resized, widget.allocation is updated from + # the configure request handler and finally size_allocate is called. + self._old_alloc = allocation def do_expose_event(self, event): # We want to draw a border with a beautiful gap