Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.15.1/qxcbnativeinterface.h

raw
1 // Copyright (C) 2016 The Qt Company Ltd.
2 //
3 // SPDX-License-Identifier: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5 #ifndef QXCBNATIVEINTERFACE_H
6 #define QXCBNATIVEINTERFACE_H
7
8 #include <qpa/qplatformnativeinterface.h>
9 #include <xcb/xcb.h>
10
11 #include <QtCore/QRect>
12
13 #include "qxcbexport.h"
14 #include "qxcbconnection.h"
15
16 QT_BEGIN_NAMESPACE
17
18 class QXcbScreen;
19 class QXcbNativeInterfaceHandler;
20
21 class Q_XCB_EXPORT QXcbNativeInterface : public QPlatformNativeInterface
22 {
23 Q_OBJECT
24 public:
25 enum ResourceType {
26 Display,
27 Connection,
28 Screen,
29 AppTime,
30 AppUserTime,
31 ScreenHintStyle,
32 StartupId,
33 TrayWindow,
34 GetTimestamp,
35 X11Screen,
36 RootWindow,
37 ScreenSubpixelType,
38 ScreenAntialiasingEnabled,
39 AtspiBus,
40 CompositingEnabled,
41 VkSurface,
42 GeneratePeekerId,
43 RemovePeekerId,
44 PeekEventQueue
45 };
46
47 QXcbNativeInterface();
48
49 void *nativeResourceForIntegration(const QByteArray &resource) override;
50 void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) override;
51 void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override;
52 void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) override;
53 void *nativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) override;
54 #ifndef QT_NO_CURSOR
55 void *nativeResourceForCursor(const QByteArray &resource, const QCursor &cursor) override;
56 #endif
57
58 NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) override;
59 NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) override;
60 NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) override;
61 NativeResourceForWindowFunction nativeResourceFunctionForWindow(const QByteArray &resource) override;
62 NativeResourceForBackingStoreFunction nativeResourceFunctionForBackingStore(const QByteArray &resource) override;
63
64 QFunctionPointer platformFunction(const QByteArray &function) const override;
65
66 inline const QByteArray &nativeEventType() const { return m_nativeEventType; }
67
68 void *displayForWindow(QWindow *window);
69 void *connectionForWindow(QWindow *window);
70 void *screenForWindow(QWindow *window);
71 void *appTime(const QXcbScreen *screen);
72 void *appUserTime(const QXcbScreen *screen);
73 void *getTimestamp(const QXcbScreen *screen);
74 void *startupId();
75 void *x11Screen();
76 void *rootWindow();
77 void *display();
78 void *atspiBus();
79 void *connection();
80 static void setStartupId(const char *);
81 static void setAppTime(QScreen *screen, xcb_timestamp_t time);
82 static void setAppUserTime(QScreen *screen, xcb_timestamp_t time);
83
84 static qint32 generatePeekerId();
85 static bool removePeekerId(qint32 peekerId);
86 static bool peekEventQueue(QXcbEventQueue::PeekerCallback peeker, void *peekerData = nullptr,
87 QXcbEventQueue::PeekOptions option = QXcbEventQueue::PeekDefault,
88 qint32 peekerId = -1);
89
90 Q_INVOKABLE QString dumpConnectionNativeWindows(const QXcbConnection *connection, WId root) const;
91 Q_INVOKABLE QString dumpNativeWindows(WId root = 0) const;
92
93 void addHandler(QXcbNativeInterfaceHandler *handler);
94 void removeHandler(QXcbNativeInterfaceHandler *handler);
95 signals:
96 void systemTrayWindowChanged(QScreen *screen);
97
98 private:
99 const QByteArray m_nativeEventType = QByteArrayLiteral("xcb_generic_event_t");
100
101 xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE;
102
103 static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
104
105 QList<QXcbNativeInterfaceHandler *> m_handlers;
106 NativeResourceForIntegrationFunction handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const;
107 NativeResourceForContextFunction handlerNativeResourceFunctionForContext(const QByteArray &resource) const;
108 NativeResourceForScreenFunction handlerNativeResourceFunctionForScreen(const QByteArray &resource) const;
109 NativeResourceForWindowFunction handlerNativeResourceFunctionForWindow(const QByteArray &resource) const;
110 NativeResourceForBackingStoreFunction handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const;
111 QFunctionPointer handlerPlatformFunction(const QByteArray &function) const;
112 void *handlerNativeResourceForIntegration(const QByteArray &resource) const;
113 void *handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const;
114 void *handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const;
115 void *handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const;
116 void *handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const;
117 };
118
119 QT_END_NAMESPACE
120
121 #endif // QXCBNATIVEINTERFACE_H