From 3d85444903e81a8ec56844eba3b5fc3addab6898 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Thu, 27 Aug 2015 21:20:19 +0200 Subject: [PATCH] Fix the tab switching if a terminal on another tab exits --- ChangeLog | 2 ++ terminatorlib/paned.py | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3183ce13..d609ea0a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -137,6 +137,8 @@ terminator trunk: appears in the config file (Steve Boddy, LP#1262709) * Fix the way alternatives are set up that cures blurry/incorrect icons in task switchers (Steve Boddy, LP#1067287) + * Fix the tab switching if a terminal on another tab exits (Steve + Boddy, LP#943311) terminator 0.97: * Allow font dimming in inactive terminals diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index 5ec85a8e..120a6fee 100755 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -244,6 +244,21 @@ class Paned(Container): if self.closeterm(widget): # At this point we only have one child, which is the surviving term sibling = self.children[0] + + focus_sibling = True + if self.get_toplevel().is_child_notebook(): + notebook = self.get_toplevel().get_children()[0] + tabnum = notebook.page_num_descendant(widget) + nth_page = notebook.get_nth_page(tabnum) + if notebook.last_active_term[nth_page] == widget.uuid: + notebook.set_last_active_term(sibling.uuid) + notebook.clean_last_active_term() + self.get_toplevel().last_active_term = None + if notebook.get_current_page() != tabnum: + focus_sibling = False + elif self.get_toplevel().last_active_term != widget.uuid: + focus_sibling = False + self.remove(sibling) metadata = None @@ -253,7 +268,8 @@ class Paned(Container): parent.remove(self) self.cnxids.remove_all() parent.add(sibling, metadata) - sibling.grab_focus() + if focus_sibling: + sibling.grab_focus() else: dbg("Paned::wrapcloseterm: self.closeterm failed")