From b1a060fb717865c338af5b4f5063bfb31e8ef74f Mon Sep 17 00:00:00 2001 From: Hendrik R Date: Sun, 15 Jul 2018 14:31:03 +0200 Subject: [PATCH] Process all events before issuing an alert Fixes #2603 The call to processEvents fixes an apparent race condition with some window managers, e.g. i3. QT seems to be thinking, that the window is not marked as urgent and toggles it twice, so synchronizing before issuing the alert makes QT behave correctly. This change should not change the behaviour on other systems only correct the fault reported in #2603. --- qutebrowser/mainwindow/mainwindow.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 4cfee7eff..b95de54fc 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -24,7 +24,8 @@ import base64 import itertools import functools -from PyQt5.QtCore import pyqtSlot, QRect, QPoint, QTimer, Qt +from PyQt5.QtCore import (pyqtSlot, QRect, QPoint, QTimer, Qt, + QCoreApplication, QEventLoop) from PyQt5.QtWidgets import QWidget, QVBoxLayout, QApplication, QSizePolicy from qutebrowser.commands import runners, cmdutils @@ -98,6 +99,8 @@ def raise_window(window, alert=True): window.setWindowState(window.windowState() & ~Qt.WindowMinimized) window.setWindowState(window.windowState() | Qt.WindowActive) window.raise_() + QCoreApplication.processEvents( + QEventLoop.ExcludeUserInputEvents | QEventLoop.ExcludeSocketNotifiers) window.activateWindow() if alert: