1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QPLATFORMINTEGRATION_H
41#define QPLATFORMINTEGRATION_H
42
43//
44// W A R N I N G
45// -------------
46//
47// This file is part of the QPA API and is not meant to be used
48// in applications. Usage of this API may make your code
49// source and binary incompatible with future versions of Qt.
50//
51
52#include <QtGui/qtguiglobal.h>
53#include <QtGui/qwindowdefs.h>
54#include <qpa/qplatformscreen.h>
55#include <QtGui/qsurfaceformat.h>
56#include <QtGui/qopenglcontext.h>
57
58QT_BEGIN_NAMESPACE
59
60
61class QPlatformWindow;
62class QWindow;
63class QPlatformBackingStore;
64class QPlatformFontDatabase;
65class QPlatformClipboard;
66class QPlatformNativeInterface;
67class QPlatformDrag;
68class QPlatformOpenGLContext;
69class QGuiGLFormat;
70class QAbstractEventDispatcher;
71class QPlatformInputContext;
72class QPlatformAccessibility;
73class QPlatformTheme;
74class QPlatformDialogHelper;
75class QPlatformSharedGraphicsCache;
76class QPlatformServices;
77class QPlatformSessionManager;
78class QKeyEvent;
79class QPlatformOffscreenSurface;
80class QOffscreenSurface;
81class QPlatformVulkanInstance;
82class QVulkanInstance;
83
84namespace QNativeInterface::Private {
85
86template <typename R, typename I, auto func, typename... Args>
87struct QInterfaceProxyImp
88{
89 template <typename T>
90 static R apply(T *obj, Args... args)
91 {
92 if (auto *iface = dynamic_cast<I*>(obj))
93 return (iface->*func)(args...);
94 else
95 return R();
96 }
97};
98
99template <auto func>
100struct QInterfaceProxy;
101template <typename R, typename I, typename... Args, R(I::*func)(Args...)>
102struct QInterfaceProxy<func> : public QInterfaceProxyImp<R, I, func, Args...> {};
103template <typename R, typename I, typename... Args, R(I::*func)(Args...) const>
104struct QInterfaceProxy<func> : public QInterfaceProxyImp<R, I, func, Args...> {};
105
106} // QNativeInterface::Private
107
108class Q_GUI_EXPORT QPlatformIntegration
109{
110public:
111 Q_DISABLE_COPY_MOVE(QPlatformIntegration)
112
113 enum Capability {
114 ThreadedPixmaps = 1,
115 OpenGL,
116 ThreadedOpenGL,
117 SharedGraphicsCache,
118 BufferQueueingOpenGL,
119 WindowMasks,
120 MultipleWindows,
121 ApplicationState,
122 ForeignWindows,
123 NonFullScreenWindows,
124 NativeWidgets,
125 WindowManagement,
126 WindowActivation, // whether requestActivate is supported
127 SyncState,
128 RasterGLSurface,
129 AllGLFunctionsQueryable,
130 ApplicationIcon,
131 SwitchableWidgetComposition,
132 TopStackedNativeChildWindows,
133 OpenGLOnRasterSurface,
134 MaximizeUsingFullscreenGeometry,
135 PaintEvents,
136 RhiBasedRendering
137 };
138
139 virtual ~QPlatformIntegration() { }
140
141 virtual bool hasCapability(Capability cap) const;
142
143 virtual QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const;
144 virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
145 virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return nullptr; }
146 virtual QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const = 0;
147#ifndef QT_NO_OPENGL
148 virtual QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
149#endif
150 virtual QPlatformSharedGraphicsCache *createPlatformSharedGraphicsCache(const char *cacheId) const;
151 virtual QPaintEngine *createImagePaintEngine(QPaintDevice *paintDevice) const;
152
153// Event dispatcher:
154 virtual QAbstractEventDispatcher *createEventDispatcher() const = 0;
155 virtual void initialize();
156 virtual void destroy();
157
158//Deeper window system integrations
159 virtual QPlatformFontDatabase *fontDatabase() const;
160#ifndef QT_NO_CLIPBOARD
161 virtual QPlatformClipboard *clipboard() const;
162#endif
163#if QT_CONFIG(draganddrop)
164 virtual QPlatformDrag *drag() const;
165#endif
166 virtual QPlatformInputContext *inputContext() const;
167#ifndef QT_NO_ACCESSIBILITY
168 virtual QPlatformAccessibility *accessibility() const;
169#endif
170
171 // Access native handles. The window handle is already available from Wid;
172 virtual QPlatformNativeInterface *nativeInterface() const;
173
174 virtual QPlatformServices *services() const;
175
176 enum StyleHint {
177 CursorFlashTime,
178 KeyboardInputInterval,
179 MouseDoubleClickInterval,
180 StartDragDistance,
181 StartDragTime,
182 KeyboardAutoRepeatRate,
183 ShowIsFullScreen,
184 PasswordMaskDelay,
185 FontSmoothingGamma,
186 StartDragVelocity,
187 UseRtlExtensions,
188 PasswordMaskCharacter,
189 SetFocusOnTouchRelease,
190 ShowIsMaximized,
191 MousePressAndHoldInterval,
192 TabFocusBehavior,
193 ReplayMousePressOutsidePopup,
194 ItemViewActivateItemOnSingleClick,
195 UiEffects,
196 WheelScrollLines,
197 ShowShortcutsInContextMenus,
198 MouseQuickSelectionThreshold
199 };
200
201 virtual QVariant styleHint(StyleHint hint) const;
202 virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const;
203
204 virtual Qt::KeyboardModifiers queryKeyboardModifiers() const;
205 virtual QList<int> possibleKeys(const QKeyEvent *) const;
206
207 virtual QStringList themeNames() const;
208 virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
209
210 virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
211
212#ifndef QT_NO_SESSIONMANAGER
213 virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const;
214#endif
215
216 virtual void sync();
217
218#ifndef QT_NO_OPENGL
219 virtual QOpenGLContext::OpenGLModuleType openGLModuleType();
220#endif
221 virtual void setApplicationIcon(const QIcon &icon) const;
222
223 virtual void beep() const;
224 virtual void quit() const;
225
226#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
227 virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const;
228#endif
229
230 template <auto func, typename... Args>
231 auto call(Args... args)
232 {
233 using namespace QNativeInterface::Private;
234 return QInterfaceProxy<func>::apply(this, args...);
235 }
236
237protected:
238 QPlatformIntegration() = default;
239};
240
241QT_END_NAMESPACE
242
243#endif // QPLATFORMINTEGRATION_H
244

source code of qtbase/src/gui/kernel/qplatformintegration.h