From 1e02c4acbf9a8d70c62ce9fd384eba0f438a4a01 Mon Sep 17 00:00:00 2001 From: Piotr Srebrny Date: Tue, 5 Jul 2022 16:19:49 +0200 Subject: [PATCH] Enable access to QWindowsScreen from QScreen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds access to the QWindowsScreen interface from QScreen with the aim to provide the native handle of QScreen. This handle will be used in QtMultmedia to find DXGI interfaces related to that screen. Change-Id: I93f066b3f0d4d70331aeedab36bb0db111a34556 Reviewed-by: Tor Arne Vestbø --- src/gui/kernel/qplatformscreen_p.h | 12 ++++++++++++ src/gui/kernel/qscreen.cpp | 4 ++++ src/gui/platform/windows/qwindowsnativeinterface.cpp | 10 ++++++++++ src/plugins/platforms/windows/qwindowsscreen.h | 4 +++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h index 2d3fb2d4182..6c79978f796 100644 --- a/src/gui/kernel/qplatformscreen_p.h +++ b/src/gui/kernel/qplatformscreen_p.h @@ -20,6 +20,10 @@ #include #include +#if defined(Q_OS_WIN32) +#include +#endif + QT_BEGIN_NAMESPACE class QScreen; @@ -68,6 +72,14 @@ struct Q_GUI_EXPORT QWebOSScreen }; #endif +#if defined(Q_OS_WIN32) || defined(Q_CLANG_QDOC) +struct Q_GUI_EXPORT QWindowsScreen +{ + QT_DECLARE_NATIVE_INTERFACE(QWindowsScreen, 1, QScreen) + virtual HMONITOR handle() const = 0; +}; +#endif + } // QNativeInterface::Private QT_END_NAMESPACE diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index ac33185900d..1bc6042a1aa 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -775,6 +775,10 @@ void *QScreen::resolveInterface(const char *name, int revision) const QT_NATIVE_INTERFACE_RETURN_IF(QWebOSScreen, platformScreen); #endif +#if defined(Q_OS_WIN32) + QT_NATIVE_INTERFACE_RETURN_IF(QWindowsScreen, platformScreen); +#endif + return nullptr; } diff --git a/src/gui/platform/windows/qwindowsnativeinterface.cpp b/src/gui/platform/windows/qwindowsnativeinterface.cpp index e4339c9aa95..fe6f4e96dd3 100644 --- a/src/gui/platform/windows/qwindowsnativeinterface.cpp +++ b/src/gui/platform/windows/qwindowsnativeinterface.cpp @@ -8,6 +8,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -88,6 +89,15 @@ QOpenGLContext *QNativeInterface::QWGLContext::fromNative(HGLRC context, HWND wi QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsApplication); +/*! + \class QNativeInterface::Private::QWindowsScreen + \since 6.5 + \internal + \brief Native interface to QScreen, to be retrieved from QPlatformIntegration. + \inmodule QtGui + \ingroup native-interfaces +*/ +QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsScreen); /*! \enum QNativeInterface::Private::QWindowsApplication::TouchWindowTouchType diff --git a/src/plugins/platforms/windows/qwindowsscreen.h b/src/plugins/platforms/windows/qwindowsscreen.h index 0635f172ad8..b1c94d2204c 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.h +++ b/src/plugins/platforms/windows/qwindowsscreen.h @@ -10,6 +10,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -38,6 +39,7 @@ struct QWindowsScreenData }; class QWindowsScreen : public QPlatformScreen + , public QNativeInterface::Private::QWindowsScreen { public: #ifndef QT_NO_CURSOR @@ -69,7 +71,7 @@ public: inline void handleChanges(const QWindowsScreenData &newData); - HMONITOR handle() const; + HMONITOR handle() const override; #ifndef QT_NO_CURSOR QPlatformCursor *cursor() const override { return m_cursor.data(); }