From 8f90c582a6d28ac633929e99fe5d24c6e501401a Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Wed, 23 Feb 2011 22:46:55 +0100 Subject: [PATCH] Defer the resize callbacks into the gobject.idle_add queue. Huge difference in splitter dragging in complex layouts --- terminatorlib/terminal.py | 18 ++++++++++++++++-- terminatorlib/window.py | 14 ++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 40b3f5a2..8f13d217 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -118,6 +118,8 @@ class Terminal(gtk.VBox): self.origcwd = self.terminator.origcwd self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD) + self.pending_on_vte_size_allocate = False + self.vte = vte.Terminal() self.vte.set_size(80, 24) self.vte._expose_data = None @@ -335,7 +337,7 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) self.emit('title-change', self.get_window_title())) self.vte.connect('grab-focus', self.on_vte_focus) self.vte.connect('focus-in-event', self.on_vte_focus_in) - self.vte.connect('size-allocate', self.on_vte_size_allocate) + self.vte.connect('size-allocate', self.deferred_on_vte_size_allocate) self.vte.add_events(gtk.gdk.ENTER_NOTIFY_MASK) self.vte.connect('enter_notify_event', @@ -1001,12 +1003,24 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) """A child widget is done editing a label, return focus to VTE""" self.vte.grab_focus() + def deferred_on_vte_size_allocate(self, widget, allocation): + # widget & allocation are not used in on_vte_size_allocate, so we + # can use the on_vte_size_allocate instead of duplicating the code + if self.pending_on_vte_size_allocate == True: + return + self.pending_on_vte_size_allocate = True + gobject.idle_add(self.do_deferred_on_vte_size_allocate, widget, allocation) + + def do_deferred_on_vte_size_allocate(self, widget, allocation): + self.pending_on_vte_size_allocate = False + self.on_vte_size_allocate(widget, allocation) + def on_vte_size_allocate(self, widget, allocation): self.titlebar.update_terminal_size(self.vte.get_column_count(), self.vte.get_row_count()) if self.vte.window and self.config['geometry_hinting']: window = self.get_toplevel() - window.set_rough_geometry_hints() + window.deferred_set_rough_geometry_hints() def on_vte_notify_enter(self, term, event): """Handle the mouse entering this terminal""" diff --git a/terminatorlib/window.py b/terminatorlib/window.py index 1e7cf85d..94f59e47 100755 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -81,6 +81,8 @@ class Window(Container, gtk.Window): err('Window::__init__: Unable to parse geometry: %s' % options.geometry) + self.pending_set_rough_geometry_hint = False + def do_get_property(self, prop): """Handle gobject getting a property""" if prop.name in ['term_zoomed', 'term-zoomed']: @@ -510,6 +512,18 @@ class Window(Container, gtk.Window): return(terminal) return(None) + def deferred_set_rough_geometry_hints(self): + # no parameters are used in set_rough_geometry_hints, so we can + # use the set_rough_geometry_hints + if self.pending_set_rough_geometry_hint == True: + return + self.pending_set_rough_geometry_hint = True + gobject.idle_add(self.do_deferred_set_rough_geometry_hints) + + def do_deferred_set_rough_geometry_hints(self): + self.pending_set_rough_geometry_hint = False + self.set_rough_geometry_hints() + def set_rough_geometry_hints(self): """Walk all the terminals along the top and left edges to fake up how many columns/rows we sort of have"""