Add possibility to retrieve displayId for Android
When handling multiple screens in Android system it is needed to have the information about the display's Id. This patch provides this possibility. Task-number: QTBUG-105325 Change-Id: Id91aeaa59b17d5a098b672e220a5182b97320703 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
d4eb5d1110
commit
4f0272befb
@ -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
|
||||
|
@ -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
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <QtGui/qoffscreensurface_platform.h>
|
||||
#include <QtGui/private/qguiapplication_p.h>
|
||||
|
||||
#include <QtGui/qpa/qplatformscreen_p.h>
|
||||
|
||||
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
|
||||
|
@ -82,6 +82,7 @@ QAndroidPlatformScreen::QAndroidPlatformScreen(const QJniObject &displayObject)
|
||||
m_size = QSize(displayObject.callMethod<jint>("getWidth"), displayObject.callMethod<jint>("getHeight"));
|
||||
m_name = displayObject.callObjectMethod<jstring>("getName").toString();
|
||||
m_refreshRate = displayObject.callMethod<jfloat>("getRefreshRate");
|
||||
m_displayId = displayObject.callMethod<jint>("getDisplayId");
|
||||
|
||||
if (QNativeInterface::QAndroidApplication::sdkVersion() >= 23) {
|
||||
const QJniObject currentMode = displayObject.callObjectMethod<QtJniTypes::DisplayMode>("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)
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <QWaitCondition>
|
||||
#include <QtCore/QJniObject>
|
||||
#include <qpa/qplatformscreen.h>
|
||||
#include <qpa/qplatformscreen_p.h>
|
||||
|
||||
#include <android/native_window.h>
|
||||
|
||||
@ -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<Mode> m_modes;
|
||||
int m_currentMode = 0;
|
||||
int m_displayId = -1;
|
||||
|
||||
private:
|
||||
QDpi logicalDpi() const override;
|
||||
|
Loading…
Reference in New Issue
Block a user