Annoyingly fiddly fix for focus change on active/inactive/tabs terminal exits
This commit is contained in:
parent
e0cedea5b5
commit
aa2f2e8282
|
@ -39,9 +39,10 @@ class Notebook(Container, gtk.Notebook):
|
||||||
child = window.get_child()
|
child = window.get_child()
|
||||||
window.remove(child)
|
window.remove(child)
|
||||||
window.add(self)
|
window.add(self)
|
||||||
|
window_last_active_term = window.last_active_term
|
||||||
self.newtab(widget=child)
|
self.newtab(widget=child)
|
||||||
if window.last_active_term:
|
if window_last_active_term:
|
||||||
self.set_last_active_term(window.last_active_term)
|
self.set_last_active_term(window_last_active_term)
|
||||||
window.last_active_term = None
|
window.last_active_term = None
|
||||||
|
|
||||||
self.show_all()
|
self.show_all()
|
||||||
|
|
|
@ -7,7 +7,7 @@ variants"""
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
import gtk
|
||||||
|
|
||||||
from util import dbg, err
|
from util import dbg, err, enumerate_descendants
|
||||||
from terminator import Terminator
|
from terminator import Terminator
|
||||||
from factory import Factory
|
from factory import Factory
|
||||||
from container import Container
|
from container import Container
|
||||||
|
@ -244,17 +244,22 @@ class Paned(Container):
|
||||||
if self.closeterm(widget):
|
if self.closeterm(widget):
|
||||||
# At this point we only have one child, which is the surviving term
|
# At this point we only have one child, which is the surviving term
|
||||||
sibling = self.children[0]
|
sibling = self.children[0]
|
||||||
|
first_term_sibling = sibling
|
||||||
|
cur_tabnum = None
|
||||||
|
|
||||||
focus_sibling = True
|
focus_sibling = True
|
||||||
if self.get_toplevel().is_child_notebook():
|
if self.get_toplevel().is_child_notebook():
|
||||||
notebook = self.get_toplevel().get_children()[0]
|
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)
|
nth_page = notebook.get_nth_page(tabnum)
|
||||||
if notebook.last_active_term[nth_page] == widget.uuid:
|
exiting_term_was_last_active = (notebook.last_active_term[nth_page] == widget.uuid)
|
||||||
notebook.set_last_active_term(sibling.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()
|
notebook.clean_last_active_term()
|
||||||
self.get_toplevel().last_active_term = None
|
self.get_toplevel().last_active_term = None
|
||||||
if notebook.get_current_page() != tabnum:
|
if cur_tabnum != tabnum:
|
||||||
focus_sibling = False
|
focus_sibling = False
|
||||||
elif self.get_toplevel().last_active_term != widget.uuid:
|
elif self.get_toplevel().last_active_term != widget.uuid:
|
||||||
focus_sibling = False
|
focus_sibling = False
|
||||||
|
@ -268,8 +273,12 @@ class Paned(Container):
|
||||||
parent.remove(self)
|
parent.remove(self)
|
||||||
self.cnxids.remove_all()
|
self.cnxids.remove_all()
|
||||||
parent.add(sibling, metadata)
|
parent.add(sibling, metadata)
|
||||||
|
if cur_tabnum:
|
||||||
|
notebook.set_current_page(cur_tabnum)
|
||||||
if focus_sibling:
|
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:
|
else:
|
||||||
dbg("Paned::wrapcloseterm: self.closeterm failed")
|
dbg("Paned::wrapcloseterm: self.closeterm failed")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue