Fixed window flicker and/or reappearing when hide on lose focus is enabled
This commit is contained in:
parent
fa67c46de2
commit
b30197de06
|
@ -4,6 +4,7 @@
|
||||||
"""window.py - class for the main Terminator window"""
|
"""window.py - class for the main Terminator window"""
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import time
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
import gobject
|
import gobject
|
||||||
|
@ -31,9 +32,9 @@ class Window(Container, gtk.Window):
|
||||||
title = None
|
title = None
|
||||||
isfullscreen = None
|
isfullscreen = None
|
||||||
ismaximised = None
|
ismaximised = None
|
||||||
iswithdrawn = None
|
|
||||||
hidebound = None
|
hidebound = None
|
||||||
hidefunc = None
|
hidefunc = None
|
||||||
|
losefocus_time = 0
|
||||||
position = None
|
position = None
|
||||||
ignore_startup_show = None
|
ignore_startup_show = None
|
||||||
|
|
||||||
|
@ -128,7 +129,6 @@ class Window(Container, gtk.Window):
|
||||||
borderless = self.config['borderless']
|
borderless = self.config['borderless']
|
||||||
skiptaskbar = self.config['hide_from_taskbar']
|
skiptaskbar = self.config['hide_from_taskbar']
|
||||||
alwaysontop = self.config['always_on_top']
|
alwaysontop = self.config['always_on_top']
|
||||||
hideonlosefocus = self.config['hide_on_lose_focus']
|
|
||||||
sticky = self.config['sticky']
|
sticky = self.config['sticky']
|
||||||
|
|
||||||
if options:
|
if options:
|
||||||
|
@ -145,7 +145,6 @@ class Window(Container, gtk.Window):
|
||||||
self.set_maximised(maximise)
|
self.set_maximised(maximise)
|
||||||
self.set_borderless(borderless)
|
self.set_borderless(borderless)
|
||||||
self.set_always_on_top(alwaysontop)
|
self.set_always_on_top(alwaysontop)
|
||||||
self.set_hide_on_lose_focus(hideonlosefocus)
|
|
||||||
self.set_real_transparency()
|
self.set_real_transparency()
|
||||||
self.set_sticky(sticky)
|
self.set_sticky(sticky)
|
||||||
if self.hidebound:
|
if self.hidebound:
|
||||||
|
@ -200,6 +199,11 @@ class Window(Container, gtk.Window):
|
||||||
for terminal in self.get_visible_terminals():
|
for terminal in self.get_visible_terminals():
|
||||||
terminal.on_window_focus_out()
|
terminal.on_window_focus_out()
|
||||||
|
|
||||||
|
self.losefocus_time = time.time()
|
||||||
|
if self.config['hide_on_lose_focus'] and self.get_property('visible'):
|
||||||
|
self.position = self.get_position()
|
||||||
|
self.hidefunc()
|
||||||
|
|
||||||
def on_focus_in(self, window, event):
|
def on_focus_in(self, window, event):
|
||||||
"""Focus has entered the window"""
|
"""Focus has entered the window"""
|
||||||
self.set_urgency_hint(False)
|
self.set_urgency_hint(False)
|
||||||
|
@ -256,7 +260,12 @@ class Window(Container, gtk.Window):
|
||||||
|
|
||||||
def on_hide_window(self, data=None):
|
def on_hide_window(self, data=None):
|
||||||
"""Handle a request to hide/show the window"""
|
"""Handle a request to hide/show the window"""
|
||||||
if self.iswithdrawn == True:
|
|
||||||
|
if not self.get_property('visible'):
|
||||||
|
#Don't show if window has just been hidden because of
|
||||||
|
#e.g. lost focus
|
||||||
|
if time.time() - self.losefocus_time < 0.1:
|
||||||
|
return
|
||||||
if self.position:
|
if self.position:
|
||||||
self.move(self.position[0], self.position[1])
|
self.move(self.position[0], self.position[1])
|
||||||
self.show()
|
self.show()
|
||||||
|
@ -264,11 +273,6 @@ class Window(Container, gtk.Window):
|
||||||
self.position = self.get_position()
|
self.position = self.get_position()
|
||||||
self.hidefunc()
|
self.hidefunc()
|
||||||
|
|
||||||
def on_lose_focus(self, widget, event):
|
|
||||||
"""Handle when window lose focus"""
|
|
||||||
self.position = self.get_position()
|
|
||||||
self.hidefunc()
|
|
||||||
|
|
||||||
# pylint: disable-msg=W0613
|
# pylint: disable-msg=W0613
|
||||||
def on_window_state_changed(self, window, event):
|
def on_window_state_changed(self, window, event):
|
||||||
"""Handle the state of the window changing"""
|
"""Handle the state of the window changing"""
|
||||||
|
@ -276,11 +280,8 @@ class Window(Container, gtk.Window):
|
||||||
gtk.gdk.WINDOW_STATE_FULLSCREEN)
|
gtk.gdk.WINDOW_STATE_FULLSCREEN)
|
||||||
self.ismaximised = bool(event.new_window_state &
|
self.ismaximised = bool(event.new_window_state &
|
||||||
gtk.gdk.WINDOW_STATE_MAXIMIZED)
|
gtk.gdk.WINDOW_STATE_MAXIMIZED)
|
||||||
self.iswithdrawn = bool(event.new_window_state &
|
dbg('Window::on_window_state_changed: fullscreen=%s, maximised=%s' \
|
||||||
gtk.gdk.WINDOW_STATE_WITHDRAWN)
|
% (self.isfullscreen, self.ismaximised))
|
||||||
dbg('Window::on_window_state_changed: fullscreen=%s, maximised=%s,\
|
|
||||||
withdrawn=%s' %
|
|
||||||
(self.isfullscreen, self.ismaximised, self.iswithdrawn))
|
|
||||||
|
|
||||||
return(False)
|
return(False)
|
||||||
|
|
||||||
|
@ -323,11 +324,6 @@ class Window(Container, gtk.Window):
|
||||||
if value == True:
|
if value == True:
|
||||||
self.stick()
|
self.stick()
|
||||||
|
|
||||||
def set_hide_on_lose_focus(self,value):
|
|
||||||
"""Registers the callback for lost focus from the supplied value"""
|
|
||||||
if value == True:
|
|
||||||
self.connect('focus-out-event', self.on_lose_focus)
|
|
||||||
|
|
||||||
def set_real_transparency(self, value=True):
|
def set_real_transparency(self, value=True):
|
||||||
"""Enable RGBA if supported on the current screen"""
|
"""Enable RGBA if supported on the current screen"""
|
||||||
if self.is_composited() == False:
|
if self.is_composited() == False:
|
||||||
|
|
Loading…
Reference in New Issue