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
84class Q_GUI_EXPORT QPlatformIntegration
85{
86public:
87 Q_DISABLE_COPY_MOVE(QPlatformIntegration)
88
89 enum Capability {
90 ThreadedPixmaps = 1,
91 OpenGL,
92 ThreadedOpenGL,
93 SharedGraphicsCache,
94 BufferQueueingOpenGL,
95 WindowMasks,
96 MultipleWindows,
97 ApplicationState,
98 ForeignWindows,
99 NonFullScreenWindows,
100 NativeWidgets,
101 WindowManagement,
102 WindowActivation, // whether requestActivate is supported
103 SyncState,
104 RasterGLSurface,
105 AllGLFunctionsQueryable,
106 ApplicationIcon,
107 SwitchableWidgetComposition,
108 TopStackedNativeChildWindows
109 };
110
111 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 virtual QPlatformWindow *createForeignWindow(QWindow *, WId) const { return 0; }
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#ifndef QT_NO_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 };
172
173 virtual QVariant styleHint(StyleHint hint) const;
174 virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const;
175
176 virtual Qt::KeyboardModifiers queryKeyboardModifiers() const;
177 virtual QList<int> possibleKeys(const QKeyEvent *) const;
178
179 virtual QStringList themeNames() const;
180 virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
181
182 virtual QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
183
184#ifndef QT_NO_SESSIONMANAGER
185 virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const;
186#endif
187
188 virtual void sync();
189
190#ifndef QT_NO_OPENGL
191 virtual QOpenGLContext::OpenGLModuleType openGLModuleType();
192#endif
193 virtual void setApplicationIcon(const QIcon &icon) const;
194
195 void removeScreen(QScreen *screen);
196
197 virtual void beep() const;
198
199#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
200 virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const;
201#endif
202
203protected:
204 QPlatformIntegration() = default;
205
206 void screenAdded(QPlatformScreen *screen, bool isPrimary = false);
207 void destroyScreen(QPlatformScreen *screen);
208 void setPrimaryScreen(QPlatformScreen *newPrimary);
209};
210
211QT_END_NAMESPACE
212
213#endif // QPLATFORMINTEGRATION_H
214