summaryrefslogtreecommitdiff
path: root/www-client/qupzilla/files/qupzilla-2.1.2-fullscreen.patch
blob: c18b4210f40b4b62517e1a04773a652d8f4486ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From 5812721e4822ae363866df2cc9fc762b25061c92 Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Sat, 19 Aug 2017 18:52:26 +0200
Subject: [PATCH] BrowserWindow: Fix failing to enter fullscreen sometimes

---
 src/lib/app/browserwindow.cpp | 23 ++++++++++++++++-------
 src/lib/app/browserwindow.h   |  5 ++++-
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp
index 1eab597d7..2a41fddf2 100644
--- a/src/lib/app/browserwindow.cpp
+++ b/src/lib/app/browserwindow.cpp
@@ -683,6 +683,15 @@ void BrowserWindow::showSource(WebView *view)
     view->showSource();
 }
 
+void BrowserWindow::showNormal()
+{
+    if (m_normalWindowState & Qt::WindowMaximized) {
+        QMainWindow::showMaximized();
+    } else {
+        QMainWindow::showNormal();
+    }
+}
+
 SideBar* BrowserWindow::addSideBar()
 {
     if (m_sideBar) {
@@ -786,9 +795,9 @@ void BrowserWindow::toggleFullScreen()
     }
 
     if (isFullScreen())
-        setWindowState(windowState() & ~Qt::WindowFullScreen);
+        showNormal();
     else
-        setWindowState(windowState() | Qt::WindowFullScreen);
+        showFullScreen();
 }
 
 void BrowserWindow::enterHtmlFullScreen()
@@ -1049,9 +1058,9 @@ bool BrowserWindow::event(QEvent* event)
     case QEvent::WindowStateChange: {
         QWindowStateChangeEvent* ev = static_cast<QWindowStateChangeEvent*>(event);
 
-        if (!(ev->oldState() & Qt::WindowFullScreen) && windowState() & Qt::WindowFullScreen) {
+        if (!(m_oldWindowState & Qt::WindowFullScreen) && windowState() & Qt::WindowFullScreen) {
             // Enter fullscreen
-            m_windowStates = ev->oldState();
+            m_normalWindowState = m_oldWindowState;
 
             m_statusBarVisible = statusBar()->isVisible();
 #ifndef Q_OS_MACOS
@@ -1063,7 +1072,7 @@ bool BrowserWindow::event(QEvent* event)
             m_navigationContainer->hide();
             m_navigationToolbar->buttonExitFullscreen()->show();
         }
-        else if (ev->oldState() & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) {
+        else if (m_oldWindowState & Qt::WindowFullScreen && !(windowState() & Qt::WindowFullScreen)) {
             // Leave fullscreen
             statusBar()->setVisible(m_statusBarVisible);
 #ifndef Q_OS_MACOS
@@ -1074,13 +1083,13 @@ bool BrowserWindow::event(QEvent* event)
             m_navigationToolbar->setSuperMenuVisible(!m_menuBarVisible);
             m_navigationToolbar->buttonExitFullscreen()->hide();
             m_isHtmlFullScreen = false;
-
-            setWindowState(m_windowStates);
         }
 
         if (m_hideNavigationTimer) {
             m_hideNavigationTimer->stop();
         }
+
+        m_oldWindowState = windowState();
         break;
     }
 
diff --git a/src/lib/app/browserwindow.h b/src/lib/app/browserwindow.h
index 51d4023ce..5e326fc34 100644
--- a/src/lib/app/browserwindow.h
+++ b/src/lib/app/browserwindow.h
@@ -141,6 +141,8 @@ public slots:
     void loadAddress(const QUrl &url);
     void showSource(WebView *view = Q_NULLPTR);
 
+    void showNormal();
+
 private slots:
     void addTab();
     void openLocation();
@@ -211,7 +213,8 @@ private slots:
     bool m_menuBarVisible;
     bool m_statusBarVisible;
     bool m_isHtmlFullScreen;
-    Qt::WindowStates m_windowStates;
+    Qt::WindowStates m_oldWindowState = Qt::WindowNoState;
+    Qt::WindowStates m_normalWindowState = Qt::WindowNoState;
     QTimer* m_hideNavigationTimer;
 
     QList<QPointer<QWidget> > m_deleteOnCloseWidgets;