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 | |
4 | #ifndef QXCBINTEGRATION_H |
5 | #define QXCBINTEGRATION_H |
6 | |
7 | #include <QtGui/private/qtguiglobal_p.h> |
8 | #include <qpa/qplatformintegration.h> |
9 | #include <qpa/qplatformscreen.h> |
10 | #include <qpa/qplatformopenglcontext.h> |
11 | |
12 | #include "qxcbexport.h" |
13 | |
14 | #include <xcb/xcb.h> |
15 | |
16 | QT_BEGIN_NAMESPACE |
17 | |
18 | class QXcbConnection; |
19 | class QAbstractEventDispatcher; |
20 | class QXcbNativeInterface; |
21 | |
22 | class Q_XCB_EXPORT QXcbIntegration : public QPlatformIntegration |
23 | #ifndef QT_NO_OPENGL |
24 | # if QT_CONFIG(xcb_glx_plugin) |
25 | , public QNativeInterface::Private::QGLXIntegration |
26 | # endif |
27 | # if QT_CONFIG(egl) |
28 | , public QNativeInterface::Private::QEGLIntegration |
29 | # endif |
30 | #endif |
31 | { |
32 | public: |
33 | QXcbIntegration(const QStringList ¶meters, int &argc, char **argv); |
34 | ~QXcbIntegration(); |
35 | |
36 | QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const override; |
37 | QPlatformWindow *createPlatformWindow(QWindow *window) const override; |
38 | QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override; |
39 | #ifndef QT_NO_OPENGL |
40 | QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; |
41 | # if QT_CONFIG(xcb_glx_plugin) |
42 | QOpenGLContext *createOpenGLContext(GLXContext context, void *visualInfo, QOpenGLContext *shareContext) const override; |
43 | # endif |
44 | # if QT_CONFIG(egl) |
45 | QOpenGLContext *createOpenGLContext(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext) const override; |
46 | # endif |
47 | #endif |
48 | QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; |
49 | |
50 | QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; |
51 | |
52 | bool hasCapability(Capability cap) const override; |
53 | QAbstractEventDispatcher *createEventDispatcher() const override; |
54 | void initialize() override; |
55 | |
56 | void moveToScreen(QWindow *window, int screen); |
57 | |
58 | QPlatformFontDatabase *fontDatabase() const override; |
59 | |
60 | QPlatformNativeInterface *nativeInterface()const override; |
61 | |
62 | #ifndef QT_NO_CLIPBOARD |
63 | QPlatformClipboard *clipboard() const override; |
64 | #endif |
65 | #if QT_CONFIG(draganddrop) |
66 | QPlatformDrag *drag() const override; |
67 | #endif |
68 | |
69 | QPlatformInputContext *inputContext() const override; |
70 | |
71 | #if QT_CONFIG(accessibility) |
72 | QPlatformAccessibility *accessibility() const override; |
73 | #endif |
74 | |
75 | QPlatformServices *services() const override; |
76 | |
77 | Qt::KeyboardModifiers queryKeyboardModifiers() const override; |
78 | QList<int> possibleKeys(const QKeyEvent *e) const override; |
79 | |
80 | QStringList themeNames() const override; |
81 | QPlatformTheme *createPlatformTheme(const QString &name) const override; |
82 | QVariant styleHint(StyleHint hint) const override; |
83 | |
84 | bool hasConnection() const { return m_connection; } |
85 | QXcbConnection *connection() const { return m_connection; } |
86 | |
87 | QByteArray wmClass() const; |
88 | |
89 | #if QT_CONFIG(xcb_sm) |
90 | QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const override; |
91 | #endif |
92 | |
93 | void sync() override; |
94 | |
95 | void beep() const override; |
96 | |
97 | bool nativePaintingEnabled() const; |
98 | |
99 | #if QT_CONFIG(vulkan) |
100 | QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override; |
101 | #endif |
102 | |
103 | static QXcbIntegration *instance() { return m_instance; } |
104 | |
105 | void setApplicationBadge(qint64 number) override; |
106 | |
107 | private: |
108 | QXcbConnection *m_connection = nullptr; |
109 | |
110 | QScopedPointer<QPlatformFontDatabase> m_fontDatabase; |
111 | QScopedPointer<QXcbNativeInterface> m_nativeInterface; |
112 | |
113 | QScopedPointer<QPlatformInputContext> m_inputContext; |
114 | |
115 | #if QT_CONFIG(accessibility) |
116 | mutable QScopedPointer<QPlatformAccessibility> m_accessibility; |
117 | #endif |
118 | |
119 | QScopedPointer<QPlatformServices> m_services; |
120 | |
121 | mutable QByteArray m_wmClass; |
122 | const char *m_instanceName; |
123 | bool m_canGrab; |
124 | xcb_visualid_t m_defaultVisualId; |
125 | |
126 | static QXcbIntegration *m_instance; |
127 | }; |
128 | |
129 | QT_END_NAMESPACE |
130 | |
131 | #endif |
132 | |