add func in gtkgui helpers
This commit is contained in:
parent
f5411971c7
commit
878b274481
|
@ -314,3 +314,26 @@ def get_current_desktop(window):
|
||||||
# f.e. prop is ('CARDINAL', 32, [0]) we want 0 or 1.. from [0]
|
# f.e. prop is ('CARDINAL', 32, [0]) we want 0 or 1.. from [0]
|
||||||
current_virtual_desktop_no = prop[2][0]
|
current_virtual_desktop_no = prop[2][0]
|
||||||
return current_virtual_desktop_no
|
return current_virtual_desktop_no
|
||||||
|
|
||||||
|
def possibly_move_window_in_current_desktop(window):
|
||||||
|
'''moves GTK window to current virtual desktop if it is not in the
|
||||||
|
current virtual desktop
|
||||||
|
window is GTK window'''
|
||||||
|
if os.name == 'nt':
|
||||||
|
return
|
||||||
|
|
||||||
|
root_window = gtk.gdk.screen_get_default().get_root_window()
|
||||||
|
# current user's vd
|
||||||
|
current_virtual_desktop_no = get_current_desktop(root_window)
|
||||||
|
|
||||||
|
# vd roster window is in
|
||||||
|
window_virtual_desktop = get_current_desktop(window.window)
|
||||||
|
|
||||||
|
# if one of those is None, something went wrong and we cannot know
|
||||||
|
# VD info, just hide it (default action) and not show it afterwards
|
||||||
|
if None not in (window_virtual_desktop, current_virtual_desktop_no):
|
||||||
|
if current_virtual_desktop_no != window_virtual_desktop:
|
||||||
|
# we are in another VD that the window was
|
||||||
|
# so show it in current VD
|
||||||
|
window.show()
|
||||||
|
|
||||||
|
|
|
@ -265,27 +265,10 @@ class Systray:
|
||||||
# no pending events, so toggle visible/hidden for roster window
|
# no pending events, so toggle visible/hidden for roster window
|
||||||
if win.get_property('visible'): # visible in ANY virtual desktop?
|
if win.get_property('visible'): # visible in ANY virtual desktop?
|
||||||
win.hide() # we hide it from VD that was visible in
|
win.hide() # we hide it from VD that was visible in
|
||||||
|
|
||||||
# but we could be in another VD right now. eg vd2
|
# but we could be in another VD right now. eg vd2
|
||||||
# and we want not only to hide it in vd1 but also show it in vd2
|
# and we want not only to hide it in vd1 but also show it in vd2
|
||||||
|
gtkgui_helpers.possibly_move_window_in_current_desktop(win)
|
||||||
if os.name != 'nt':
|
|
||||||
root_window = gtk.gdk.screen_get_default().get_root_window()
|
|
||||||
# current user's vd
|
|
||||||
current_virtual_desktop_no = gtkgui_helpers.get_current_desktop(
|
|
||||||
root_window)
|
|
||||||
|
|
||||||
# vd roster window is in
|
|
||||||
window_virtual_desktop = gtkgui_helpers.get_current_desktop(
|
|
||||||
win.window)
|
|
||||||
|
|
||||||
# if one of those is None, something went wrong and we cannot know
|
|
||||||
# VD info, just hide it (default action) and not show it afterwards
|
|
||||||
if None not in (window_virtual_desktop, current_virtual_desktop_no):
|
|
||||||
if current_virtual_desktop_no != window_virtual_desktop:
|
|
||||||
# we are in another VD that the window was
|
|
||||||
# so show it in current VD
|
|
||||||
win.show()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
win.present()
|
win.present()
|
||||||
else:
|
else:
|
||||||
|
@ -333,8 +316,10 @@ class Systray:
|
||||||
tv.scroll_to_end()
|
tv.scroll_to_end()
|
||||||
|
|
||||||
def on_middle_click(self):
|
def on_middle_click(self):
|
||||||
|
'''middle click raises window to have complete focus (fe. get kbd events)
|
||||||
|
but if already raised, it hides it'''
|
||||||
win = gajim.interface.roster.window
|
win = gajim.interface.roster.window
|
||||||
if win.is_active():
|
if win.is_active(): # is it fully raised? (eg does it receive kbd events?)
|
||||||
win.hide()
|
win.hide()
|
||||||
else:
|
else:
|
||||||
win.present()
|
win.present()
|
||||||
|
|
Loading…
Reference in New Issue