diff --git a/TODO b/TODO index 4c58c1e1b..5f62ec30f 100644 --- a/TODO +++ b/TODO @@ -11,8 +11,6 @@ Before 0.1 - Autosave feature (against segfaults/...) - Save tabs feature - More dwb keybindings -- Filter events in QMainWindow, not QApplication - or at least release them when opening other windows, e.g. print dialog - Use :open engine searchterm syntax for searching Crashes diff --git a/qutebrowser/app.py b/qutebrowser/app.py index be935f887..17fa736b1 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -135,6 +135,7 @@ class QuteBrowser(QApplication): self._init_cmds() self.mainwindow = MainWindow() + self.modeman.mainwindow = self.mainwindow self.installEventFilter(self.modeman) self.setQuitOnLastWindowClosed(False) @@ -399,13 +400,6 @@ class QuteBrowser(QApplication): self._quit_status['crash'] = False - # Give key input back for crash dialog - try: - self.removeEventFilter(self.modeman) - except AttributeError: - # self.modeman could be None - pass - if exctype is BdbQuit or not issubclass(exctype, Exception): # pdb exit, KeyboardInterrupt, ... try: diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 8abce25dc..14c6eb701 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -62,6 +62,7 @@ class ModeManager(QObject): Attributes: mode: The current mode (readonly property). passthrough: A list of modes in which to pass through events. + mainwindow: The mainwindow object _handlers: A dictionary of modes and their handlers. _mode_stack: A list of the modes we're currently in, with the active one on the right. @@ -84,6 +85,7 @@ class ModeManager(QObject): def __init__(self, parent=None): super().__init__(parent) + self.mainwindow = None self._handlers = {} self.passthrough = [] self._mode_stack = [] @@ -248,7 +250,10 @@ class ModeManager(QObject): logging.debug("Ignoring event {} for {}".format( debug.EVENTS[typ], obj.__class__.__name__)) return False - + if QApplication.instance().activeWindow() is not self.mainwindow: + # Some other window (print dialog, etc.) is focused so we pass + # the event through. + return False logging.debug("Got event {} for {} in mode {}".format( debug.EVENTS[typ], obj.__class__.__name__, self.mode))