diff --git a/ChangeLog b/ChangeLog index c4911458..7ee042e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,8 @@ terminator GTK3: Koblinger, LP#1518596) * Fix right-click for mouse aware apps ((Egmont Koblinger, LP#1518700) + * Fix the tab switching if a terminal on another tab exits (Steve + Boddy, LP#943311) terminator 0.97: diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index f45d092e..54bef799 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -40,9 +40,10 @@ class Notebook(Container, Gtk.Notebook): child = window.get_child() window.remove(child) window.add(self) + window_last_active_term = window.last_active_term self.newtab(widget=child) - if window.last_active_term: - self.set_last_active_term(window.last_active_term) + if window_last_active_term: + self.set_last_active_term(window_last_active_term) window.last_active_term = None self.show_all() diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index 24cd9d74..9fee0673 100755 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -7,7 +7,7 @@ variants""" import time from gi.repository import GObject, Gtk, Gdk -from util import dbg, err +from util import dbg, err, enumerate_descendants from terminator import Terminator from factory import Factory from container import Container @@ -259,6 +259,26 @@ class Paned(Container): if self.closeterm(widget): # At this point we only have one child, which is the surviving term sibling = self.children[0] + first_term_sibling = sibling + cur_tabnum = None + + focus_sibling = True + if self.get_toplevel().is_child_notebook(): + notebook = self.get_toplevel().get_children()[0] + cur_tabnum = notebook.get_current_page() + tabnum = notebook.page_num_descendant(self) + nth_page = notebook.get_nth_page(tabnum) + exiting_term_was_last_active = (notebook.last_active_term[nth_page] == widget.uuid) + if exiting_term_was_last_active: + first_term_sibling = enumerate_descendants(self)[1][0] + notebook.set_last_active_term(first_term_sibling.uuid) + notebook.clean_last_active_term() + self.get_toplevel().last_active_term = None + if cur_tabnum != tabnum: + focus_sibling = False + elif self.get_toplevel().last_active_term != widget.uuid: + focus_sibling = False + self.remove(sibling) metadata = None @@ -268,7 +288,12 @@ class Paned(Container): parent.remove(self) self.cnxids.remove_all() parent.add(sibling, metadata) - sibling.grab_focus() + if cur_tabnum: + notebook.set_current_page(cur_tabnum) + if focus_sibling: + first_term_sibling.grab_focus() + elif not sibling.get_toplevel().is_child_notebook(): + Terminator().find_terminal_by_uuid(sibling.get_toplevel().last_active_term.urn).grab_focus() else: dbg("Paned::wrapcloseterm: self.closeterm failed")