Enable access to QWindowsScreen from QScreen

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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
Piotr Srebrny 2022-07-05 16:19:49 +02:00
parent 3622fc81ea
commit 1e02c4acbf
4 changed files with 29 additions and 1 deletions

View File

@ -20,6 +20,10 @@
#include <QtCore/qpointer.h> #include <QtCore/qpointer.h>
#include <QtCore/qnativeinterface.h> #include <QtCore/qnativeinterface.h>
#if defined(Q_OS_WIN32)
#include <qwindowdefs_win.h>
#endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QScreen; class QScreen;
@ -68,6 +72,14 @@ struct Q_GUI_EXPORT QWebOSScreen
}; };
#endif #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 } // QNativeInterface::Private
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -775,6 +775,10 @@ void *QScreen::resolveInterface(const char *name, int revision) const
QT_NATIVE_INTERFACE_RETURN_IF(QWebOSScreen, platformScreen); QT_NATIVE_INTERFACE_RETURN_IF(QWebOSScreen, platformScreen);
#endif #endif
#if defined(Q_OS_WIN32)
QT_NATIVE_INTERFACE_RETURN_IF(QWindowsScreen, platformScreen);
#endif
return nullptr; return nullptr;
} }

View File

@ -8,6 +8,7 @@
#include <qpa/qplatformintegration.h> #include <qpa/qplatformintegration.h>
#include <qpa/qplatformwindow.h> #include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h> #include <qpa/qplatformwindow_p.h>
#include <qpa/qplatformscreen_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -88,6 +89,15 @@ QOpenGLContext *QNativeInterface::QWGLContext::fromNative(HGLRC context, HWND wi
QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWindowsApplication); 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 \enum QNativeInterface::Private::QWindowsApplication::TouchWindowTouchType

View File

@ -10,6 +10,7 @@
#include <QtCore/qpair.h> #include <QtCore/qpair.h>
#include <QtCore/qscopedpointer.h> #include <QtCore/qscopedpointer.h>
#include <qpa/qplatformscreen.h> #include <qpa/qplatformscreen.h>
#include <qpa/qplatformscreen_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -38,6 +39,7 @@ struct QWindowsScreenData
}; };
class QWindowsScreen : public QPlatformScreen class QWindowsScreen : public QPlatformScreen
, public QNativeInterface::Private::QWindowsScreen
{ {
public: public:
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
@ -69,7 +71,7 @@ public:
inline void handleChanges(const QWindowsScreenData &newData); inline void handleChanges(const QWindowsScreenData &newData);
HMONITOR handle() const; HMONITOR handle() const override;
#ifndef QT_NO_CURSOR #ifndef QT_NO_CURSOR
QPlatformCursor *cursor() const override { return m_cursor.data(); } QPlatformCursor *cursor() const override { return m_cursor.data(); }