From 16c2268d092c4cd2977ded6e9fe8f7dd027557e0 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 9 Aug 2016 20:18:43 +0200 Subject: [PATCH] Fix last-focused-main-window's behavior Right now, get('last-focused-main-window') essentially returns the same as qApp.activeWindow(), since it's None when no window is focused. This seems somewhat contrary to its original intent, so I've changed it to only ever update the object. This actually fixes another bug as well: on_focus_changed's new is not always a MainWindow - in fact it's a WebView on my end. To fix this, directly use the QApplication.activeWindow() to find the current focus. That second bit in particular actually some related bugs that probably nobody ever noticed or bothered reporting: * _maybe_hide_mouse_cursor currently pretty much never gets called * :adblock-update doesn't actually show any downloads * ... probably more --- qutebrowser/app.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 295fca1fe..cdcbff460 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -342,16 +342,13 @@ def on_focus_changed(_old, new): if not isinstance(new, QWidget) and new is not None: log.misc.debug("on_focus_changed called with non-QWidget {!r}".format( new)) + return - if new is None or not isinstance(new, mainwindow.MainWindow): - try: - objreg.delete('last-focused-main-window') - except KeyError: - pass - qApp.restoreOverrideCursor() - else: - objreg.register('last-focused-main-window', new.window(), update=True) + if new is not None: _maybe_hide_mouse_cursor() + objreg.register('last-focused-main-window', new.window(), update=True) + else: + qApp.restoreOverrideCursor() def open_desktopservices_url(url):