summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/windows/qwindowswindowclassdescription.cpp')
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.cpp124
1 files changed, 84 insertions, 40 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
index 63e16260b62..6962d28e7d0 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
@@ -11,68 +11,112 @@ QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;
-QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure)
+QString QWindowsWindowClassDescription::classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon)
{
- return { std::move(name), procedure };
+ QString suffix;
+
+ switch (type) {
+ case Qt::Popup:
+ suffix += "Popup"_L1;
+ break;
+ case Qt::Tool:
+ suffix += "Tool"_L1;
+ break;
+ case Qt::ToolTip:
+ suffix += "ToolTip"_L1;
+ break;
+ default:
+ break;
+ }
+
+ if (style & CS_DROPSHADOW)
+ suffix += "DropShadow"_L1;
+ if (style & CS_SAVEBITS)
+ suffix += "SaveBits"_L1;
+ if (style & CS_OWNDC)
+ suffix += "OwnDC"_L1;
+ if (hasIcon)
+ suffix += "Icon"_L1;
+
+ return suffix;
}
-QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const QWindow *window, WNDPROC procedure)
+bool QWindowsWindowClassDescription::computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type)
{
- Q_ASSERT(window);
-
- QWindowsWindowClassDescription description;
- description.procedure = procedure;
+ bool hasIcon = true;
- const Qt::WindowFlags flags = window->flags();
- const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
- // Determine style and icon.
- description.style = CS_DBLCLKS;
- description.hasIcon = true;
- // The following will not set CS_OWNDC for any widget window, even if it contains a
- // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
- if (window->surfaceType() == QSurface::OpenGLSurface || (flags & Qt::MSWindowsOwnDC))
- description.style |= CS_OWNDC;
- if (!(flags & Qt::NoDropShadowWindowHint)
- && (type == Qt::Popup || window->property("_q_windowsDropShadow").toBool())) {
- description.style |= CS_DROPSHADOW;
- }
switch (type) {
case Qt::Tool:
case Qt::ToolTip:
case Qt::Popup:
- description.style |= CS_SAVEBITS; // Save/restore background
- description.hasIcon = false;
+ hasIcon = false;
break;
case Qt::Dialog:
if (!(flags & Qt::WindowSystemMenuHint))
- description.hasIcon = false; // QTBUG-2027, dialogs without system menu.
+ hasIcon = false; // QTBUG-2027, dialogs without system menu.
break;
}
- // Create a unique name for the flag combination
- description.name = "QWindow"_L1;
+
+ return hasIcon;
+}
+
+unsigned int QWindowsWindowClassDescription::computeWindowStyles(Qt::WindowFlags flags, Qt::WindowFlags type, WindowStyleOptions options)
+{
+ unsigned int style = CS_DBLCLKS;
+
+ // The following will not set CS_OWNDC for any widget window, even if it contains a
+ // QOpenGLWidget or QQuickWidget later on. That cannot be detected at this stage.
+ if (options.testFlag(WindowStyleOption::GLSurface) || (flags & Qt::MSWindowsOwnDC))
+ style |= CS_OWNDC;
+ if (!(flags & Qt::NoDropShadowWindowHint) && (type == Qt::Popup || options.testFlag(WindowStyleOption::DropShadow)))
+ style |= CS_DROPSHADOW;
+
switch (type) {
case Qt::Tool:
- description.name += "Tool"_L1;
- break;
case Qt::ToolTip:
- description.name += "ToolTip"_L1;
- break;
case Qt::Popup:
- description.name += "Popup"_L1;
- break;
- default:
+ style |= CS_SAVEBITS; // Save/restore background
break;
}
- if (description.style & CS_DROPSHADOW)
- description.name += "DropShadow"_L1;
- if (description.style & CS_SAVEBITS)
- description.name += "SaveBits"_L1;
- if (description.style & CS_OWNDC)
- description.name += "OwnDC"_L1;
- if (description.hasIcon)
- description.name += "Icon"_L1;
+
+ return style;
+}
+
+QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure)
+{
+ return { std::move(name), procedure };
+}
+
+QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const QWindow *window, WNDPROC procedure)
+{
+ Q_ASSERT(window);
+
+ const Qt::WindowFlags flags = window->flags();
+ const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
+
+ WindowStyleOptions options = WindowStyleOption::None;
+ if (window->surfaceType() == QSurface::OpenGLSurface)
+ options |= WindowStyleOption::GLSurface;
+ if (window->property("_q_windowsDropShadow").toBool())
+ options |= WindowStyleOption::DropShadow;
+
+ QWindowsWindowClassDescription description;
+ description.procedure = procedure;
+ description.style = computeWindowStyles(flags, type, options);
+ description.hasIcon = computeHasIcon(flags, type);
+ description.name = "QWindow"_L1 + classNameSuffix(type, description.style, description.hasIcon);
return description;
}
+QDebug operator<<(QDebug dbg, const QWindowsWindowClassDescription &description)
+{
+ dbg << description.name
+ << " style=0x" << Qt::hex << description.style << Qt::dec
+ << " brush=" << description.brush
+ << " hasIcon=" << description.hasIcon;
+
+ return dbg;
+}
+
QT_END_NAMESPACE