From 59590540284897f3d09982c492fccfc4c61c758c Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Thu, 22 Aug 2024 08:30:12 +0000 Subject: [PATCH] sync: from linuxdeepin/dtkdeclarative Synchronize source files from linuxdeepin/dtkdeclarative. Source-pull-request: https://github.com/linuxdeepin/dtkdeclarative/pull/380 --- src/dquickwindow.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/dquickwindow.cpp b/src/dquickwindow.cpp index 101791e6..57c667ad 100644 --- a/src/dquickwindow.cpp +++ b/src/dquickwindow.cpp @@ -16,6 +16,27 @@ #include +// Fix top level window flags in case only the type flags are passed. +static inline void fixTopLevelWindowFlags(Qt::WindowFlags &flags) +{ + // Not supported on Windows, also do correction when it is set. + flags &= ~Qt::WindowFullscreenButtonHint; + switch (flags) { + case Qt::Window: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint + |Qt::WindowMaximizeButtonHint|Qt::WindowCloseButtonHint; + break; + case Qt::Dialog: + case Qt::Tool: + flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint; + break; + default: + break; + } + if ((flags & Qt::WindowType_Mask) == Qt::SplashScreen) + flags |= Qt::FramelessWindowHint; +} + DQUICK_BEGIN_NAMESPACE DQuickWindowPrivate::DQuickWindowPrivate(DQuickWindow *qq) @@ -319,6 +340,12 @@ DQuickWindowAttached::DQuickWindowAttached(QWindow *window) : QObject(window) , DObject(*new DQuickWindowAttachedPrivate(window, this)) { + auto windowFlags = window->flags(); + if (window->isTopLevel()) { + fixTopLevelWindowFlags(windowFlags); + window->setFlags(windowFlags); + } + window->installEventFilter(this); QObject::connect(DWindowManagerHelper::instance(), SIGNAL(windowMotifWMHintsChanged(quint32)), this, SLOT(_q_onWindowMotifHintsChanged(quint32)));