diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h index f7c9d94154..e871fc16c8 100644 --- a/src/gui/kernel/qplatformscreen_p.h +++ b/src/gui/kernel/qplatformscreen_p.h @@ -92,6 +92,14 @@ struct Q_GUI_EXPORT QWaylandScreen }; #endif +#if defined(Q_OS_ANDROID) || defined(Q_QDOC) +struct Q_GUI_EXPORT QAndroidScreen +{ + QT_DECLARE_NATIVE_INTERFACE(QAndroidScreen, 1, QScreen) + virtual int displayId() const = 0; +}; +#endif + } // QNativeInterface::Private QT_END_NAMESPACE diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index efaba3e426..2cc38cb638 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -759,6 +759,10 @@ void *QScreen::resolveInterface(const char *name, int revision) const QT_NATIVE_INTERFACE_RETURN_IF(QWindowsScreen, platformScreen); #endif +#if defined(Q_OS_ANDROID) + QT_NATIVE_INTERFACE_RETURN_IF(QAndroidScreen, platformScreen); +#endif + #if defined(Q_OS_UNIX) QT_NATIVE_INTERFACE_RETURN_IF(QWaylandScreen, platformScreen); #endif diff --git a/src/gui/platform/android/qandroidnativeinterface.cpp b/src/gui/platform/android/qandroidnativeinterface.cpp index 3062b5255e..1bc718cbf1 100644 --- a/src/gui/platform/android/qandroidnativeinterface.cpp +++ b/src/gui/platform/android/qandroidnativeinterface.cpp @@ -7,6 +7,8 @@ #include #include +#include + QT_BEGIN_NAMESPACE using namespace QNativeInterface::Private; @@ -33,4 +35,6 @@ QOffscreenSurface *QNativeInterface::QAndroidOffscreenSurface::fromNative(ANati &QAndroidOffScreenIntegration::createOffscreenSurface>(nativeSurface); } +QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QAndroidScreen); + QT_END_NAMESPACE diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 1c867f435d..451a8d84cb 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -82,6 +82,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen(const QJniObject &displayObject) m_size = QSize(displayObject.callMethod("getWidth"), displayObject.callMethod("getHeight")); m_name = displayObject.callObjectMethod("getName").toString(); m_refreshRate = displayObject.callMethod("getRefreshRate"); + m_displayId = displayObject.callMethod("getDisplayId"); if (QNativeInterface::QAndroidApplication::sdkVersion() >= 23) { const QJniObject currentMode = displayObject.callObjectMethod("getMode"); @@ -271,6 +272,11 @@ void QAndroidPlatformScreen::setSizeParameters(const QSize &physicalSize, const } } +int QAndroidPlatformScreen::displayId() const +{ + return m_displayId; +} + void QAndroidPlatformScreen::setRefreshRate(qreal refreshRate) { if (refreshRate == m_refreshRate) diff --git a/src/plugins/platforms/android/qandroidplatformscreen.h b/src/plugins/platforms/android/qandroidplatformscreen.h index 390bda0416..076530613b 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.h +++ b/src/plugins/platforms/android/qandroidplatformscreen.h @@ -13,6 +13,7 @@ #include #include #include +#include #include @@ -20,7 +21,9 @@ QT_BEGIN_NAMESPACE class QAndroidPlatformWindow; -class QAndroidPlatformScreen: public QObject, public QPlatformScreen, public AndroidSurfaceClient +class QAndroidPlatformScreen: public QObject, + public QPlatformScreen, public AndroidSurfaceClient, + public QNativeInterface::Private::QAndroidScreen { Q_OBJECT public: @@ -50,6 +53,7 @@ public: void scheduleUpdate(); void topWindowChanged(QWindow *w); int rasterSurfaces(); + int displayId() const override; public slots: void setDirty(const QRect &rect); @@ -77,6 +81,7 @@ protected: QString m_name; QList m_modes; int m_currentMode = 0; + int m_displayId = -1; private: QDpi logicalDpi() const override;