diff options
Diffstat (limited to 'src/plugins/platforms/android')
5 files changed, 33 insertions, 23 deletions
diff --git a/src/plugins/platforms/android/androidjniinput.cpp b/src/plugins/platforms/android/androidjniinput.cpp index defc59abf0..2c4b664487 100644 --- a/src/plugins/platforms/android/androidjniinput.cpp +++ b/src/plugins/platforms/android/androidjniinput.cpp @@ -47,6 +47,7 @@ #include <QTouchEvent> #include <QPointer> +#include <QGuiApplication> #include <QDebug> QT_BEGIN_NAMESPACE @@ -58,10 +59,10 @@ namespace QtAndroidInput static jmethodID m_showSoftwareKeyboardMethodID = 0; static jmethodID m_resetSoftwareKeyboardMethodID = 0; static jmethodID m_hideSoftwareKeyboardMethodID = 0; - static jmethodID m_isSoftwareKeyboardVisibleMethodID = 0; static jmethodID m_updateSelectionMethodID = 0; static bool m_ignoreMouseEvents = false; + static bool m_softwareKeyboardVisible = false; static QList<QWindowSystemInterface::TouchPoint> m_touchPoints; @@ -124,15 +125,7 @@ namespace QtAndroidInput bool isSoftwareKeyboardVisible() { - AttachedJNIEnv env; - if (!env.jniEnv) - return false; - - bool visibility = env.jniEnv->CallStaticBooleanMethod(applicationClass(), m_isSoftwareKeyboardVisibleMethodID); -#ifdef QT_DEBUG_ANDROID_IM_PROTOCOL - qDebug() << "@@@ ISSOFTWAREKEYBOARDVISIBLE" << visibility; -#endif - return visibility; + return m_softwareKeyboardVisible; } @@ -713,10 +706,11 @@ namespace QtAndroidInput false); } - static void keyboardVisibilityChanged(JNIEnv */*env*/, jobject /*thiz*/, jboolean /*visibility*/) + static void keyboardVisibilityChanged(JNIEnv */*env*/, jobject /*thiz*/, jboolean visibility) { + m_softwareKeyboardVisible = visibility; QAndroidInputContext *inputContext = QAndroidInputContext::androidInputContext(); - if (inputContext) + if (inputContext && qGuiApp) inputContext->emitInputPanelVisibleChanged(); #ifdef QT_DEBUG_ANDROID_IM_PROTOCOL qDebug() << "@@@ KEYBOARDVISIBILITYCHANGED" << inputContext; @@ -755,7 +749,6 @@ namespace QtAndroidInput GET_AND_CHECK_STATIC_METHOD(m_showSoftwareKeyboardMethodID, appClass, "showSoftwareKeyboard", "(IIIII)V"); GET_AND_CHECK_STATIC_METHOD(m_resetSoftwareKeyboardMethodID, appClass, "resetSoftwareKeyboard", "()V"); GET_AND_CHECK_STATIC_METHOD(m_hideSoftwareKeyboardMethodID, appClass, "hideSoftwareKeyboard", "()V"); - GET_AND_CHECK_STATIC_METHOD(m_isSoftwareKeyboardVisibleMethodID, appClass, "isSoftwareKeyboardVisible", "()Z"); GET_AND_CHECK_STATIC_METHOD(m_updateSelectionMethodID, appClass, "updateSelection", "(IIII)V"); return true; } diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 7b76177141..6df9f56c2c 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -559,6 +559,12 @@ static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, jint desktopWidthPixels, jint desktopHeightPixels, jdouble xdpi, jdouble ydpi, jdouble scaledDensity) { + // Android does not give us the correct screen size for immersive mode, but + // the surface does have the right size + + widthPixels = qMax(widthPixels, desktopWidthPixels); + heightPixels = qMax(heightPixels, desktopHeightPixels); + m_desktopWidthPixels = desktopWidthPixels; m_desktopHeightPixels = desktopHeightPixels; m_scaledDensity = scaledDensity; @@ -573,8 +579,8 @@ static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, } else { m_androidPlatformIntegration->setDisplayMetrics(qRound(double(widthPixels) / xdpi * 25.4), qRound(double(heightPixels) / ydpi * 25.4)); - m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); m_androidPlatformIntegration->setScreenSize(widthPixels, heightPixels); + m_androidPlatformIntegration->setDesktopSize(desktopWidthPixels, desktopHeightPixels); } } diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index 53cb3588f6..cbf13e81d5 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -121,8 +121,8 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen = new QAndroidPlatformScreen(); screenAdded(m_primaryScreen); m_primaryScreen->setPhysicalSize(QSize(m_defaultPhysicalSizeWidth, m_defaultPhysicalSizeHeight)); - m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); m_primaryScreen->setSize(QSize(m_defaultScreenWidth, m_defaultScreenHeight)); + m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); m_mainThread = QThread::currentThread(); QtAndroid::setAndroidPlatformIntegration(this); diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index 2c6e8370ce..e8dc8a9c5c 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -64,17 +64,28 @@ void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) QEGLPlatformContext::swapBuffers(surface); } -bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaroud() +bool QAndroidPlatformOpenGLContext::needsFBOReadBackWorkaround() { static bool set = false; static bool needsWorkaround = false; if (!set) { - const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); - needsWorkaround = - qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450 - || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205 - || qstrcmp(rendererString, "GC1000 core") == 0; + QByteArray env = qgetenv("QT_ANDROID_DISABLE_GLYPH_CACHE_WORKAROUND"); + needsWorkaround = env.isEmpty() || env == "0" || env == "false"; + + if (!needsWorkaround) { + const char *rendererString = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); + needsWorkaround = + qstrncmp(rendererString, "Mali-4xx", 6) == 0 // Mali-400, Mali-450 + || qstrncmp(rendererString, "Adreno (TM) 2xx", 13) == 0 // Adreno 200, 203, 205 + || qstrncmp(rendererString, "Adreno 2xx", 8) == 0 // Same as above but without the '(TM)' + || qstrncmp(rendererString, "Adreno (TM) 30x", 14) == 0 // Adreno 302, 305 + || qstrncmp(rendererString, "Adreno 30x", 9) == 0 // Same as above but without the '(TM)' + || qstrcmp(rendererString, "GC800 core") == 0 + || qstrcmp(rendererString, "GC1000 core") == 0 + || qstrcmp(rendererString, "Immersion.16") == 0; + } + set = true; } @@ -90,7 +101,7 @@ bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface) if (rendererString != 0 && qstrncmp(rendererString, "Android Emulator", 16) == 0) ctx_d->workaround_missingPrecisionQualifiers = true; - if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaroud()) + if (!ctx_d->workaround_brokenFBOReadBack && needsFBOReadBackWorkaround()) ctx_d->workaround_brokenFBOReadBack = true; return ret; diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.h b/src/plugins/platforms/android/qandroidplatformopenglcontext.h index 10a89d541b..b734cb4db9 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.h +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.h @@ -57,7 +57,7 @@ public: private: virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface); - static bool needsFBOReadBackWorkaroud(); + static bool needsFBOReadBackWorkaround(); }; QT_END_NAMESPACE |