Annoyingly fiddly fix for focus change on active/inactive/tabs terminal exits

This commit is contained in:
Stephen Boddy 2015-09-07 04:03:24 +02:00
parent e0cedea5b5
commit aa2f2e8282
2 changed files with 18 additions and 8 deletions

View File

@ -39,9 +39,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()

View File

@ -7,7 +7,7 @@ variants"""
import gobject
import gtk
from util import dbg, err
from util import dbg, err, enumerate_descendants
from terminator import Terminator
from factory import Factory
from container import Container
@ -244,17 +244,22 @@ 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]
tabnum = notebook.page_num_descendant(widget)
cur_tabnum = notebook.get_current_page()
tabnum = notebook.page_num_descendant(self)
nth_page = notebook.get_nth_page(tabnum)
if notebook.last_active_term[nth_page] == widget.uuid:
notebook.set_last_active_term(sibling.uuid)
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 notebook.get_current_page() != tabnum:
if cur_tabnum != tabnum:
focus_sibling = False
elif self.get_toplevel().last_active_term != widget.uuid:
focus_sibling = False
@ -268,8 +273,12 @@ class Paned(Container):
parent.remove(self)
self.cnxids.remove_all()
parent.add(sibling, metadata)
if cur_tabnum:
notebook.set_current_page(cur_tabnum)
if focus_sibling:
sibling.grab_focus()
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")