summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/android')
-rw-r--r--src/plugins/platforms/android/src/androidjnimain.cpp20
-rw-r--r--src/plugins/platforms/android/src/androidjnimain.h2
-rw-r--r--src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp6
-rw-r--r--src/plugins/platforms/android/src/qandroidplatformintegration.cpp1
-rw-r--r--src/plugins/platforms/android/src/raster/qandroidplatformwindow.cpp13
-rw-r--r--src/plugins/platforms/android/src/raster/qandroidplatformwindow.h2
6 files changed, 44 insertions, 0 deletions
diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp
index 8282b3b558..023cce30ec 100644
--- a/src/plugins/platforms/android/src/androidjnimain.cpp
+++ b/src/plugins/platforms/android/src/androidjnimain.cpp
@@ -89,6 +89,9 @@ static AAssetManager *m_assetManager = NULL;
static jobject m_resourcesObj;
static jobject m_activityObject = NULL;
+static bool m_activityActive = true; // defaults to true because when the platform plugin is
+ // initialized, QtActivity::onResume() has already been called
+
static jclass m_bitmapClass = 0;
static jmethodID m_createBitmapMethodID = 0;
static jobject m_ARGB_8888_BitmapConfigValue = 0;
@@ -320,6 +323,12 @@ namespace QtAndroid
return m_activityObject;
}
+ void setApplicationActive()
+ {
+ if (m_activityActive)
+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive);
+ }
+
jobject createBitmap(QImage img, JNIEnv *env)
{
if (img.format() != QImage::Format_ARGB32 && img.format() != QImage::Format_RGB16)
@@ -652,6 +661,16 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/)
#endif
}
+static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state)
+{
+ m_activityActive = (state == Qt::ApplicationActive);
+
+ if (!m_androidPlatformIntegration)
+ return;
+
+ QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState(state));
+}
+
static void handleOrientationChanged(JNIEnv */*env*/, jobject /*thiz*/, jint newOrientation)
{
if (m_androidPlatformIntegration == 0)
@@ -678,6 +697,7 @@ static JNINativeMethod methods[] = {
{"lockSurface", "()V", (void *)lockSurface},
{"unlockSurface", "()V", (void *)unlockSurface},
{"updateWindow", "()V", (void *)updateWindow},
+ {"updateApplicationState", "(I)V", (void *)updateApplicationState},
{"handleOrientationChanged", "(I)V", (void *)handleOrientationChanged}
};
diff --git a/src/plugins/platforms/android/src/androidjnimain.h b/src/plugins/platforms/android/src/androidjnimain.h
index f75df55e02..9a3d8a9607 100644
--- a/src/plugins/platforms/android/src/androidjnimain.h
+++ b/src/plugins/platforms/android/src/androidjnimain.h
@@ -88,6 +88,8 @@ namespace QtAndroid
jclass applicationClass();
jobject activity();
+ void setApplicationActive();
+
jobject createBitmap(QImage img, JNIEnv *env = 0);
jobject createBitmapDrawable(jobject bitmap, JNIEnv *env = 0);
diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp
index 24a7debd1f..f9262c69f6 100644
--- a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp
+++ b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp
@@ -120,6 +120,12 @@ void QAndroidOpenGLPlatformWindow::raise()
void QAndroidOpenGLPlatformWindow::setVisible(bool visible)
{
QEglFSWindow::setVisible(visible);
+
+ // The Android Activity is activated before Qt is initialized, causing the application state to
+ // never be set to 'active'. We explicitly set this state when the first window becomes visible.
+ if (visible)
+ QtAndroid::setApplicationActive();
+
QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); // Expose event
QWindowSystemInterface::flushWindowSystemEvents();
}
diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp
index 3e7b046edb..045eb57148 100644
--- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp
+++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp
@@ -121,6 +121,7 @@ bool QAndroidPlatformIntegration::hasCapability(Capability cap) const
{
switch (cap) {
case ThreadedPixmaps: return true;
+ case ApplicationState: return true;
case NonFullScreenWindows: return false;
case NativeWidgets: return false;
default:
diff --git a/src/plugins/platforms/android/src/raster/qandroidplatformwindow.cpp b/src/plugins/platforms/android/src/raster/qandroidplatformwindow.cpp
index 94a69c10c7..f5fce0ae34 100644
--- a/src/plugins/platforms/android/src/raster/qandroidplatformwindow.cpp
+++ b/src/plugins/platforms/android/src/raster/qandroidplatformwindow.cpp
@@ -41,6 +41,9 @@
#include "qandroidplatformwindow.h"
+#include "androidjnimain.h"
+#include <qpa/qwindowsysteminterface.h>
+
QAndroidPlatformWindow::QAndroidPlatformWindow(QWindow *window) : QFbWindow(window)
{
}
@@ -54,3 +57,13 @@ void QAndroidPlatformWindow::propagateSizeHints()
{
//shut up warning from default implementation
}
+
+void QAndroidPlatformWindow::setVisible(bool visible)
+{
+ QFbWindow::setVisible(visible);
+
+ // The Android Activity is activated before Qt is initialized, causing the application state to
+ // never be set to 'active'. We explicitly set this state when the first window becomes visible.
+ if (visible)
+ QtAndroid::setApplicationActive();
+}
diff --git a/src/plugins/platforms/android/src/raster/qandroidplatformwindow.h b/src/plugins/platforms/android/src/raster/qandroidplatformwindow.h
index 3ee815fd69..58e6451ea1 100644
--- a/src/plugins/platforms/android/src/raster/qandroidplatformwindow.h
+++ b/src/plugins/platforms/android/src/raster/qandroidplatformwindow.h
@@ -52,6 +52,8 @@ public:
void propagateSizeHints();
+ void setVisible(bool visible);
+
public slots:
void setGeometry(const QRect &rect);