/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 | | }; |
110 | | |
111 | 0 | virtual ~QPlatformIntegration() { } |
112 | | |
113 | | virtual bool hasCapability(Capability cap) const; |
114 | | |
115 | | virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const; |
116 | | virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0; |
117 | 0 | virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return nullptr; } |
118 | | virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0; |
119 | | #ifndef QT_NO_OPENGL |
120 | | virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const; |
121 | | #endif |
122 | | virtual QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const; |
123 | | virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const; |
124 | | |
125 | | // Event dispatcher: |
126 | | virtual QAbstractEventDispatcher *createEventDispatcher() const = 0; |
127 | | virtual void initialize(); |
128 | | virtual void destroy(); |
129 | | |
130 | | //Deeper window system integrations |
131 | | virtual QPlatformFontDatabase *fontDatabase() const; |
132 | | #ifndef QT_NO_CLIPBOARD |
133 | | virtual QPlatformClipboard *clipboard() const; |
134 | | #endif |
135 | | #if QT_CONFIG(draganddrop) |
136 | | virtual QPlatformDrag *drag() const; |
137 | | #endif |
138 | | virtual QPlatformInputContext *inputContext() const; |
139 | | #if QT_CONFIG(accessibility) |
140 | | virtual QPlatformAccessibility *accessibility() const; |
141 | | #endif |
142 | | |
143 | | // Access native handles. The window handle is already available from Wid; |
144 | | virtual QPlatformNativeInterface *nativeInterface() const; |
145 | | |
146 | | virtual QPlatformServices *services() const; |
147 | | |
148 | | enum StyleHint { |
149 | | CursorFlashTime, |
150 | | KeyboardInputInterval, |
151 | | MouseDoubleClickInterval, |
152 | | StartDragDistance, |
153 | | StartDragTime, |
154 | | KeyboardAutoRepeatRate, |
155 | | ShowIsFullScreen, |
156 | | PasswordMaskDelay, |
157 | | FontSmoothingGamma, |
158 | | StartDragVelocity, |
159 | | UseRtlExtensions, |
160 | | PasswordMaskCharacter, |
161 | | SetFocusOnTouchRelease, |
162 | | ShowIsMaximized, |
163 | | MousePressAndHoldInterval, |
164 | | TabFocusBehavior, |
165 | | ReplayMousePressOutsidePopup, |
166 | | ItemViewActivateItemOnSingleClick, |
167 | | UiEffects, |
168 | | WheelScrollLines, |
169 | | ShowShortcutsInContextMenus, |
170 | | MouseQuickSelectionThreshold, |
171 | | MouseDoubleClickDistance, |
172 | | FlickStartDistance, |
173 | | FlickMaximumVelocity, |
174 | | FlickDeceleration, |
175 | | UnderlineShortcut, |
176 | | }; |
177 | | |
178 | | virtual QVariant styleHint(StyleHint hint) const; |
179 | | virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const; |
180 | | |
181 | | protected: |
182 | | virtual Qt::KeyboardModifiers queryKeyboardModifiers() const; |
183 | | virtual QList<int> possibleKeys(const QKeyEvent *) const; |
184 | | friend class QPlatformKeyMapper; |
185 | | public: |
186 | | virtual QPlatformKeyMapper *keyMapper() const; |
187 | | |
188 | | virtual QStringList themeNames() const; |
189 | | virtual QPlatformTheme *createPlatformTheme(const QString &name) const; |
190 | | |
191 | | virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const; |
192 | | |
193 | | #ifndef QT_NO_SESSIONMANAGER |
194 | | virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const; |
195 | | #endif |
196 | | |
197 | | virtual void sync(); |
198 | | |
199 | | #ifndef QT_NO_OPENGL |
200 | | virtual QOpenGLContext::OpenGLModuleType openGLModuleType(); |
201 | | #endif |
202 | | virtual void setApplicationIcon(const QIcon &icon) const; |
203 | | virtual void setApplicationBadge(qint64 number); |
204 | | |
205 | | virtual void beep() const; |
206 | | virtual void quit() const; |
207 | | |
208 | | #if QT_CONFIG(vulkan) || defined(Q_QDOC) |
209 | | virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const; |
210 | | #endif |
211 | | |
212 | | template <auto func, typename... Args> |
213 | | auto call(Args... args) |
214 | | { |
215 | | using namespace QNativeInterface::Private; |
216 | | return QInterfaceProxy<func>::apply(this, args...); |
217 | | } |
218 | | |
219 | | protected: |
220 | | QPlatformIntegration() = default; |
221 | | }; |
222 | | |
223 | | QT_END_NAMESPACE |
224 | | |
225 | | #endif // QPLATFORMINTEGRATION_H |