Skip to content

Commit

Permalink
Merge pull request #456 from Vulcalien/master
Browse files Browse the repository at this point in the history
Fixed Issue #425 (hide_window will try to show a destroyed window)
  • Loading branch information
mattrose authored Jul 2, 2021
2 parents c0f4888 + c954002 commit 2d38070
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions terminatorlib/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Window(Container, Gtk.Window):
title = None
isfullscreen = None
ismaximised = None
isDestroyed = False
hidebound = None
hidefunc = None
losefocus_time = 0
Expand Down Expand Up @@ -302,30 +303,32 @@ def on_destroy_event(self, widget, data=None):
terminal.close()
self.cnxids.remove_all()
self.terminator.deregister_window(self)
self.isDestroyed = True
self.destroy()
del(self)

def on_hide_window(self, data=None):
"""Handle a request to hide/show the window"""

if not self.get_property('visible'):
#Don't show if window has just been hidden because of
#lost focus
if (time.time() - self.losefocus_time < 0.1) and \
self.config['hide_on_lose_focus']:
return
if self.position:
self.move(self.position[0], self.position[1])
self.show()
self.grab_focus()
try:
t = GdkX11.x11_get_server_time(self.get_window())
except (TypeError, AttributeError):
t = 0
self.get_window().focus(t)
else:
self.position = self.get_position()
self.hidefunc()
if not self.isDestroyed:
if not self.get_property('visible'):
#Don't show if window has just been hidden because of
#lost focus
if (time.time() - self.losefocus_time < 0.1) and \
self.config['hide_on_lose_focus']:
return
if self.position:
self.move(self.position[0], self.position[1])
self.show()
self.grab_focus()
try:
t = GdkX11.x11_get_server_time(self.get_window())
except (TypeError, AttributeError):
t = 0
self.get_window().focus(t)
else:
self.position = self.get_position()
self.hidefunc()

# pylint: disable-msg=W0613
def on_window_state_changed(self, window, event):
Expand Down

0 comments on commit 2d38070

Please sign in to comment.