| 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 |
QT_BEGIN_NAMESPACE |
| 14 |
|
| 15 |
class QWidget; |
| 16 |
class QXcbScreen; |
| 17 |
class QXcbConnection; |
| 18 |
|
| 19 |
class QXcbNativeInterface : public QPlatformNativeInterface |
| 20 |
{ |
| 21 |
Q_OBJECT |
| 22 |
public: |
| 23 |
enum ResourceType { |
| 24 |
Display, |
| 25 |
EglDisplay, |
| 26 |
Connection, |
| 27 |
Screen, |
| 28 |
EglContext, |
| 29 |
EglConfig, |
| 30 |
GLXConfig, |
| 31 |
GLXContext, |
| 32 |
AppTime, |
| 33 |
AppUserTime, |
| 34 |
ScreenHintStyle, |
| 35 |
StartupId, |
| 36 |
TrayWindow, |
| 37 |
GetTimestamp, |
| 38 |
X11Screen, |
| 39 |
RootWindow, |
| 40 |
ScreenSubpixelType, |
| 41 |
ScreenAntialiasingEnabled |
| 42 |
}; |
| 43 |
|
| 44 |
QXcbNativeInterface(); |
| 45 |
|
| 46 |
void *nativeResourceForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE; |
| 47 |
void *nativeResourceForContext(const QByteArray &resourceString, QOpenGLContext *context) Q_DECL_OVERRIDE; |
| 48 |
void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) Q_DECL_OVERRIDE; |
| 49 |
void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window) Q_DECL_OVERRIDE; |
| 50 |
|
| 51 |
NativeResourceForIntegrationFunction nativeResourceFunctionForIntegration(const QByteArray &resource) Q_DECL_OVERRIDE; |
| 52 |
NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE; |
| 53 |
NativeResourceForScreenFunction nativeResourceFunctionForScreen(const QByteArray &resource) Q_DECL_OVERRIDE; |
| 54 |
|
| 55 |
QFunctionPointer platformFunction(const QByteArray &function) const Q_DECL_OVERRIDE; |
| 56 |
|
| 57 |
inline const QByteArray &genericEventFilterType() const { return m_genericEventFilterType; } |
| 58 |
|
| 59 |
void *displayForWindow(QWindow *window); |
| 60 |
void *eglDisplayForWindow(QWindow *window); |
| 61 |
void *connectionForWindow(QWindow *window); |
| 62 |
void *screenForWindow(QWindow *window); |
| 63 |
void *appTime(const QXcbScreen *screen); |
| 64 |
void *appUserTime(const QXcbScreen *screen); |
| 65 |
void *getTimestamp(const QXcbScreen *screen); |
| 66 |
void *startupId(); |
| 67 |
void *x11Screen(); |
| 68 |
void *rootWindow(); |
| 69 |
static void setStartupId(const char *); |
| 70 |
static void setAppTime(QScreen *screen, xcb_timestamp_t time); |
| 71 |
static void setAppUserTime(QScreen *screen, xcb_timestamp_t time); |
| 72 |
static void *eglContextForContext(QOpenGLContext *context); |
| 73 |
static void *eglConfigForContext(QOpenGLContext *context); |
| 74 |
static void *glxContextForContext(QOpenGLContext *context); |
| 75 |
static void *glxConfigForContext(QOpenGLContext *context); |
| 76 |
|
| 77 |
Q_INVOKABLE void beep(); |
| 78 |
Q_INVOKABLE bool systemTrayAvailable(const QScreen *screen) const; |
| 79 |
Q_INVOKABLE void clearRegion(const QWindow *qwindow, const QRect& rect); |
| 80 |
Q_INVOKABLE bool systrayVisualHasAlphaChannel(); |
| 81 |
Q_INVOKABLE bool requestSystemTrayWindowDock(const QWindow *window); |
| 82 |
Q_INVOKABLE QRect systemTrayWindowGlobalGeometry(const QWindow *window); |
| 83 |
|
| 84 |
signals: |
| 85 |
void systemTrayWindowChanged(QScreen *screen); |
| 86 |
|
| 87 |
private: |
| 88 |
xcb_window_t locateSystemTray(xcb_connection_t *conn, const QXcbScreen *screen); |
| 89 |
|
| 90 |
const QByteArray m_genericEventFilterType; |
| 91 |
|
| 92 |
xcb_atom_t m_sysTraySelectionAtom; |
| 93 |
xcb_visualid_t m_systrayVisualId; |
| 94 |
|
| 95 |
static QXcbScreen *qPlatformScreenForWindow(QWindow *window); |
| 96 |
}; |
| 97 |
|
| 98 |
QT_END_NAMESPACE |
| 99 |
|
| 100 |
#endif // QXCBNATIVEINTERFACE_H |