| 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 |
|
| 96 |
void addHandler(QXcbNativeInterfaceHandler *handler); |
| 97 |
void removeHandler(QXcbNativeInterfaceHandler *handler); |
| 98 |
signals: |
| 99 |
void systemTrayWindowChanged(QScreen *screen); |
| 100 |
|
| 101 |
private: |
| 102 |
xcb_window_t locateSystemTray(xcb_connection_t *conn, const QXcbScreen *screen); |
| 103 |
|
| 104 |
const QByteArray m_genericEventFilterType; |
| 105 |
|
| 106 |
xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE; |
| 107 |
|
| 108 |
static QXcbScreen *qPlatformScreenForWindow(QWindow *window); |
| 109 |
|
| 110 |
QList<QXcbNativeInterfaceHandler *> m_handlers; |
| 111 |
NativeResourceForIntegrationFunction handlerNativeResourceFunctionForIntegration(const QByteArray &resource) const; |
| 112 |
NativeResourceForContextFunction handlerNativeResourceFunctionForContext(const QByteArray &resource) const; |
| 113 |
NativeResourceForScreenFunction handlerNativeResourceFunctionForScreen(const QByteArray &resource) const; |
| 114 |
NativeResourceForWindowFunction handlerNativeResourceFunctionForWindow(const QByteArray &resource) const; |
| 115 |
NativeResourceForBackingStoreFunction handlerNativeResourceFunctionForBackingStore(const QByteArray &resource) const; |
| 116 |
QFunctionPointer handlerPlatformFunction(const QByteArray &function) const; |
| 117 |
void *handlerNativeResourceForIntegration(const QByteArray &resource) const; |
| 118 |
void *handlerNativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) const; |
| 119 |
void *handlerNativeResourceForScreen(const QByteArray &resource, QScreen *screen) const; |
| 120 |
void *handlerNativeResourceForWindow(const QByteArray &resource, QWindow *window) const; |
| 121 |
void *handlerNativeResourceForBackingStore(const QByteArray &resource, QBackingStore *backingStore) const; |
| 122 |
}; |
| 123 |
|
| 124 |
QT_END_NAMESPACE |
| 125 |
|
| 126 |
#endif // QXCBNATIVEINTERFACE_H |