summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindowclassregistry.h
blob: c4a36b7f3c4484008a0bbf02f8463c98d73f9184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (C) 2025 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
// Qt-Security score:significant reason:default

#ifndef QWINDOWSWINDOWCLASSREGISTRY_H
#define QWINDOWSWINDOWCLASSREGISTRY_H

#include "qtwindowsglobal.h"

#include <QtCore/qloggingcategory.h>
#include <QtCore/qset.h>
#include <QtCore/qstring.h>

QT_BEGIN_NAMESPACE

Q_DECLARE_LOGGING_CATEGORY(lcQpaWindowClass)

class QWindow;
struct QWindowsWindowClassDescription;

class QWindowsWindowClassRegistry
{
    Q_DISABLE_COPY_MOVE(QWindowsWindowClassRegistry)
public:
    QWindowsWindowClassRegistry(WNDPROC defaultProcedure);
    ~QWindowsWindowClassRegistry();

    static QWindowsWindowClassRegistry *instance();

    QString registerWindowClass(const QWindowsWindowClassDescription &description);
    QString registerWindowClass(const QWindow *window);
    QString registerWindowClass(QString name, WNDPROC procedure);

private:
    static QString classNamePrefix();

    bool shouldDecorateWindowClassName(const QWindowsWindowClassDescription &description) const;
    bool shouldDecorateWindowClassName(const QString &name, WNDPROC procedure) const;
    void unregisterWindowClasses();

    static QWindowsWindowClassRegistry *m_instance;

    WNDPROC m_defaultProcedure;
    QSet<QString> m_registeredWindowClassNames;
};

QT_END_NAMESPACE

#endif // QWINDOWSWINDOWCLASSREGISTRY_H