set-has-border-in-full-screen-default.patch 6.37 KB
Newer Older
Boudewijn Rempt's avatar
Boudewijn Rempt committed
1
diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
Boudewijn Rempt's avatar
Boudewijn Rempt committed
2
index e51c2fde6..032dcafa6 100644
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
--- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
+++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.h
@@ -81,6 +81,15 @@ public:
             func(window, border);
     }
 
+    typedef void (*SetHasBorderInFullScreenDefault)(bool border);
+    static const QByteArray setHasBorderInFullScreenDefaultIdentifier() { return QByteArrayLiteral("WindowsSetHasBorderInFullScreenDefault"); }
+    static void setHasBorderInFullScreenDefault(bool border)
+    {
+        auto func = reinterpret_cast<SetHasBorderInFullScreenDefault>(QGuiApplication::platformFunction(setHasBorderInFullScreenDefaultIdentifier()));
+        if (func)
+            func(border);
+    }
+
     typedef void (*SetWindowActivationBehaviorType)(WindowActivationBehavior);
     static const QByteArray setWindowActivationBehaviorIdentifier() { return QByteArrayLiteral("WindowsSetWindowActivationBehavior"); }
 
Boudewijn Rempt's avatar
Boudewijn Rempt committed
21
diff --git a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
Boudewijn Rempt's avatar
Boudewijn Rempt committed
22
index a52bbe061..0c52cde75 100644
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
--- a/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
+++ b/src/platformheaders/windowsfunctions/qwindowswindowfunctions.qdoc
@@ -93,7 +93,40 @@
     is true then it will enable the WS_BORDER flag in full screen mode to enable other top level windows
     inside the application to appear on top when required.
 
+    \note The setting must be applied before showing the window or switching it
+    to full screen. For QML, setHasBorderInFullScreenDefault() can be used to
+    set a default value.
+
+    See also \l [QtDoc] {Fullscreen OpenGL Based Windows}
+*/
+
+/*!
+    \typedef QWindowsWindowFunctions::SetHasBorderInFullScreenDefault
+    \since 5.13
+
+    This is the typedef for the function returned by QGuiApplication::platformFunction
+    when passed setHasBorderInFullScreenDefaultIdentifier.
+*/
+
+/*!
+    \fn QByteArray QWindowsWindowFunctions::setHasBorderInFullScreenDefaultIdentifier()
+    \since 5.13
+
+    This function returns the bytearray that can be used to query
+    QGuiApplication::platformFunction to retrieve the SetHasBorderInFullScreen function.
+*/
+
+/*!
+    \fn void QWindowsWindowFunctions::setHasBorderInFullScreenDefault(bool border)
+    \since 5.13
+
+    This is a convenience function that can be used directly instead of resolving
+    the function pointer. \a border will be relayed to the function retrieved by
+    QGuiApplication. When \a border is true, the WS_BORDER flag will be set
+    in full screen mode for all windows by default.
+
     See also \l [QtDoc] {Fullscreen OpenGL Based Windows}
+    \sa setHasBorderInFullScreen()
 */
 
 /*!
Boudewijn Rempt's avatar
Boudewijn Rempt committed
66
diff --git a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
Boudewijn Rempt's avatar
Boudewijn Rempt committed
67
index ed945ec4b..9003e94c5 100644
68 69
--- a/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
+++ b/src/plugins/platforms/windows/qwindowsnativeinterface.cpp
Boudewijn Rempt's avatar
Boudewijn Rempt committed
70
@@ -277,6 +277,8 @@ QFunctionPointer QWindowsNativeInterface::platformFunction(const QByteArray &fun
71 72 73 74 75 76 77 78
         return QFunctionPointer(QWindowsWindow::setTouchWindowTouchTypeStatic);
     if (function == QWindowsWindowFunctions::setHasBorderInFullScreenIdentifier())
         return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenStatic);
+    if (function == QWindowsWindowFunctions::setHasBorderInFullScreenDefaultIdentifier())
+        return QFunctionPointer(QWindowsWindow::setHasBorderInFullScreenDefault);
     if (function == QWindowsWindowFunctions::setWindowActivationBehaviorIdentifier())
         return QFunctionPointer(QWindowsNativeInterface::setWindowActivationBehavior);
     if (function == QWindowsWindowFunctions::isTabletModeIdentifier())
Boudewijn Rempt's avatar
Boudewijn Rempt committed
79
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
Boudewijn Rempt's avatar
Boudewijn Rempt committed
80
index 0376e363f..338e594c7 100644
81 82
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
Boudewijn Rempt's avatar
Boudewijn Rempt committed
83
@@ -1183,6 +1183,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
84 85 86 87 88 89 90
 
 const char *QWindowsWindow::embeddedNativeParentHandleProperty = "_q_embedded_native_parent_handle";
 const char *QWindowsWindow::hasBorderInFullScreenProperty = "_q_has_border_in_fullscreen";
+bool QWindowsWindow::m_borderInFullScreenDefault = false;
 
 QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) :
     QWindowsBaseWindow(aWindow),
Boudewijn Rempt's avatar
Boudewijn Rempt committed
91
@@ -1220,7 +1221,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
92 93 94 95 96 97 98 99
 
     if (aWindow->isTopLevel())
         setWindowIcon(aWindow->icon());
-    if (aWindow->property(hasBorderInFullScreenProperty).toBool())
+    if (m_borderInFullScreenDefault || aWindow->property(hasBorderInFullScreenProperty).toBool())
         setFlag(HasBorderInFullScreen);
     clearFlag(WithinCreate);
 }
Boudewijn Rempt's avatar
Boudewijn Rempt committed
100
@@ -2819,6 +2820,11 @@ void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border
101 102 103 104 105 106 107 108 109 110 111
         window->setProperty(hasBorderInFullScreenProperty, QVariant(border));
 }
 
+void QWindowsWindow::setHasBorderInFullScreenDefault(bool border)
+{
+    m_borderInFullScreenDefault = border;
+}
+
 void QWindowsWindow::setHasBorderInFullScreen(bool border)
 {
     if (testFlag(HasBorderInFullScreen) == border)
Boudewijn Rempt's avatar
Boudewijn Rempt committed
112
diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h
Boudewijn Rempt's avatar
Boudewijn Rempt committed
113
index 2675990cf..0d8096ddf 100644
114 115
--- a/src/plugins/platforms/windows/qwindowswindow.h
+++ b/src/plugins/platforms/windows/qwindowswindow.h
Boudewijn Rempt's avatar
Boudewijn Rempt committed
116
@@ -342,6 +342,7 @@ public:
117 118 119 120 121 122 123
     static void setTouchWindowTouchTypeStatic(QWindow *window, QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes);
     void registerTouchWindow(QWindowsWindowFunctions::TouchWindowTouchTypes touchTypes = QWindowsWindowFunctions::NormalTouch);
     static void setHasBorderInFullScreenStatic(QWindow *window, bool border);
+    static void setHasBorderInFullScreenDefault(bool border);
     void setHasBorderInFullScreen(bool border);
     static QString formatWindowTitle(const QString &title);
 
Boudewijn Rempt's avatar
Boudewijn Rempt committed
124
@@ -387,6 +388,7 @@ private:
125 126 127 128 129 130 131
     // note: intentionally not using void * in order to avoid breaking x86
     VkSurfaceKHR m_vkSurface = 0;
 #endif
+    static bool m_borderInFullScreenDefault;
 };
 
 #ifndef QT_NO_DEBUG_STREAM