From eda8d3fc220945f908aa33cf5554aff4c0c829dd Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 18 Oct 2012 16:23:25 -0700 Subject: [PATCH] Partially prevent focus grabbing by terminals leaving a Paned where they had no focus to begin with. This is useful where terminals are exiting for reasons other than direct user intervention. LP#943311 --- terminatorlib/paned.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index 01b297e6..6d623498 100755 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -111,7 +111,10 @@ class Paned(Container): handler = handler[0] self.connect_child(widget, signal, handler, *args) - widget.grab_focus() + if metadata and \ + metadata.has_key('had_focus') and \ + metadata['had_focus'] == True: + widget.grab_focus() elif isinstance(widget, gtk.Paned): try: @@ -220,9 +223,15 @@ class Paned(Container): children.append(self.get_child2()) return(children) + def get_child_metadata(self, widget): + """Return metadata about a child""" + metadata = {} + metadata['had_focus'] = widget.has_focus() + def wrapcloseterm(self, widget): """A child terminal has closed, so this container must die""" dbg('Paned::wrapcloseterm: Called on %s' % widget) + if self.closeterm(widget): # At this point we only have one child, which is the surviving term sibling = self.children[0] @@ -235,7 +244,6 @@ class Paned(Container): parent.remove(self) self.cnxids.remove_all() parent.add(sibling, metadata) - sibling.grab_focus() del(self) else: dbg("Paned::wrapcloseterm: self.closeterm failed")