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
This commit is contained in:
parent
fb3da578c5
commit
16c2268d09
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user