From 7ea7a2f3fd029fc58e78965151974262de2d567a Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Tue, 4 Jul 2017 17:50:07 +0200 Subject: [PATCH] restore maximized state on :fullscreen and when exiting video fullscreen --- qutebrowser/browser/commands.py | 6 +++++- qutebrowser/mainwindow/mainwindow.py | 13 ++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 3d8516fe2..e3b7398ed 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -2171,6 +2171,10 @@ class CommandDispatcher: window = self._tabbed_browser.window() if window.isFullScreen(): - window.showNormal() + if window._restore_maximized: + window.showMaximized() + else: + window.showNormal() else: + window._restore_maximized = window.isMaximized() window.showFullScreen() diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 5ea212b18..d8fe052b1 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -130,6 +130,8 @@ class MainWindow(QWidget): _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. """ def __init__(self, *, private, geometry=None, parent=None): @@ -220,6 +222,7 @@ class MainWindow(QWidget): objreg.get("app").new_window.emit(self) self._restore_fullscreen = False + self._restore_maximized = self.isMaximized() def _init_geometry(self, geometry): """Initialize the window geometry or load it from disk.""" @@ -488,13 +491,17 @@ class MainWindow(QWidget): def _on_fullscreen_requested(self, on): if on: self._restore_fullscreen = self.isFullScreen() + self._restore_maximized = self.isMaximized() self.showFullScreen() elif not self._restore_fullscreen: - self.showNormal() + if self._restore_maximized: + self.showMaximized() + else: + self.showNormal() else: self._restore_fullscreen = self.isFullScreen() - log.misc.debug('on: {}, restore fullscreen: {}' - .format(on, self._restore_fullscreen)) + log.misc.debug('on: {}, restore fullscreen: {}, restore maximized: {}' + .format(on, self._restore_fullscreen, self._restore_maximized)) @cmdutils.register(instance='main-window', scope='window') @pyqtSlot()