diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-01 15:22:04 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-07 12:17:46 +0000 |
commit | cafdb8d3ee1195b8ace5556e52bb992d95d788ab (patch) | |
tree | 55175dcb87e3cee9f6243126d4ff41c323977bd0 /src/gui/kernel | |
parent | 19a154f57b9141e5cbe7dba3919a2acdfa91525a (diff) | |
download | qtbase-cafdb8d3ee1195b8ace5556e52bb992d95d788ab.tar.gz |
Expose the native interfaces of QScreen/QWindow
Add the macros.
Task-number: QTBUG-84220
Change-Id: Ica23b9e4d5c1ca072acb5356e6f2be28d5199fa6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qplatformscreen_p.h | 6 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow_p.h | 6 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 25 | ||||
-rw-r--r-- | src/gui/kernel/qscreen.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 26 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.h | 3 |
6 files changed, 63 insertions, 6 deletions
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h index 3ef87625ad..35097b5d23 100644 --- a/src/gui/kernel/qplatformscreen_p.h +++ b/src/gui/kernel/qplatformscreen_p.h @@ -73,7 +73,7 @@ namespace QNativeInterface::Private { #if QT_CONFIG(xcb) || defined(Q_CLANG_QDOC) struct Q_GUI_EXPORT QXcbScreen { - QT_DECLARE_NATIVE_INTERFACE(QXcbScreen) + QT_DECLARE_NATIVE_INTERFACE(QXcbScreen, 1, QScreen) virtual int virtualDesktopNumber() const = 0; }; #endif @@ -81,7 +81,7 @@ struct Q_GUI_EXPORT QXcbScreen #if QT_CONFIG(vsp2) || defined(Q_CLANG_QDOC) struct Q_GUI_EXPORT QVsp2Screen { - QT_DECLARE_NATIVE_INTERFACE(QVsp2Screen) + QT_DECLARE_NATIVE_INTERFACE(QVsp2Screen, 1, QScreen) virtual int addLayer(int dmabufFd, const QSize &size, const QPoint &position, uint drmPixelFormat, uint bytesPerLine) = 0; virtual void setLayerBuffer(int id, int dmabufFd) = 0; virtual void setLayerPosition(int id, const QPoint &position) = 0; @@ -94,7 +94,7 @@ struct Q_GUI_EXPORT QVsp2Screen #if defined(Q_OS_WEBOS) || defined(Q_CLANG_QDOC) struct Q_GUI_EXPORT QWebOSScreen { - QT_DECLARE_NATIVE_INTERFACE(QWebOSScreen) + QT_DECLARE_NATIVE_INTERFACE(QWebOSScreen, 1, QScreen) virtual int addLayer(void *gbm_bo, const QRectF &geometry) = 0; virtual void setLayerBuffer(int id, void *gbm_bo) = 0; virtual void setLayerGeometry(int id, const QRectF &geometry) = 0; diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h index 22431e8d79..e35f527921 100644 --- a/src/gui/kernel/qplatformwindow_p.h +++ b/src/gui/kernel/qplatformwindow_p.h @@ -74,7 +74,7 @@ namespace QNativeInterface::Private { #if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC) struct Q_GUI_EXPORT QCocoaWindow { - QT_DECLARE_NATIVE_INTERFACE(QCocoaWindow) + QT_DECLARE_NATIVE_INTERFACE(QCocoaWindow, 1, QWindow) virtual void setContentBorderEnabled(bool enable) = 0; virtual QPoint bottomLeftClippedByNSWindowOffset() const = 0; }; @@ -83,7 +83,7 @@ struct Q_GUI_EXPORT QCocoaWindow #if QT_CONFIG(xcb) || defined(Q_CLANG_QDOC) struct Q_GUI_EXPORT QXcbWindow { - QT_DECLARE_NATIVE_INTERFACE(QXcbWindow) + QT_DECLARE_NATIVE_INTERFACE(QXcbWindow, 1, QWindow) enum WindowType { None = 0x000000, @@ -115,7 +115,7 @@ struct Q_GUI_EXPORT QXcbWindow #if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC) struct Q_GUI_EXPORT QWindowsWindow { - QT_DECLARE_NATIVE_INTERFACE(QWindowsWindow) + QT_DECLARE_NATIVE_INTERFACE(QWindowsWindow, 1, QWindow) virtual void setHasBorderInFullScreen(bool border) = 0; virtual bool hasBorderInFullScreen() const = 0; diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index b978638782..6f9f48d6c4 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -786,6 +786,31 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) return result; } +template <> +Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QScreen *that, const char *name, int revision) +{ + using namespace QNativeInterface::Private; + + auto *platformScreen = that->handle(); + Q_UNUSED(platformScreen); + Q_UNUSED(name); + Q_UNUSED(revision); + +#if QT_CONFIG(xcb) + QT_NATIVE_INTERFACE_RETURN_IF(QXcbScreen, platformScreen); +#endif + +#if QT_CONFIG(vsp2) + QT_NATIVE_INTERFACE_RETURN_IF(QVsp2Screen, platformScreen); +#endif + +#if defined(Q_OS_WEBOS) + QT_NATIVE_INTERFACE_RETURN_IF(QWebOSScreen, platformScreen); +#endif + + return nullptr; +} + #ifndef QT_NO_DEBUG_STREAM static inline void formatRect(QDebug &debug, const QRect r) diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h index 1bff3f4ec1..98271c0aa0 100644 --- a/src/gui/kernel/qscreen.h +++ b/src/gui/kernel/qscreen.h @@ -50,6 +50,7 @@ #include <QtGui/QTransform> #include <QtCore/qnamespace.h> +#include <QtCore/qnativeinterface.h> QT_BEGIN_NAMESPACE @@ -148,6 +149,8 @@ public: qreal refreshRate() const; + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + Q_SIGNALS: void geometryChanged(const QRect &geometry); void availableGeometryChanged(const QRect &geometry); diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index bacc49a98e..61c201559a 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -69,6 +69,7 @@ #include <QStyleHints> #include <qpa/qplatformcursor.h> +#include <qpa/qplatformwindow_p.h> QT_BEGIN_NAMESPACE @@ -3003,6 +3004,31 @@ bool QWindowPrivate::applyCursor() } #endif // QT_NO_CURSOR +template <> +Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QWindow *that, const char *name, int revision) +{ + using namespace QNativeInterface::Private; + + auto *platformWindow = that->handle(); + Q_UNUSED(platformWindow); + Q_UNUSED(name); + Q_UNUSED(revision); + +#if defined(Q_OS_WIN) + QT_NATIVE_INTERFACE_RETURN_IF(QWindowsWindow, platformWindow); +#endif + +#if QT_CONFIG(xcb) + QT_NATIVE_INTERFACE_RETURN_IF(QXcbWindow, platformWindow); +#endif + +#if defined(Q_OS_MACOS) + QT_NATIVE_INTERFACE_RETURN_IF(QCocoaWindow, platformWindow); +#endif + + return nullptr; +} + #ifndef QT_NO_DEBUG_STREAM QDebug operator<<(QDebug debug, const QWindow *window) { diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 14d8ba1810..6200727789 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -47,6 +47,7 @@ #include <QtCore/QRect> #include <QtCore/qnamespace.h> +#include <QtCore/qnativeinterface.h> #include <QtGui/qsurface.h> #include <QtGui/qsurfaceformat.h> @@ -283,6 +284,8 @@ public: QVulkanInstance *vulkanInstance() const; #endif + QT_DECLARE_NATIVE_INTERFACE_ACCESSOR + public Q_SLOTS: Q_REVISION(2, 1) void requestActivate(); |