Merge pull request #81 from monsta/better-focusout-blocking

Better logic in focus-out-event blocking/unblocking
This commit is contained in:
Clement Lefebvre 2014-04-02 12:25:23 +01:00
commit 2cc7f19546

View File

@ -87,6 +87,7 @@ class MainWindow( object ):
self.window.connect( "key-press-event", self.onKeyPress )
self.window.connect( "focus-in-event", self.onFocusIn )
self.loseFocusId = self.window.connect( "focus-out-event", self.onFocusOut )
self.loseFocusBlocked = False
self.window.stick()
@ -462,17 +463,9 @@ class MainWindow( object ):
self.window.hide()
def onFocusIn( self, *args ):
def dummy( *args ): pass
signalId = GObject.signal_lookup( "focus-out-event", self.window )
while True:
result = GObject.signal_handler_find( self.window,
GObject.SignalMatchType.ID | GObject.SignalMatchType.UNBLOCKED,
signalId, 0, None, dummy, dummy )
if result == 0:
if self.loseFocusBlocked:
self.window.handler_unblock( self.loseFocusId )
else:
break
self.loseFocusBlocked = False
return False
@ -482,7 +475,9 @@ class MainWindow( object ):
return False
def stopHiding( self ):
if not self.loseFocusBlocked:
self.window.handler_block( self.loseFocusId )
self.loseFocusBlocked = True
class MenuWin( object ):
def __init__( self, applet, iid ):