separated window raising into it's own function

This commit is contained in:
Anton S 2017-10-09 03:08:08 +03:00
parent 91c6847e59
commit 6b7cecc840

View File

@ -71,29 +71,33 @@ def get_window(via_ipc, force_window=False, force_tab=False,
open_target = 'tab-silent' open_target = 'tab-silent'
window = None window = None
raise_window = False should_raise = False
# Try to find the existing tab target if opening in a tab # Try to find the existing tab target if opening in a tab
if open_target != 'window': if open_target != 'window':
window = get_target_window() window = get_target_window()
raise_window = open_target not in ['tab-silent', 'tab-bg-silent'] should_raise = open_target not in ['tab-silent', 'tab-bg-silent']
# Otherwise, or if no window was found, create a new one # Otherwise, or if no window was found, create a new one
if window is None: if window is None:
window = MainWindow(private=None) window = MainWindow(private=None)
window.show() window.show()
raise_window = True should_raise = True
if raise_window: if should_raise:
window.setWindowState(window.windowState() & ~Qt.WindowMinimized) raise_window(window)
window.setWindowState(window.windowState() | Qt.WindowActive)
window.raise_()
window.activateWindow()
QApplication.instance().alert(window)
return window.win_id return window.win_id
def raise_window(window):
window.setWindowState(window.windowState() & ~Qt.WindowMinimized)
window.setWindowState(window.windowState() | Qt.WindowActive)
window.raise_()
window.activateWindow()
QApplication.instance().alert(window)
def get_target_window(): def get_target_window():
"""Get the target window for new tabs, or None if none exist.""" """Get the target window for new tabs, or None if none exist."""
try: try: