From 20db65e430beb7bbe9f6f0b895dcaea34c64cd55 Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Tue, 4 Jul 2017 22:56:44 +0200 Subject: [PATCH] preserve window state when exiting video fullscreen --- qutebrowser/browser/commands.py | 7 ++----- qutebrowser/mainwindow/mainwindow.py | 22 ++++++---------------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index e3b7398ed..080c3e209 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -2171,10 +2171,7 @@ class CommandDispatcher: window = self._tabbed_browser.window() if window.isFullScreen(): - if window._restore_maximized: - window.showMaximized() - else: - window.showNormal() + window.setWindowState(window._state_before_fullscreen & ~Qt.WindowFullScreen) else: - window._restore_maximized = window.isMaximized() + window._state_before_fullscreen = window.windowState() window.showFullScreen() diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index d8fe052b1..2fac3f51a 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -128,10 +128,7 @@ class MainWindow(QWidget): _commandrunner: The main CommandRunner instance. _overlays: Widgets shown as overlay for the current webpage. _private: Whether the window is in private browsing mode. - _restore_fullscreen: Whether to restore the fullscreen after leaving - a video fullscreen. - _restore_maximized: Whether to restore maximized window after leaving - a video fullscreen. + _state_before_fullscreen: window state before activation of fullscreen """ def __init__(self, *, private, geometry=None, parent=None): @@ -221,8 +218,7 @@ class MainWindow(QWidget): objreg.get("app").new_window.emit(self) - self._restore_fullscreen = False - self._restore_maximized = self.isMaximized() + self._state_before_fullscreen = self.windowState() def _init_geometry(self, geometry): """Initialize the window geometry or load it from disk.""" @@ -490,18 +486,12 @@ class MainWindow(QWidget): @pyqtSlot(bool) def _on_fullscreen_requested(self, on): if on: - self._restore_fullscreen = self.isFullScreen() - self._restore_maximized = self.isMaximized() + self._state_before_fullscreen = self.windowState() self.showFullScreen() - elif not self._restore_fullscreen: - if self._restore_maximized: - self.showMaximized() - else: - self.showNormal() else: - self._restore_fullscreen = self.isFullScreen() - log.misc.debug('on: {}, restore fullscreen: {}, restore maximized: {}' - .format(on, self._restore_fullscreen, self._restore_maximized)) + self.setWindowState(self._state_before_fullscreen) + log.misc.debug('on: {}, state before fullscreen: {}' + .format(on, self._state_before_fullscreen)) @cmdutils.register(instance='main-window', scope='window') @pyqtSlot()