diff options
author | Anton S <residentsummer@gmail.com> | 2017-10-09 03:08:08 +0300 |
---|---|---|
committer | Anton S <residentsummer@gmail.com> | 2017-10-10 01:00:33 +0300 |
commit | 6b7cecc84083775f558772beb76be542e119b62b (patch) | |
tree | abd5f370a673716cfb85accdd942fecda1ecd786 | |
parent | 91c6847e5991bd4d7524614b598d83a66f0ecb94 (diff) | |
download | qutebrowser-6b7cecc84083775f558772beb76be542e119b62b.tar.gz qutebrowser-6b7cecc84083775f558772beb76be542e119b62b.zip |
separated window raising into it's own function
-rw-r--r-- | qutebrowser/mainwindow/mainwindow.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 373a9030a..28bd0ef72 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -71,29 +71,33 @@ def get_window(via_ipc, force_window=False, force_tab=False, open_target = 'tab-silent' window = None - raise_window = False + should_raise = False # Try to find the existing tab target if opening in a tab if open_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 if window is None: window = MainWindow(private=None) window.show() - raise_window = True + should_raise = True - if raise_window: - window.setWindowState(window.windowState() & ~Qt.WindowMinimized) - window.setWindowState(window.windowState() | Qt.WindowActive) - window.raise_() - window.activateWindow() - QApplication.instance().alert(window) + if should_raise: + raise_window(window) 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(): """Get the target window for new tabs, or None if none exist.""" try: |