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 plugins 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 QXCBINTEGRATION_H 41 #define QXCBINTEGRATION_H 42 43 #include <QtGui/private/qtguiglobal_p.h> 44 #include <qpa/qplatformintegration.h> 45 #include <qpa/qplatformscreen.h> 46 47 #include "qxcbexport.h" 48 49 #include <xcb/xcb.h> 50 51 QT_BEGIN_NAMESPACE 52 53 class QXcbConnection; 54 class QAbstractEventDispatcher; 55 class QXcbNativeInterface; 56 57 class Q_XCB_EXPORT QXcbIntegration : public QPlatformIntegration 58 { 59 public: 60 QXcbIntegration(const QStringList ¶meters, int &argc, char **argv); 61 ~QXcbIntegration(); 62 63 QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const override; 64 QPlatformWindow *createPlatformWindow(QWindow *window) const override; 65 QPlatformWindow *createForeignWindow(QWindow *window, WId nativeHandle) const override; 66 #ifndef QT_NO_OPENGL 67 QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override; 68 #endif 69 QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override; 70 71 QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const override; 72 73 bool hasCapability(Capability cap) const override; 74 QAbstractEventDispatcher *createEventDispatcher() const override; 75 void initialize() override; 76 77 void moveToScreen(QWindow *window, int screen); 78 79 QPlatformFontDatabase *fontDatabase() const override; 80 81 QPlatformNativeInterface *nativeInterface()const override; 82 83 #ifndef QT_NO_CLIPBOARD 84 QPlatformClipboard *clipboard() const override; 85 #endif 86 #if QT_CONFIG(draganddrop) 87 QPlatformDrag *drag() const override; 88 #endif 89 90 QPlatformInputContext *inputContext() const override; 91 92 #ifndef QT_NO_ACCESSIBILITY 93 QPlatformAccessibility *accessibility() const override; 94 #endif 95 96 QPlatformServices *services() const override; 97 98 Qt::KeyboardModifiers queryKeyboardModifiers() const override; 99 QList<int> possibleKeys(const QKeyEvent *e) const override; 100 101 QStringList themeNames() const override; 102 QPlatformTheme *createPlatformTheme(const QString &name) const override; 103 QVariant styleHint(StyleHint hint) const override; 104 hasDefaultConnection()105 bool hasDefaultConnection() const { return !m_connections.isEmpty(); } defaultConnection()106 QXcbConnection *defaultConnection() const { return m_connections.first(); } 107 108 QByteArray wmClass() const; 109 110 #if QT_CONFIG(xcb_sm) 111 QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const override; 112 #endif 113 114 void sync() override; 115 116 void beep() const override; 117 118 bool nativePaintingEnabled() const; 119 120 #if QT_CONFIG(vulkan) 121 QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const override; 122 #endif 123 instance()124 static QXcbIntegration *instance() { return m_instance; } 125 126 private: 127 QList<QXcbConnection *> m_connections; 128 129 QScopedPointer<QPlatformFontDatabase> m_fontDatabase; 130 QScopedPointer<QXcbNativeInterface> m_nativeInterface; 131 132 QScopedPointer<QPlatformInputContext> m_inputContext; 133 134 #ifndef QT_NO_ACCESSIBILITY 135 mutable QScopedPointer<QPlatformAccessibility> m_accessibility; 136 #endif 137 138 QScopedPointer<QPlatformServices> m_services; 139 140 mutable QByteArray m_wmClass; 141 const char *m_instanceName; 142 bool m_canGrab; 143 xcb_visualid_t m_defaultVisualId; 144 145 static QXcbIntegration *m_instance; 146 }; 147 148 QT_END_NAMESPACE 149 150 #endif 151