summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Dubsky <[email protected]>2025-11-10 00:04:09 +0100
committerPavel Dubsky <[email protected]>2025-11-25 21:51:07 +0100
commita1e07d2a768aa4755e1a5776e79ec049db3d2cbb (patch)
tree2b9ad96fa3d4cfe3ce0d293d310fa3a8b0ca008b
parent9f8f49cc140a9d1f90f2dd4b96def69a435c4080 (diff)
Add shouldAddSuffix to QWindowsWindowClassDescription
Change-Id: Ibbcfb8ff728f7fb292dcf6bac03234f1ed88007d Reviewed-by: Volker Hilsheimer <[email protected]>
-rw-r--r--src/plugins/platforms/windows/qwindowscontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsscreen.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowssystemtrayicon.cpp6
-rw-r--r--src/plugins/platforms/windows/qwindowstheme.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowswindow.cpp9
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassdescription.h1
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassregistry.cpp3
-rw-r--r--src/plugins/platforms/windows/qwindowswindowclassregistry.h4
9 files changed, 19 insertions, 13 deletions
diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp
index 3013de1c068..156351987cb 100644
--- a/src/plugins/platforms/windows/qwindowscontext.cpp
+++ b/src/plugins/platforms/windows/qwindowscontext.cpp
@@ -696,7 +696,7 @@ HWND QWindowsContext::createDummyWindow(const QString &classNameIn,
{
if (!wndProc)
wndProc = DefWindowProc;
- QString className = d->m_windowClassRegistry.registerWindowClass(QWindowsWindowClassRegistry::classNamePrefix() + classNameIn, wndProc);
+ QString className = d->m_windowClassRegistry.registerWindowClass(classNameIn, wndProc);
return CreateWindowEx(0, reinterpret_cast<LPCWSTR>(className.utf16()),
windowName, style,
CW_USEDEFAULT, CW_USEDEFAULT,
diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp
index 9139ec0c463..2bd2f0c9e3d 100644
--- a/src/plugins/platforms/windows/qwindowsscreen.cpp
+++ b/src/plugins/platforms/windows/qwindowsscreen.cpp
@@ -704,7 +704,7 @@ void QWindowsScreenManager::initialize()
qCDebug(lcQpaScreen) << "Initializing screen manager";
auto className = QWindowsWindowClassRegistry::instance()->registerWindowClass(
- QWindowsWindowClassRegistry::classNamePrefix() + QLatin1String("ScreenChangeObserverWindow"),
+ QLatin1String("ScreenChangeObserverWindow"),
qDisplayChangeObserverWndProc);
// HWND_MESSAGE windows do not get WM_DISPLAYCHANGE, so we need to create
diff --git a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
index a2ce1e86a4d..beeab1a089e 100644
--- a/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
+++ b/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
@@ -119,9 +119,9 @@ static inline HWND createTrayIconMessageWindow()
if (!ctx)
return nullptr;
// Register window class in the platform plugin.
- const QString className =
- ctx->registerWindowClass(QWindowsWindowClassRegistry::classNamePrefix() + "TrayIconMessageWindowClass"_L1,
- qWindowsTrayIconWndProc);
+ const QString className = ctx->registerWindowClass(
+ "TrayIconMessageWindowClass"_L1,
+ qWindowsTrayIconWndProc);
const wchar_t windowName[] = L"QTrayIconMessageWindow";
return CreateWindowEx(0, reinterpret_cast<const wchar_t *>(className.utf16()),
windowName, WS_OVERLAPPED,
diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp
index 33d7c4124ac..d132bbb6130 100644
--- a/src/plugins/platforms/windows/qwindowstheme.cpp
+++ b/src/plugins/platforms/windows/qwindowstheme.cpp
@@ -549,7 +549,7 @@ QWindowsTheme::QWindowsTheme()
refreshIconPixmapSizes();
auto className = QWindowsWindowClassRegistry::instance()->registerWindowClass(
- QWindowsWindowClassRegistry::classNamePrefix() + QLatin1String("ThemeChangeObserverWindow"),
+ QLatin1String("ThemeChangeObserverWindow"),
qThemeChangeObserverWndProc);
// HWND_MESSAGE windows do not get the required theme events,
// so we use a real top-level window that we never show.
diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 26d0f907b92..ed391009423 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -887,9 +887,12 @@ QWindowsWindowData
const auto appinst = reinterpret_cast<HINSTANCE>(GetModuleHandle(nullptr));
const QString windowClassName = QWindowsWindowClassRegistry::instance()->registerWindowClass(w);
- const QString windowTitlebarName = QWindowsWindowClassRegistry::instance()->registerWindowClass({
- QStringLiteral("_q_titlebar"), DefWindowProc, CS_VREDRAW | CS_HREDRAW
- });
+
+ QWindowsWindowClassDescription windowTitlebarDescription;
+ windowTitlebarDescription.name = QStringLiteral("_q_titlebar");
+ windowTitlebarDescription.style = CS_VREDRAW | CS_HREDRAW;
+ windowTitlebarDescription.shouldAddPrefix = false;
+ const QString windowTitlebarName = QWindowsWindowClassRegistry::instance()->registerWindowClass(windowTitlebarDescription);
const QScreen *screen{};
const QRect rect = QPlatformWindow::initialGeometry(w, data.geometry,
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
index cb862bba47c..63e16260b62 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.cpp
@@ -49,8 +49,7 @@ QWindowsWindowClassDescription QWindowsWindowClassDescription::fromWindow(const
break;
}
// Create a unique name for the flag combination
- description.name = QWindowsWindowClassRegistry::classNamePrefix();
- description.name += "QWindow"_L1;
+ description.name = "QWindow"_L1;
switch (type) {
case Qt::Tool:
description.name += "Tool"_L1;
diff --git a/src/plugins/platforms/windows/qwindowswindowclassdescription.h b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
index ece48e4343c..9423abf9d2d 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassdescription.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassdescription.h
@@ -22,6 +22,7 @@ struct QWindowsWindowClassDescription
unsigned int style{ 0 };
HBRUSH brush{ nullptr };
bool hasIcon{ false };
+ bool shouldAddPrefix{ true };
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
index e367350d55e..c330720a09c 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
+++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.cpp
@@ -59,6 +59,9 @@ QString QWindowsWindowClassRegistry::registerWindowClass(const QWindowsWindowCla
{
QString className = description.name;
+ if (description.shouldAddPrefix)
+ className = classNamePrefix() + className;
+
// since multiple Qt versions can be used in one process
// each one has to have window class names with a unique name
// The first instance gets the unmodified name; if the class
diff --git a/src/plugins/platforms/windows/qwindowswindowclassregistry.h b/src/plugins/platforms/windows/qwindowswindowclassregistry.h
index d1f10310dc8..c19b4f616fb 100644
--- a/src/plugins/platforms/windows/qwindowswindowclassregistry.h
+++ b/src/plugins/platforms/windows/qwindowswindowclassregistry.h
@@ -27,13 +27,13 @@ public:
static QWindowsWindowClassRegistry *instance();
- static QString classNamePrefix();
-
QString registerWindowClass(const QWindowsWindowClassDescription &description);
QString registerWindowClass(const QWindow *window);
QString registerWindowClass(QString name, WNDPROC procedure);
private:
+ static QString classNamePrefix();
+
void unregisterWindowClasses();
static QWindowsWindowClassRegistry *m_instance;