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 <laszlo.agocs@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
This commit is contained in:
Friedemann Kleint 2018-03-13 10:50:41 +01:00
parent 910cc08f6b
commit 43918feb4a
2 changed files with 16 additions and 1 deletions

View File

@ -1077,6 +1077,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
*/ */
const char *QWindowsWindow::embeddedNativeParentHandleProperty = "_q_embedded_native_parent_handle"; 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) : QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data) :
QWindowsBaseWindow(aWindow), QWindowsBaseWindow(aWindow),
@ -1115,6 +1116,8 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
if (aWindow->isTopLevel()) if (aWindow->isTopLevel())
setWindowIcon(aWindow->icon()); setWindowIcon(aWindow->icon());
if (aWindow->property(hasBorderInFullScreenProperty).toBool())
setFlag(HasBorderInFullScreen);
clearFlag(WithinCreate); clearFlag(WithinCreate);
} }
@ -2662,15 +2665,26 @@ void QWindowsWindow::setHasBorderInFullScreenStatic(QWindow *window, bool border
if (QPlatformWindow *handle = window->handle()) if (QPlatformWindow *handle = window->handle())
static_cast<QWindowsWindow *>(handle)->setHasBorderInFullScreen(border); static_cast<QWindowsWindow *>(handle)->setHasBorderInFullScreen(border);
else else
qWarning("%s invoked without window handle; call has no effect.", Q_FUNC_INFO); window->setProperty(hasBorderInFullScreenProperty, QVariant(border));
} }
void QWindowsWindow::setHasBorderInFullScreen(bool border) void QWindowsWindow::setHasBorderInFullScreen(bool border)
{ {
if (testFlag(HasBorderInFullScreen) == border)
return;
if (border) if (border)
setFlag(HasBorderInFullScreen); setFlag(HasBorderInFullScreen);
else else
clearFlag(HasBorderInFullScreen); 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) QString QWindowsWindow::formatWindowTitle(const QString &title)

View File

@ -340,6 +340,7 @@ public:
static QString formatWindowTitle(const QString &title); static QString formatWindowTitle(const QString &title);
static const char *embeddedNativeParentHandleProperty; static const char *embeddedNativeParentHandleProperty;
static const char *hasBorderInFullScreenProperty;
private: private:
inline void show_sys() const; inline void show_sys() const;