Coverage Report

Created: 2026-11-10 07:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qplatformintegration.h
Line
Count
Source
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#ifndef QPLATFORMINTEGRATION_H
6
#define QPLATFORMINTEGRATION_H
7
8
//
9
//  W A R N I N G
10
//  -------------
11
//
12
// This file is part of the QPA API and is not meant to be used
13
// in applications. Usage of this API may make your code
14
// source and binary incompatible with future versions of Qt.
15
//
16
17
#include <QtGui/qtguiglobal.h>
18
#include <QtGui/qwindowdefs.h>
19
#include <qpa/qplatformscreen.h>
20
#include <QtGui/qsurfaceformat.h>
21
#include <QtGui/qopenglcontext.h>
22
23
QT_BEGIN_NAMESPACE
24
25
26
class QPlatformWindow;
27
class QWindow;
28
class QPlatformBackingStore;
29
class QPlatformFontDatabase;
30
class QPlatformClipboard;
31
class QPlatformNativeInterface;
32
class QPlatformDrag;
33
class QPlatformOpenGLContext;
34
class QGuiGLFormat;
35
class QAbstractEventDispatcher;
36
class QPlatformInputContext;
37
class QPlatformKeyMapper;
38
class QPlatformAccessibility;
39
class QPlatformTheme;
40
class QPlatformDialogHelper;
41
class QPlatformSharedGraphicsCache;
42
class QPlatformServices;
43
class QPlatformSessionManager;
44
class QKeyEvent;
45
class QPlatformOffscreenSurface;
46
class QOffscreenSurface;
47
class QPlatformVulkanInstance;
48
class QVulkanInstance;
49
50
namespace QNativeInterface::Private {
51
52
template <typename R, typename I, auto func, typename... Args>
53
struct QInterfaceProxyImp
54
{
55
    template <typename T>
56
    static R apply(T *obj, Args... args)
57
    {
58
        if (auto *iface = dynamic_cast<I*>(obj))
59
            return (iface->*func)(args...);
60
        else
61
            return R();
62
    }
63
};
64
65
template <auto func>
66
struct QInterfaceProxy;
67
template <typename R, typename I, typename... Args, R(I::*func)(Args...)>
68
struct QInterfaceProxy<func> : public QInterfaceProxyImp<R, I, func, Args...> {};
69
template <typename R, typename I, typename... Args, R(I::*func)(Args...) const>
70
struct QInterfaceProxy<func> : public QInterfaceProxyImp<R, I, func, Args...> {};
71
72
} // QNativeInterface::Private
73
74
class Q_GUI_EXPORT QPlatformIntegration
75
{
76
public:
77
    Q_DISABLE_COPY_MOVE(QPlatformIntegration)
78
79
    enum Capability {
80
        ThreadedPixmaps = 1,
81
        OpenGL,
82
        ThreadedOpenGL,
83
        SharedGraphicsCache,
84
        BufferQueueingOpenGL,
85
        WindowMasks,
86
        MultipleWindows,
87
        ApplicationState,
88
        ForeignWindows,
89
        NonFullScreenWindows,
90
        NativeWidgets,
91
        WindowManagement,
92
        WindowActivation, // whether requestActivate is supported
93
        SyncState,
94
#if QT_REMOVAL_QT7_DEPRECATED_SINCE(6, 11)
95
        RasterGLSurface Q_DECL_ENUMERATOR_DEPRECATED_X("This capability is no longer used"),
96
#endif
97
        AllGLFunctionsQueryable,
98
        ApplicationIcon,
99
        SwitchableWidgetComposition,
100
        TopStackedNativeChildWindows,
101
        OpenGLOnRasterSurface,
102
        MaximizeUsingFullscreenGeometry,
103
        PaintEvents,
104
        RhiBasedRendering,
105
        ScreenWindowGrabbing, // whether QScreen::grabWindow() is supported
106
        BackingStoreStaticContents,
107
        OffscreenSurface,
108
        MouseCursorPositioning,
109
        ChildWindows,
110
    };
111
112
0
    virtual ~QPlatformIntegration() { }
113
114
    virtual bool hasCapability(Capability cap) const;
115
116
    virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
117
    virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
118
0
    virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return nullptr; }
