From 43918feb4adbcd2e7035b5985309eefe2e2f28c6 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 13 Mar 2018 10:50:41 +0100 Subject: Windows QPA: Fix QWindowsWindowFunctions::SetHasBorderInFullScreen() to work in all cases - Directly apply the flag in case the platform window exists and is in full screen. - Store as a dynamic property in case the platform window is not created yet. Amends 69839e55c13000ee9bf8d8e9d74b70096a92ae51. Task-number: QTBUG-41309 Task-number: QTBUG-66557 Change-Id: I162baecfae4d07a5d5b59c5401bdb605faa7ab68 Reviewed-by: Laszlo Agocs Reviewed-by: Andy Shaw --- src/plugins/platforms/windows/qwindowswindow.cpp | 16 +++++++++++++++- src/plugins/platforms/windows/qwindowswindow.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 159e1250d0..d639f27c1a 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1077,6 +1077,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w, */ const char *QWindowsWindow::embeddedNativeParentHandleProperty = "_q_embedded_native_parent_handle"; +const char *QWindowsWindow::hasBorderInFullScreenProperty = "_q_has_border_in_fullscreen"; QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) : QWindowsBaseWindow(aWindow), @@ -1115,6 +1116,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) if (aWindow->isTopLevel()) setWindowIcon(aWindow->icon()); + if (aWindow->property(hasBorderInFullScreenProperty).toBool()) + setFlag(HasBorderInFullScreen); clearFlag(WithinCreate); } @@ -2662,15 +2665,26 @@ void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border if (QPlatformWindow *handle = window->handle()) static_cast(handle)->setHasBorderInFullScreen(border); else - qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO); + window->setProperty(hasBorderInFullScreenProperty, QVariant(border)); } void QWindowsWindow::setHasBorderInFullScreen(bool border) { + if (testFlag(HasBorderInFullScreen) == border) + return; if (border) setFlag(HasBorderInFullScreen); else clearFlag(HasBorderInFullScreen); + // Directly apply the flag in case we are fullscreen. + if (m_windowState == Qt::WindowFullScreen) { + LONG_PTR style = GetWindowLongPtr(handle(), GWL_STYLE); + if (border) + style |= WS_BORDER; + else + style &= ~WS_BORDER; + SetWindowLongPtr(handle(), GWL_STYLE, style); + } } QString QWindowsWindow::formatWindowTitle(const QString &title) diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 8d29b871bf..fe2518e329 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -340,6 +340,7 @@ public: static QString formatWindowTitle(const QString &title); static const char *embeddedNativeParentHandleProperty; + static const char *hasBorderInFullScreenProperty; private: inline void show_sys() const; -- cgit v1.2.3