From 066acd779ae14b3914617855159a1c8305eb6e1a Mon Sep 17 00:00:00 2001 From: Matthew Rose Date: Tue, 28 Feb 2023 21:42:29 -0500 Subject: [PATCH 1/3] Remove hack to ensure that focus is set. set_focus() should do the trick according to the docs, so let's just use that, and not go to extraordinary measures. --- terminatorlib/terminator.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 0a3f361b..509a0156 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -346,22 +346,11 @@ class Terminator(Borg): t = 0 window.get_window().focus(t) - # Awful workaround to be sure that the last focused window is actually the one focused. - # Don't ask, don't tell policy on this. Even this is not 100% + # Going by the docs, this should be all that's needed to ensure that the + # last_active_window is focussed. if self.last_active_window: window = self.find_window_by_uuid(self.last_active_window.urn) - count = 0 - while count < 1000 and Gtk.events_pending(): - count += 1 - Gtk.main_iteration_do(False) - window.show() - window.grab_focus() - try: - t = GdkX11.x11_get_server_time(window.get_window()) - except (NameError,TypeError, AttributeError): - t = 0 - window.get_window().focus(t) - + window.set_focus() self.prelayout_windows = None def on_gtk_theme_name_notify(self, settings, prop): From ed763df3310ff64b073efc1bf59494da72d44eae Mon Sep 17 00:00:00 2001 From: Matthew Rose Date: Tue, 28 Feb 2023 22:22:57 -0500 Subject: [PATCH 2/3] Further fix to last_active_window --- terminatorlib/terminator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 509a0156..184bf12f 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -350,6 +350,7 @@ class Terminator(Borg): # last_active_window is focussed. if self.last_active_window: window = self.find_window_by_uuid(self.last_active_window.urn) + window.present_with_time(0) window.set_focus() self.prelayout_windows = None From d6d9cce90cc01c4b1b75ff97f248cb3baab62f47 Mon Sep 17 00:00:00 2001 From: Matthew Rose Date: Tue, 28 Feb 2023 22:32:14 -0500 Subject: [PATCH 3/3] should not commit this late at night. --- terminatorlib/terminator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 184bf12f..0fb65660 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -309,6 +309,7 @@ class Terminator(Borg): """Layout operations have finished, record that fact""" self.doing_layout = False maker = Factory() + t = 0 window_last_active_term_mapping = {} for window in self.windows: @@ -350,7 +351,7 @@ class Terminator(Borg): # last_active_window is focussed. if self.last_active_window: window = self.find_window_by_uuid(self.last_active_window.urn) - window.present_with_time(0) + window.present_with_time(t) window.set_focus() self.prelayout_windows = None