diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> | 2013-08-15 10:45:51 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-19 16:52:21 +0200 |
commit | 05ddae12d18a348afd942fd85a8d8773698da3a1 (patch) | |
tree | b8b50871c8b0c014201311ef5b3f00c9b90ac023 /src/plugins/platforms/android/src/androidjnimain.cpp | |
parent | 07502898e982dae54f919582350af8be3b4ad2cc (diff) |
Android: Fix orientation change on Android 4.3
In Android 4.3, we will get a new native window pointer for the
same surface (the old surface has not been destroyed), whereas
before we would get the same pointer, thus hitting the
"sameNativeWindow" branch. This revealed some bugs in the
surfaceChanged code path when the old surface had not been
destroyed. This path is now taken both when there's no old surface
(the app has been suspended in the mean time) and when the
orientation changes.
To handle the second case, we need to make sure:
1. We update the static pointer
2. We update the pointers in the platform windows
3. We don't add a second reference to the static data for
windows
4. We schedule an update of the window size
Task-number: QTBUG-32878
Change-Id: I47257615f9ba820315fc98d7a804e52223f430bf
Reviewed-by: Christian Stromme <christian.stromme@digia.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Diffstat (limited to 'src/plugins/platforms/android/src/androidjnimain.cpp')
-rw-r--r-- | src/plugins/platforms/android/src/androidjnimain.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp index 162a8aa977..74183b3107 100644 --- a/src/plugins/platforms/android/src/androidjnimain.cpp +++ b/src/plugins/platforms/android/src/androidjnimain.cpp @@ -555,33 +555,37 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jobject jSurface) m_nativeWindow = nativeWindow; if (m_waitForWindow) m_waitForWindowSemaphore.release(); - if (m_androidPlatformIntegration && !sameNativeWindow) { - m_surfaceMutex.unlock(); - m_androidPlatformIntegration->surfaceChanged(); - } else if (m_androidPlatformIntegration && sameNativeWindow) { - QPlatformScreen *screen = m_androidPlatformIntegration->screen(); + + if (m_androidPlatformIntegration) { QSize size = QtAndroid::nativeWindowSize(); + QPlatformScreen *screen = m_androidPlatformIntegration->screen(); QRect geometry(QPoint(0, 0), size); QWindowSystemInterface::handleScreenAvailableGeometryChange(screen->screen(), geometry); QWindowSystemInterface::handleScreenGeometryChange(screen->screen(), geometry); - // Resize all top level windows, since they share the same surface - foreach (QWindow *w, QGuiApplication::topLevelWindows()) { - QAndroidOpenGLPlatformWindow *window = - static_cast<QAndroidOpenGLPlatformWindow *>(w->handle()); - - if (window != 0) { - window->lock(); - window->scheduleResize(size); - - QWindowSystemInterface::handleExposeEvent(window->window(), - QRegion(window->window()->geometry())); - window->unlock(); + if (!sameNativeWindow) { + m_surfaceMutex.unlock(); + m_androidPlatformIntegration->surfaceChanged(); + } else { + // Resize all top level windows, since they share the same surface + foreach (QWindow *w, QGuiApplication::topLevelWindows()) { + QAndroidOpenGLPlatformWindow *window = + static_cast<QAndroidOpenGLPlatformWindow *>(w->handle()); + + if (window != 0) { + window->lock(); + window->scheduleResize(size); + + QWindowSystemInterface::handleExposeEvent(window->window(), + QRegion(window->window()->geometry())); + window->unlock(); + } } + + m_surfaceMutex.unlock(); } - m_surfaceMutex.unlock(); } else { m_surfaceMutex.unlock(); } |