119
    virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0;
120
#ifndef QT_NO_OPENGL
121
    virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
122
#endif
123
    virtual QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const;
124
    virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const;
125
126
// Event dispatcher:
127
    virtual QAbstractEventDispatcher *createEventDispatcher() const = 0;
128
    virtual void initialize();
129
    virtual void destroy();
130
131
//Deeper window system integrations
132
    virtual QPlatformFontDatabase *fontDatabase() const;
133
#ifndef QT_NO_CLIPBOARD
134
    virtual QPlatformClipboard *clipboard() const;
135
#endif
136
#if QT_CONFIG(draganddrop)
137
    virtual QPlatformDrag *drag() const;
138
#endif
139
    virtual QPlatformInputContext *inputContext() const;
140
#if QT_CONFIG(accessibility)
141
    virtual QPlatformAccessibility *accessibility() const;
142
#endif
143
144
    // Access native handles. The window handle is already available from Wid;
145
    virtual QPlatformNativeInterface *nativeInterface() const;
146
147
    virtual QPlatformServices *services() const;
148
149
    enum StyleHint {
150
        CursorFlashTime,
151
        KeyboardInputInterval,
152
        MouseDoubleClickInterval,
153
        StartDragDistance,
154
        StartDragTime,
155
        KeyboardAutoRepeatRate,
156
        ShowIsFullScreen,
157
        PasswordMaskDelay,
158
        FontSmoothingGamma,
159
        StartDragVelocity,
160
        UseRtlExtensions,
161
        PasswordMaskCharacter,
162
        SetFocusOnTouchRelease,
163
        ShowIsMaximized,
164
        MousePressAndHoldInterval,
165
        TabFocusBehavior,
166
        ReplayMousePressOutsidePopup,
167
        ItemViewActivateItemOnSingleClick,
168
        UiEffects,
169
        WheelScrollLines,
170
        ShowShortcutsInContextMenus,
171
        MouseQuickSelectionThreshold,
172
        MouseDoubleClickDistance,
173
        FlickStartDistance,
174
        FlickMaximumVelocity,
175
        FlickDeceleration,
176
        UnderlineShortcut,
177
    };
178
179
    virtual QVariant styleHint(StyleHint hint) const;
180
    virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const;
181
182
protected:
183
    virtual Qt::KeyboardModifiers queryKeyboardModifiers() const;
184
    virtual QList<int> possibleKeys(const QKeyEvent *) const;
185
    friend class QPlatformKeyMapper;
186
public:
187
    virtual QPlatformKeyMapper *keyMapper() const;
188
189
    virtual QStringList themeNames() const;
190
    virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
191
192
    virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
193
194
#ifndef QT_NO_SESSIONMANAGER
195
    virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const;
196
#endif
197
198
    virtual void sync();
199
200
#ifndef QT_NO_OPENGL
201
    virtual QOpenGLContext::OpenGLModuleType openGLModuleType();
202
#endif
203
    virtual void setApplicationIcon(const QIcon &icon) const;
204
    virtual void setApplicationBadge(qint64 number);
205
206
    virtual void beep() const;
207
    virtual void quit() const;
208
209
#if QT_CONFIG(vulkan) || defined(Q_QDOC)
210
    virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const;
211
#endif
212
213
    template <auto func, typename... Args>
214
    auto call(Args... args)
215
    {
216
        using namespace QNativeInterface::Private;
217
        return QInterfaceProxy<func>::apply(this, args...);
218
    }
219
220
protected:
221
    QPlatformIntegration() = default;
222
};
223
224
QT_END_NAMESPACE
225
226
#endif // QPLATFORMINTEGRATION_H