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.
This commit is contained in:
parent
5a73f5d2c1
commit
22fab87311
@ -22,8 +22,9 @@
|
|||||||
import functools
|
import functools
|
||||||
|
|
||||||
from PyQt5.QtGui import QWindow
|
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.QtWidgets import QApplication
|
||||||
|
from PyQt5.QtWebKitWidgets import QWebView
|
||||||
|
|
||||||
from qutebrowser.keyinput import modeparsers, keyparser
|
from qutebrowser.keyinput import modeparsers, keyparser
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
@ -177,9 +178,13 @@ class ModeManager(QObject):
|
|||||||
handled = handler(event) if handler is not None else False
|
handled = handler(event) if handler is not None else False
|
||||||
|
|
||||||
is_non_alnum = bool(event.modifiers()) or not event.text().strip()
|
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:
|
if handled:
|
||||||
filter_this = True
|
filter_this = True
|
||||||
|
elif is_tab and not isinstance(focus_widget, QWebView):
|
||||||
|
filter_this = True
|
||||||
elif (curmode in self.passthrough or
|
elif (curmode in self.passthrough or
|
||||||
self._forward_unbound_keys == 'all' or
|
self._forward_unbound_keys == 'all' or
|
||||||
(self._forward_unbound_keys == 'auto' and is_non_alnum)):
|
(self._forward_unbound_keys == 'auto' and is_non_alnum)):
|
||||||
@ -192,12 +197,11 @@ class ModeManager(QObject):
|
|||||||
|
|
||||||
if curmode != usertypes.KeyMode.insert:
|
if curmode != usertypes.KeyMode.insert:
|
||||||
log.modes.debug("handled: {}, forward-unbound-keys: {}, "
|
log.modes.debug("handled: {}, forward-unbound-keys: {}, "
|
||||||
"passthrough: {}, is_non_alnum: {} --> filter: "
|
"passthrough: {}, is_non_alnum: {}, is_tab {} --> "
|
||||||
"{} (focused: {!r})".format(
|
"filter: {} (focused: {!r})".format(
|
||||||
handled, self._forward_unbound_keys,
|
handled, self._forward_unbound_keys,
|
||||||
curmode in self.passthrough,
|
curmode in self.passthrough, is_non_alnum,
|
||||||
is_non_alnum, filter_this,
|
is_tab, filter_this, focus_widget))
|
||||||
QApplication.instance().focusWidget()))
|
|
||||||
return filter_this
|
return filter_this
|
||||||
|
|
||||||
def _eventFilter_keyrelease(self, event):
|
def _eventFilter_keyrelease(self, event):
|
||||||
|
Loading…
Reference in New Issue
Block a user