summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Dubsky <[email protected]>2025-11-20 18:35:43 +0100
committerPavel Dubsky <[email protected]>2025-11-29 02:52:25 +0100
commit3d75ca4ceb92890184bbfc9814979e7f7f4ec495 (patch)
treefdf80c73220cb5196802fcb627bf1d4ac3ef1653
parent1bd59107e35b972348c84ea428a5716ec8b5eacd (diff)
Add computeWindowStyles helper to window class registry
Introduced computeWindowStyles to centralize logic for determining window class style flags based on window type, surface type, and properties like drop shadows. Change-Id: I3c3ddeb89b462f7a25754ae51e605f1fade7cf7f Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.cpp52
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.h11
2 files changed, 43 insertions, 20 deletions
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
index 55e36b4587a..6962d28e7d0 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
@@ -60,6 +60,28 @@ bool QWindowsWindowClassDescription::computeHasIcon(Qt::WindowFlags flags, Qt::W
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:
+ case Qt::ToolTip:
+ case Qt::Popup:
+ style |= CS_SAVEBITS; // Save/restore background
+ break;
+ }
+
+ return style;
+}
+
QWindowsWindowClassDescription QWindowsWindowClassDescription::fromName(QString name, WNDPROC procedure)
{
return { std::move(name), procedure };
@@ -69,29 +91,19 @@ QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const
{
Q_ASSERT(window);
- QWindowsWindowClassDescription description;
- description.procedure = procedure;
-
const Qt::WindowFlags flags = window->flags();
const Qt::WindowFlags type = flags & Qt::WindowType_Mask;
- // Determine style and icon.
- description.style = CS_DBLCLKS;
+
+ 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);
- // 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
- break;
- }
description.name = "QWindow"_L1 + classNameSuffix(type, description.style, description.hasIcon);
return description;
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.h b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
index 78d99b4c525..f0019f8f3c2 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
@@ -14,6 +14,14 @@ class QWindow;
struct QWindowsWindowClassDescription
{
+ enum class WindowStyleOption
+ {
+ None = 0x00,
+ GLSurface = 0x01,
+ DropShadow = 0x02
+ };
+ Q_DECLARE_FLAGS(WindowStyleOptions, WindowStyleOption)
+
static QWindowsWindowClassDescription fromName(QString name, WNDPROC procedure);
static QWindowsWindowClassDescription fromWindow(const QWindow *window, WNDPROC procedure);
@@ -27,10 +35,13 @@ struct QWindowsWindowClassDescription
private:
static QString classNameSuffix(Qt::WindowFlags type, unsigned int style, bool hasIcon);
static bool computeHasIcon(Qt::WindowFlags flags, Qt::WindowFlags type);
+ static unsigned int computeWindowStyles(Qt::WindowFlags flags, Qt::WindowFlags type, WindowStyleOptions options);
friend QDebug operator<<(QDebug dbg, const QWindowsWindowClassDescription &description);
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowsWindowClassDescription::WindowStyleOptions)
+
QT_END_NAMESPACE
#endif // QWINDOWSWINDOWCLASSDESCRIPTION_H