diff options
author | Florian Bruhin <git@the-compiler.org> | 2015-02-12 18:57:56 +0100 |
---|---|---|
committer | Florian Bruhin <git@the-compiler.org> | 2015-03-18 22:17:17 +0100 |
commit | d618892e0914c83905932479d28e1670c996024a (patch) | |
tree | e9367d6cabf432b36e101bcea9e3a9d948122839 | |
parent | 612afc45ef4ea37d71df56b7406cd89a292b19dd (diff) | |
download | qutebrowser-d618892e0914c83905932479d28e1670c996024a.tar.gz qutebrowser-d618892e0914c83905932479d28e1670c996024a.zip |
Ignore tab key presses if they'd switch focus.
If the mainwindow is focused but not the web view (e.g. in prompt mode), an
unbound tab key should be filtered so it doesn't change keyboard focus.
Fixes #504.
-rw-r--r-- | qutebrowser/keyinput/modeman.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 57c5fd86b..1d4aca57a 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -26,8 +26,9 @@ Module attributes: import functools from PyQt5.QtGui import QWindow -from PyQt5.QtCore import pyqtSignal, QObject, QEvent +from PyQt5.QtCore import pyqtSignal, Qt, QObject, QEvent from PyQt5.QtWidgets import QApplication +from PyQt5.QtWebKitWidgets import QWebView from qutebrowser.keyinput import modeparsers, keyparser from qutebrowser.config import config @@ -181,9 +182,13 @@ class ModeManager(QObject): handled = handler(event) if handler is not None else False is_non_alnum = bool(event.modifiers()) or not event.text().strip() + focus_widget = QApplication.instance().focusWidget() + is_tab = event.key() in (Qt.Key_Tab, Qt.Key_Backtab) if handled: filter_this = True + elif is_tab and not isinstance(focus_widget, QWebView): + filter_this = True elif (curmode in self.passthrough or self._forward_unbound_keys == 'all' or (self._forward_unbound_keys == 'auto' and is_non_alnum)): @@ -196,12 +201,11 @@ class ModeManager(QObject): if curmode != usertypes.KeyMode.insert: log.modes.debug("handled: {}, forward-unbound-keys: {}, " - "passthrough: {}, is_non_alnum: {} --> filter: " - "{} (focused: {!r})".format( + "passthrough: {}, is_non_alnum: {}, is_tab {} --> " + "filter: {} (focused: {!r})".format( handled, self._forward_unbound_keys, - curmode in self.passthrough, - is_non_alnum, filter_this, - QApplication.instance().focusWidget())) + curmode in self.passthrough, is_non_alnum, + is_tab, filter_this, focus_widget)) return filter_this def _eventFilter_keyrelease(self, event): |