diff --git a/qutebrowser/keyinput/modeman.py b/qutebrowser/keyinput/modeman.py index 075e6d51e..d9a0cd29f 100644 --- a/qutebrowser/keyinput/modeman.py +++ b/qutebrowser/keyinput/modeman.py @@ -220,9 +220,11 @@ class ModeManager(QObject): if curmode != usertypes.KeyMode.insert: log.modes.debug("handled: {}, forward-unbound-keys: {}, " "passthrough: {}, is_non_alnum: {} --> filter: " - "{}".format(handled, self._forward_unbound_keys, - curmode in self.passthrough, - is_non_alnum, filter_this)) + "{} (focused: {!r})".format( + handled, self._forward_unbound_keys, + curmode in self.passthrough, + is_non_alnum, filter_this, + QApplication.instance().focusWidget())) return filter_this def _eventFilter_keyrelease(self, event): diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index af6d01de7..15eaf4581 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -215,7 +215,7 @@ class MainWindow(QWidget): cmd.got_cmd.connect(self._commandrunner.run_safely) cmd.got_search.connect(search_runner.search) cmd.got_search_rev.connect(search_runner.search_rev) - cmd.returnPressed.connect(tabs.setFocus) + cmd.returnPressed.connect(tabs.on_cmd_return_pressed) search_runner.do_search.connect(tabs.search) tabs.got_cmd.connect(self._commandrunner.run_safely) diff --git a/qutebrowser/widgets/statusbar/command.py b/qutebrowser/widgets/statusbar/command.py index 211a0c4aa..a1ad7c46c 100644 --- a/qutebrowser/widgets/statusbar/command.py +++ b/qutebrowser/widgets/statusbar/command.py @@ -153,6 +153,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): # won't change, so we make sure we emit update_completion. self.update_completion.emit(self.prefix(), self.split(), self._cursor_part) + log.modes.debug("Setting command text, focusing {!r}".format(self)) self.setFocus() self.show_cmd.emit() @@ -212,6 +213,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): text += ' ' self.setText(text) log.completion.debug("Placing cursor after '{}'".format(cursor_str)) + log.modes.debug("Completion triggered, focusing {!r}".format(self)) self.setCursorPosition(len(cursor_str)) self.setFocus() self.show_cmd.emit() diff --git a/qutebrowser/widgets/statusbar/prompter.py b/qutebrowser/widgets/statusbar/prompter.py index 55ea8720f..60c96790d 100644 --- a/qutebrowser/widgets/statusbar/prompter.py +++ b/qutebrowser/widgets/statusbar/prompter.py @@ -162,6 +162,8 @@ class Prompter(QObject): mode = usertypes.KeyMode.prompt else: raise ValueError("Invalid prompt mode!") + log.modes.debug("Question asked, focusing {!r}".format( + prompt.lineedit)) prompt.lineedit.setFocus() self.show_prompt.emit() self._busy = True diff --git a/qutebrowser/widgets/tabbedbrowser.py b/qutebrowser/widgets/tabbedbrowser.py index 38dba3cbc..6317d91bb 100644 --- a/qutebrowser/widgets/tabbedbrowser.py +++ b/qutebrowser/widgets/tabbedbrowser.py @@ -497,6 +497,7 @@ class TabbedBrowser(tabwidget.TabWidget): """Give focus to current tab if command mode was left.""" if mode == usertypes.KeyMode.command: widget = self.currentWidget() + log.modes.debug("Left command mode, focusing {!r}".format(widget)) if widget is None: return widget.setFocus() @@ -508,6 +509,7 @@ class TabbedBrowser(tabwidget.TabWidget): # closing the last tab (before quitting) return tab = self.widget(idx) + log.modes.debug("Current tab changed, focusing {!r}".format(tab)) tab.setFocus() modeman.maybe_leave(self._win_id, usertypes.KeyMode.hint, 'tab changed') @@ -520,6 +522,11 @@ class TabbedBrowser(tabwidget.TabWidget): self._tab_insert_idx_left = self.currentIndex() self._tab_insert_idx_right = self.currentIndex() + 1 + @pyqtSlot() + def on_cmd_return_pressed(self): + """Set focus when the commandline closes.""" + log.modes.debug("Commandline closed, focusing {!r}".format(self)) + def on_load_progress(self, tab, perc): """Adjust tab indicator on load progress.""" try: diff --git a/qutebrowser/widgets/webview.py b/qutebrowser/widgets/webview.py index 4f390e69e..32622462b 100644 --- a/qutebrowser/widgets/webview.py +++ b/qutebrowser/widgets/webview.py @@ -328,6 +328,7 @@ class WebView(QWebView): @pyqtSlot('QMouseEvent') def on_mouse_event(self, evt): """Post a new mouseevent from a hintmanager.""" + log.modes.debug("Hint triggered, focusing {!r}".format(self)) self.setFocus() QApplication.postEvent(self, evt)