Debian Codegraph @

xcb/libqt5xcbqpa-dev/5.11.0/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 &genericEventFilterType() const { return m_genericEventFilterType; }
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(QXcbConnection::PeekerCallback peeker, void *peekerData = nullptr,
87 QXcbConnection::PeekOptions option = QXcbConnection::PeekDefault,
88 qint32 peekerId = -1);
89
90 Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const;
91 Q_INVOKABLE void setParentRelativeBackPixmap(QWindow *window);
92 Q_INVOKABLE bool systrayVisualHasAlphaChannel();
93 Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window);
94 Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window);
95 Q_INVOKABLE QString dumpConnectionNativeWindows(const QXcbConnection *connection, WId root) const;
96 Q_INVOKABLE QString dumpNativeWindows(WId root = 0) const;
97
98 void addHandler(QXcbNativeInterfaceHandler *handler);
99 void removeHandler(QXcbNativeInterfaceHandler *handler);
100 signals:
101 void systemTrayWindowChanged(QScreen *screen);
102
103 private:
104 xcb_window_t locateSystemTray(xcb_connection_t *conn, const QXcbScreen *screen);
105
106 const QByteArray m_genericEventFilterType;
107
108 xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE;
109
110 static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
111
112 QList<QXcbNativeInterfaceHandler *> m_handlers;
113 NativeResourceForIntegrationFunction handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const;
114 NativeResourceForContextFunction handlerNativeResourceFunctionForContext(const QByteArray &resource) const;
115 NativeResourceForScreenFunction handlerNativeResourceFunctionForScreen(const QByteArray &resource) const;
116 NativeResourceForWindowFunction handlerNativeResourceFunctionForWindow(const QByteArray &resource) const;
117 NativeResourceForBackingStoreFunction handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const;
118 QFunctionPointer handlerPlatformFunction(const QByteArray &function) const;
119 void *handlerNativeResourceForIntegration(const QByteArray &resource) const;
120 void *handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const;
121 void *handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const;
122 void *handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const;
123 void *handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const;
124 };
125
126 QT_END_NAMESPACE
127
128 #endif // QXCBNATIVEINTERFACE_H