24#include <QGuiApplication>
25#include <QOffscreenSurface>
26#include <QOpenGLContext>
28#include <QtCore/QJniObject>
29#include <QtGui/private/qeglpbuffer_p.h>
30#include <QtGui/private/qguiapplication_p.h>
31#include <QtGui/private/qoffscreensurface_p.h>
32#include <qpa/qplatformoffscreensurface.h>
33#include <qpa/qplatformwindow.h>
34#include <qpa/qwindowsysteminterface.h>
43#include <QtGui/qpa/qplatforminputcontextfactory_p.h>
49Q_CONSTINIT
QSize QAndroidPlatformIntegration::m_defaultScreenSize =
QSize(320, 455);
50Q_CONSTINIT
QRect QAndroidPlatformIntegration::m_defaultAvailableGeometry =
QRect(0, 0, 320, 455);
51Q_CONSTINIT
QSize QAndroidPlatformIntegration::m_defaultPhysicalSize =
QSize(50, 71);
56bool QAndroidPlatformIntegration::m_showPasswordEnabled =
false;
68 const QJniObject display = QJniObject::callStaticObjectMethod<QtJniTypes::Display>(
69 QtJniTypes::className<QtJniTypes::QtNative>(),
81 if (resource==
"JavaVM")
83 if (resource ==
"QtActivity")
85 if (resource ==
"QtService")
87 if (resource ==
"AndroidStyleData") {
96 if (resource ==
"AndroidStandardPalette") {
102 if (resource ==
"AndroidQWidgetFonts") {
108 if (resource ==
"AndroidDeviceName") {
118 if (resource ==
"vkSurface") {
135 if (resource ==
"eglcontext")
136 return platformContext->eglContext();
137 else if (resource ==
"eglconfig")
138 return platformContext->eglConfig();
139 else if (resource ==
"egldisplay")
140 return platformContext->eglDisplay();
154#if QT_CONFIG(accessibility)
175 m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
176 if (
Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY))
177 qFatal(
"Could not open egl display");
180 if (
Q_UNLIKELY(!eglInitialize(m_eglDisplay, &major, &minor)))
181 qFatal(
"Could not initialize egl display");
183 if (
Q_UNLIKELY(!eglBindAPI(EGL_OPENGL_ES_API)))
184 qFatal(
"Could not bind GL_ES API");
186 m_primaryDisplayId = QJniObject::getStaticField<jint>(
187 QtJniTypes::className<QtJniTypes::Display>(),
"DEFAULT_DISPLAY");
189 const QJniObject nativeDisplaysList = QJniObject::callStaticObjectMethod<QtJniTypes::List>(
190 QtJniTypes::className<QtJniTypes::QtNative>(),
191 "getAvailableDisplays");
193 const int numberOfAvailableDisplays = nativeDisplaysList.callMethod<jint>(
"size");
194 for (
int i = 0;
i < numberOfAvailableDisplays; ++
i) {
196 nativeDisplaysList.callObjectMethod<jobject, jint>(
"get", jint(
i));
197 const int displayId =
display.callMethod<jint>(
"getDisplayId");
198 const bool isPrimary = (m_primaryDisplayId == displayId);
205 m_screens[displayId] =
screen;
208 if (numberOfAvailableDisplays == 0) {
220#ifndef QT_NO_CLIPBOARD
226#if QT_CONFIG(accessibility)
231 if (!javaActivity.isValid())
234 if (javaActivity.isValid()) {
235 QJniObject resources = javaActivity.callObjectMethod(
"getResources",
"()Landroid/content/res/Resources;");
236 QJniObject configuration = resources.callObjectMethod(
"getConfiguration",
"()Landroid/content/res/Configuration;");
238 int touchScreen = configuration.getField<jint>(
"touchscreen");
239 if (touchScreen == QJniObject::getStaticField<jint>(
"android/content/res/Configuration",
"TOUCHSCREEN_FINGER")
240 || touchScreen == QJniObject::getStaticField<jint>(
"android/content/res/Configuration",
"TOUCHSCREEN_STYLUS"))
242 QJniObject pm = javaActivity.callObjectMethod(
"getPackageManager",
"()Landroid/content/pm/PackageManager;");
244 int maxTouchPoints = 1;
245 if (pm.callMethod<jboolean>(
"hasSystemFeature",
"(Ljava/lang/String;)Z",
246 QJniObject::getStaticObjectField(
"android/content/pm/PackageManager",
247 "FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND",
248 "Ljava/lang/String;").object())) {
250 }
else if (pm.callMethod<jboolean>(
"hasSystemFeature",
"(Ljava/lang/String;)Z",
251 QJniObject::getStaticObjectField(
"android/content/pm/PackageManager",
252 "FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT",
253 "Ljava/lang/String;").object())) {
255 }
else if (pm.callMethod<jboolean>(
"hasSystemFeature",
"(Ljava/lang/String;)Z",
256 QJniObject::getStaticObjectField(
"android/content/pm/PackageManager",
257 "FEATURE_TOUCHSCREEN_MULTITOUCH",
258 "Ljava/lang/String;").object())) {
274 auto contentResolver = javaActivity.callObjectMethod(
"getContentResolver",
"()Landroid/content/ContentResolver;");
275 Q_ASSERT(contentResolver.isValid());
276 QJniObject txtShowPassValue = QJniObject::callStaticObjectMethod(
277 "android/provider/Settings$System",
279 "(Landroid/content/ContentResolver;Ljava/lang/String;)Ljava/lang/String;",
280 contentResolver.object(),
281 QJniObject::getStaticObjectField(
"android/provider/Settings$System",
282 "TEXT_SHOW_PASSWORD",
283 "Ljava/lang/String;").object());
284 if (txtShowPassValue.isValid()) {
286 const int txtShowPass = txtShowPassValue.toString().toInt(&
ok);
287 m_showPasswordEnabled =
ok ? (txtShowPass == 1) :
false;
298 static bool needsWorkaround =
302 return needsWorkaround;
344 format.setAlphaBufferSize(8);
345 format.setRedBufferSize(8);
346 format.setGreenBufferSize(8);
347 format.setBlueBufferSize(8);
354 return QEGLPlatformContext::createFrom<QAndroidPlatformOpenGLContext>(
context,
display, m_eglDisplay, shareContext);
363 format.setAlphaBufferSize(8);
364 format.setRedBufferSize(8);
365 format.setGreenBufferSize(8);
366 format.setBlueBufferSize(8);
407 if (m_eglDisplay != EGL_NO_DISPLAY)
408 eglTerminate(m_eglDisplay);
410 delete m_androidPlatformNativeInterface;
412 delete m_androidSystemLocale;
414#ifndef QT_NO_CLIPBOARD
415 delete m_androidPlatformClipboard;
426#ifndef QT_NO_CLIPBOARD
429 return m_androidPlatformClipboard;
435 return m_inputContext.
data();
440 return m_androidPlatformNativeInterface;
445 return m_androidPlatformServices;
453 return m_showPasswordEnabled ? 1500 : 0;
485 int availableWidth,
int availableHeight,
486 int physicalWidth,
int physicalHeight,
487 int screenWidth,
int screenHeight)
489 m_defaultAvailableGeometry =
QRect(availableLeft, availableTop,
490 availableWidth, availableHeight);
491 m_defaultPhysicalSize =
QSize(physicalWidth, physicalHeight);
492 m_defaultScreenSize =
QSize(screenWidth, screenHeight);
498 m_orientation = currentOrientation;
499 m_nativeOrientation = nativeOrientation;
504 if (m_primaryScreen) {
506 m_defaultAvailableGeometry);
510#if QT_CONFIG(accessibility)
511QPlatformAccessibility *QAndroidPlatformIntegration::accessibility()
const
513 return m_accessibility;
548 const QSize &screenSize,
549 const QRect &availableGeometry)
551 if (m_primaryScreen) {
568 if (
result.first->second ==
nullptr) {
570 it->second = createScreenForDisplayId(displayId);
571 if (
it->second ==
nullptr)
573 const bool isPrimary = (m_primaryDisplayId == displayId);
575 m_primaryScreen =
it->second;
578 qWarning() <<
"Display with id" << displayId <<
"already exists.";
584 auto it = m_screens.
find(displayId);
585 if (
it == m_screens.
end() ||
it->second ==
nullptr) {
596 auto it = m_screens.
find(displayId);
598 if (
it == m_screens.
end())
601 if (
it->second !=
nullptr)
static void postEvent(QObject *receiver, QEvent *event, int priority=Qt::NormalEventPriority)
A pbuffer-based implementation of QPlatformOffscreenSurface for EGL.
An EGL context implementation.
iterator erase(iterator it)
iterator find(const Key &key)
std::pair< iterator, bool > insert(const Key &key, const T &value)
static QPlatformIntegration * platformIntegration()
static QOffscreenSurfacePrivate * get(QOffscreenSurface *surface)
QSurfaceFormat requestedFormat() const
Returns the requested surfaceformat of this offscreen surface.
static QString requested()
static QPlatformInputContext * create()
The QPlatformInputContext class abstracts the input method dependent data and composing state.
The QPlatformOpenGLContext class provides an abstraction for native GL contexts.
The QPointingDevice class describes a device from which mouse, touch or tablet events originate.
\inmodule QtCore\reentrant
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isNull() const
Returns true if this string is null; otherwise returns false.
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
static QThread * currentThread()
The QVulkanInstance class represents a native Vulkan instance, enabling Vulkan rendering onto a QSurf...
static void registerInputDevice(const QInputDevice *device)
static void handleScreenAdded(QPlatformScreen *screen, bool isPrimary=false)
Should be called by the implementation whenever a new screen is added.
static void handleScreenRemoved(QPlatformScreen *screen)
Should be called by the implementation whenever a screen is removed.
QSet< QString >::iterator it
struct wl_display * display
Combined button and popup list for selecting options.
void setAndroidPlatformIntegration(QAndroidPlatformIntegration *androidPlatformIntegration)
QBasicMutex * platformInterfaceMutex()
void notifyQtAndroidPluginRunning(bool running)
QtJniTypes::Activity activity()
QtJniTypes::Service service()
typedef EGLDisplay(EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum platform
#define Q_ARG(Type, data)
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLint GLsizei GLsizei GLenum format
QT_BEGIN_NAMESPACE Q_DECLARE_JNI_CLASS(Environment, "android/os/Environment")
Q_DECLARE_JNI_TYPE(File, "Ljava/io/File;")
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define QT_CONFIG(feature)
if(qFloatDistance(a, b)<(1<< 7))
[0]
static QJsonObject loadStyleData()