diff options
Diffstat (limited to 'src/plugins/platforms')
21 files changed, 127 insertions, 232 deletions
diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h index ba3d293e054..41946105f08 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/dmabuf-server/dmabufserverbufferintegration.h @@ -1,8 +1,7 @@ // Copyright (C) 2018 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef DMABUFSERVERBUFFERINTEGRATION_H -#define DMABUFSERVERBUFFERINTEGRATION_H +#pragma once #include <QtCore/QVariant> #include <QtWaylandClient/private/qwayland-wayland.h> @@ -106,5 +105,3 @@ void DmaBufServerBufferIntegration::glEGLImageTargetTexture2DOES(GLenum target, } QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h index 01ac4dbe718..68db25dbfc5 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/drm-egl-server/drmeglserverbufferintegration.h @@ -1,8 +1,7 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef DRMEGLSERVERBUFFERINTEGRATION_H -#define DRMEGLSERVERBUFFERINTEGRATION_H +#pragma once #include <QtWaylandClient/private/qwayland-wayland.h> #include <QtCore/QVariant> @@ -101,5 +100,3 @@ void DrmEglServerBufferIntegration::glEGLImageTargetTexture2DOES (GLenum target, } QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h index 4f9e0aeced5..d112fb32385 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/shm-emulation-server/shmserverbufferintegration.h @@ -1,8 +1,7 @@ // Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef SHMSERVERBUFFERINTEGRATION_H -#define SHMSERVERBUFFERINTEGRATION_H +#pragma once #include <QtWaylandClient/private/qwayland-wayland.h> #include "qwayland-shm-emulation-server-buffer.h" @@ -50,5 +49,3 @@ private: } QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h index a1c413be5d9..9d86c61a366 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/vulkan-server/vulkanserverbufferintegration.h @@ -1,8 +1,7 @@ // Copyright (C) 2019 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef VULKANSERVERBUFFERINTEGRATION_H -#define VULKANSERVERBUFFERINTEGRATION_H +#pragma once #include <QtWaylandClient/private/qwayland-wayland.h> #include "qwayland-qt-vulkan-server-buffer-unstable-v1.h" @@ -61,5 +60,3 @@ private: } QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h index 9890d14f137..756d139cac1 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglclientbufferintegration_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QWAYLANDEGLINTEGRATION_H -#define QWAYLANDEGLINTEGRATION_H +#pragma once #include <QtWaylandClient/private/qwaylandclientbufferintegration_p.h> @@ -59,5 +47,3 @@ private: QT_END_NAMESPACE } - -#endif // QWAYLANDEGLINTEGRATION_H diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h index aa45d1b1759..b18c01ac267 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglinclude_p.h @@ -1,20 +1,7 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QWAYLANDEGLINCLUDE_H -#define QWAYLANDEGLINCLUDE_H +#pragma once #include <string.h> #include <wayland-client-core.h> @@ -23,5 +10,3 @@ #define EGL_EGLEXT_PROTOTYPES #include <QtGui/private/qt_egl_p.h> - -#endif // QWAYLANDEGLINCLUDE_H diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h index dc2e0319519..863bd7f0e53 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandeglwindow_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QWAYLANDEGLWINDOW_H -#define QWAYLANDEGLWINDOW_H +#pragma once #include <QtWaylandClient/private/qwaylandwindow_p.h> #include "qwaylandeglinclude_p.h" @@ -72,5 +60,3 @@ private: } QT_END_NAMESPACE - -#endif // QWAYLANDEGLWINDOW_H diff --git a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h index 543c31fd727..7ea7019dfe5 100644 --- a/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h +++ b/src/plugins/platforms/wayland/plugins/hardwareintegration/wayland-egl/qwaylandglcontext_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QWAYLANDGLCONTEXT_H -#define QWAYLANDGLCONTEXT_H +#pragma once #include "qwaylandeglinclude_p.h" //must be first @@ -71,5 +59,3 @@ private: } QT_END_NAMESPACE - -#endif // QWAYLANDGLCONTEXT_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h index 006f648e4d6..693c179fe29 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1integration.h @@ -1,8 +1,7 @@ // Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDFULLSCREENSHELLV1INTEGRATION_H -#define QWAYLANDFULLSCREENSHELLV1INTEGRATION_H +#pragma once #include <wayland-client-core.h> #include <QtWaylandClient/private/qwayland-wayland.h> @@ -27,5 +26,3 @@ public: } // namespace QtWaylandClient QT_END_NAMESPACE - -#endif // QWAYLANDFULLSCREENSHELLV1INTEGRATION_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h index 0a82e5eee2a..12f551d1031 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/fullscreen-shell-v1/qwaylandfullscreenshellv1surface.h @@ -1,8 +1,7 @@ // Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDFULLSCREENSHELLV1SURFACE_H -#define QWAYLANDFULLSCREENSHELLV1SURFACE_H +#pragma once #include <QtWaylandClient/qtwaylandclientglobal.h> #include <QtWaylandClient/private/qwaylandshellsurface_p.h> @@ -28,5 +27,3 @@ private: } // namespace QtWaylandClient QT_END_NAMESPACE - -#endif // QWAYLANDFULLSCREENSHELLV1SURFACE_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h index e2c54ef0078..fd107f825e1 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDXDGACTIVATIONV1_P_H -#define QWAYLANDXDGACTIVATIONV1_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#pragma once #include <QObject> #include "qwayland-xdg-activation-v1.h" @@ -55,4 +43,3 @@ public: } // namespace QtWaylandClient QT_END_NAMESPACE -#endif // QWAYLANDXDGACTIVATIONV1_P_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h index 680fcf69b9f..fc2e67b97c4 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2018 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDXDGDECORATIONV1_P_H -#define QWAYLANDXDGDECORATIONV1_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#pragma once #include "qwayland-xdg-decoration-unstable-v1.h" @@ -59,4 +47,3 @@ private: } // namespace QtWaylandClient QT_END_NAMESPACE -#endif // QWAYLANDXDGDECORATIONV1_P_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h index f5465a63e6f..27ebc8d5afa 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h @@ -1,8 +1,7 @@ // Copyright (C) 2022 David Reondo <kde@david-redondo.de> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDDIALOGV1_P_H -#define QWAYLANDDIALOGV1_P_H +#pragma once #include <qwayland-xdg-dialog-v1.h> @@ -28,5 +27,3 @@ public: } // namespace QtWaylandClient QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h index c993e390a24..aa48e38c34b 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2022 David Reondo <kde@david-redondo.de> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDXDGEXPORTERV2_H -#define QWAYLANDXDGEXPORTERV2_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#pragma once #include <qwayland-xdg-foreign-unstable-v2.h> @@ -45,5 +33,3 @@ public: } QT_END_NAMESPACE - -#endif // QWAYLANDXDGEXPORTERV2_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h index 43c17672c23..bfecff41758 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h @@ -2,19 +2,7 @@ // Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDXDGSHELL_H -#define QWAYLANDXDGSHELL_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#pragma once #include "qwayland-xdg-shell.h" @@ -204,4 +192,3 @@ private: } // namespace QtWaylandClient QT_END_NAMESPACE -#endif // QWAYLANDXDGSHELL_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h index b7627d80462..82b2e005edd 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h @@ -1,19 +1,7 @@ // Copyright (C) 2017 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDXDGSHELLINTEGRATION_P_H -#define QWAYLANDXDGSHELLINTEGRATION_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#pragma once #include "qwayland-xdg-shell.h" @@ -47,5 +35,3 @@ private: } QT_END_NAMESPACE - -#endif // QWAYLANDXDGSHELLINTEGRATION_P_H diff --git a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h index 63e379c4daf..25e06183f2f 100644 --- a/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h +++ b/src/plugins/platforms/wayland/plugins/shellintegration/xdg-shell/qwaylandxdgtopleveliconv1_p.h @@ -2,19 +2,7 @@ // Copyright (C) 2024 David Edmundson <davidedmundson@kde.org> // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#ifndef QWAYLANDTOPLEVELICONV1_P_H -#define QWAYLANDTOPLEVELICONV1_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// +#pragma once #include "wayland-xdg-shell-client-protocol.h" #include <qwayland-xdg-toplevel-icon-v1.h> @@ -45,8 +33,7 @@ private: QList<int> mPreferredSizes; QWaylandDisplay *mDisplay; }; + } // namespace QtWaylandClient QT_END_NAMESPACE - -#endif diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp index e2e46a7b215..6962d28e7d0 100644 --- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp +++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp @@ -11,66 +11,100 @@ 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); + bool hasIcon = true; - 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; - 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; } diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.h b/src/plugins/platforms/windows/qwindowswindowclassdescription.h index 3acca65b8a2..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); @@ -25,9 +33,15 @@ struct QWindowsWindowClassDescription bool shouldAddPrefix{ true }; 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 diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp index c918407a27a..8bf2fb887f1 100644 --- a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp +++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp @@ -69,25 +69,19 @@ QString QWindowsWindowClassRegistry::registerWindowClass(const QWindowsWindowCla // add a UUID. The check needs to be performed for each name // in case new message windows are added (QTBUG-81347). // Note: GetClassInfo() returns != 0 when a class exists. - const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); - WNDCLASS wcinfo; - const bool classExists = GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(className.utf16()), &wcinfo) != FALSE - && wcinfo.lpfnWndProc != description.procedure; - - if (classExists) + if (shouldDecorateWindowClassName(description)) className += QUuid::createUuid().toString(); if (m_registeredWindowClassNames.contains(className)) // already registered in our list return className; - WNDCLASSEX wc; + const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); + + WNDCLASSEX wc{}; wc.cbSize = sizeof(WNDCLASSEX); wc.style = description.style; wc.lpfnWndProc = description.procedure; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; wc.hInstance = appInstance; - wc.hCursor = nullptr; wc.hbrBackground = description.brush; if (description.hasIcon) { wc.hIcon = static_cast<HICON>(LoadImage(appInstance, L"IDI_ICON1", IMAGE_ICON, 0, 0, LR_DEFAULTSIZE)); @@ -98,15 +92,9 @@ QString QWindowsWindowClassRegistry::registerWindowClass(const QWindowsWindowCla } else { wc.hIcon = static_cast<HICON>(LoadImage(nullptr, IDI_APPLICATION, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_SHARED)); - wc.hIconSm = nullptr; } } - else { - wc.hIcon = nullptr; - wc.hIconSm = nullptr; - } - wc.lpszMenuName = nullptr; wc.lpszClassName = reinterpret_cast<LPCWSTR>(className.utf16()); ATOM atom = RegisterClassEx(&wc); if (!atom) @@ -130,6 +118,21 @@ QString QWindowsWindowClassRegistry::registerWindowClass(QString name, WNDPROC p return registerWindowClass(QWindowsWindowClassDescription::fromName(name, procedure)); } +bool QWindowsWindowClassRegistry::shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const +{ + return shouldDecorateWindowClassName(description.name, description.procedure); +} + +bool QWindowsWindowClassRegistry::shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const +{ + const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); + + WNDCLASS wc{}; + + return GetClassInfo(appInstance, reinterpret_cast<LPCWSTR>(name.utf16()), &wc) != FALSE + && wc.lpfnWndProc != procedure; +} + void QWindowsWindowClassRegistry::unregisterWindowClasses() { const auto appInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr)); diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.h b/src/plugins/platforms/windows/qwindowswindowclassregistry.h index 44f274de2b2..c4a36b7f3c4 100644 --- a/src/plugins/platforms/windows/qwindowswindowclassregistry.h +++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.h @@ -34,6 +34,8 @@ public: private: static QString classNamePrefix(); + bool shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const; + bool shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const; void unregisterWindowClasses(); static QWindowsWindowClassRegistry *m_instance; |
