Debian Codegraph @

xcb/libqt6xcbqpa-dev/6.2.4/qxcbnativeinterface.h

raw
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 QXCBNATIVEINTERFACE_H
41 #define QXCBNATIVEINTERFACE_H
42
43 #include <qpa/qplatformnativeinterface.h>
44 #include <xcb/xcb.h>
45
46 #include <QtCore/QRect>
47
48 #include <QtGui/qguiapplication.h>
49
50 #include "qxcbexport.h"
51 #include "qxcbconnection.h"
52
53 QT_BEGIN_NAMESPACE
54
55 class QXcbScreen;
56 class QXcbNativeInterfaceHandler;
57
58 class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
59 , public QNativeInterface::QX11Application
60 {
61 Q_OBJECT
62 public:
63 enum ResourceType {
64 XDisplay,
65 Connection,
66 Screen,
67 AppTime,
68 AppUserTime,
69 ScreenHintStyle,
70 StartupId,
71 TrayWindow,
72 GetTimestamp,
73 X11Screen,
74 RootWindow,
75 ScreenSubpixelType,
76 ScreenAntialiasingEnabled,
77 AtspiBus,
78 CompositingEnabled,
79 VkSurface,
80 GeneratePeekerId,
81 RemovePeekerId,
82 PeekEventQueue
83 };
84
85 QXcbNativeInterface();
86
87 void *nativeResourceForIntegration(const QByteArray &resource) override;
88 void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) override;
89 void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override;
90 void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) override;
91 void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) override;
92 #ifndef QT_NO_CURSOR
93 void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) override;
94 #endif
95
96 NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) override;
97 NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) override;
98 NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) override;
99 NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) override;
100 NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) override;
101
102 QFunctionPointer platformFunction(const QByteArray &function) const override;
103
104 inline const QByteArray &nativeEventType() const { return m_nativeEventType; }
105
106 void *displayForWindow(QWindow *window);
107 void *connectionForWindow(QWindow *window);
108 void *screenForWindow(QWindow *window);
109 void *appTime(const QXcbScreen *screen);
110 void *appUserTime(const QXcbScreen *screen);
111 void *getTimestamp(const QXcbScreen *screen);
112 void *startupId();
113 void *x11Screen();
114 void *rootWindow();
115
116 Display *display() const override;
117 xcb_connection_t *connection() const override;
118
119 void *atspiBus();
120 static void setStartupId(const char *);
121 static void setAppTime(QScreen *screen, xcb_timestamp_t time);
122 static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
123
124 static qint32 generatePeekerId();
125 static bool removePeekerId(qint32 peekerId);
126 static bool peekEventQueue(QXcbEventQueue::PeekerCallback peeker, void *peekerData = nullptr,
127 QXcbEventQueue::PeekOptions option = QXcbEventQueue::PeekDefault,
128 qint32 peekerId = -1);
129
130 Q_INVOKABLE QString dumpConnectionNativeWindows(const QXcbConnection *connection, WId root) const;
131 Q_INVOKABLE QString dumpNativeWindows(WId root = 0) const;
132
133 void addHandler(QXcbNativeInterfaceHandler *handler);
134 void removeHandler(QXcbNativeInterfaceHandler *handler);
135 signals:
136 void systemTrayWindowChanged(QScreen *screen);
137
138 private:
139 const QByteArray m_nativeEventType = QByteArrayLiteral("xcb_generic_event_t");
140
141 xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE;
142
143 static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
144
145 QList<QXcbNativeInterfaceHandler *> m_handlers;
146 NativeResourceForIntegrationFunction handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const;
147 NativeResourceForContextFunction handlerNativeResourceFunctionForContext(const QByteArray &resource) const;
148 NativeResourceForScreenFunction handlerNativeResourceFunctionForScreen(const QByteArray &resource) const;
149 NativeResourceForWindowFunction handlerNativeResourceFunctionForWindow(const QByteArray &resource) const;
150 NativeResourceForBackingStoreFunction handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const;
151 QFunctionPointer handlerPlatformFunction(const QByteArray &function) const;
152 void *handlerNativeResourceForIntegration(const QByteArray &resource) const;
153 void *handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const;
154 void *handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const;
155 void *handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const;
156 void *handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const;
157 };
158
159 QT_END_NAMESPACE
160
161 #endif // QXCBNATIVEINTERFACE_H