iOS: Raise window level instead of hiding statusbar during VKB scroll

Hiding the statusbar using the normal iOS APIs result in QScreen
reporting new availableGeometry, which is not what we want. The
scroll of the screen is a purely visual effect, and shouldn't
have any effect on observable Qt APIs besides the keyboard rect
changing.

Instead of actually hiding the statusbar, we achieve the same
effect by raising the key window (and any other application
windows, including the keyboard) to the level of the statusbar,
effectively putting them above the statusbar. This still leaves
popups and alert windows above the key window, as normal.

Change-Id: Ib7694240ca86cfb9000de35bf0c49343ffb37e32
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
Tor Arne Vestbø 2014-12-12 15:14:04 +01:00 committed by Tor Arne Vestbø
parent 83bd9393e5
commit 8f9ced9857
2 changed files with 17 additions and 8 deletions

View File

@ -503,7 +503,22 @@ void QIOSInputContext::scroll(int y)
[rootView.layer addAnimation:animation forKey:@"AnimateSubLayerTransform"];
rootView.layer.sublayerTransform = translationTransform;
[rootView.qtViewController updateProperties];
bool keyboardScrollIsActive = y != 0;
// Raise all known windows to above the status-bar if we're scrolling the screen,
// while keeping the relative window level between the windows the same.
NSArray *applicationWindows = [[UIApplication sharedApplication] windows];
static QHash<UIWindow *, UIWindowLevel> originalWindowLevels;
for (UIWindow *window in applicationWindows) {
if (keyboardScrollIsActive && !originalWindowLevels.contains(window))
originalWindowLevels.insert(window, window.windowLevel);
UIWindowLevel windowLevelAdjustment = keyboardScrollIsActive ? UIWindowLevelStatusBar : 0;
window.windowLevel = originalWindowLevels.value(window) + windowLevelAdjustment;
if (!keyboardScrollIsActive)
originalWindowLevels.remove(window);
}
}
completion:^(BOOL){
if (self) {

View File

@ -281,14 +281,8 @@
// All decisions are based on the the top level window
focusWindow = qt_window_private(focusWindow)->topLevelWindow();
bool hasScrolledRootViewDueToVirtualKeyboard =
!CATransform3DIsIdentity(self.view.layer.sublayerTransform);
bool currentStatusBarVisibility = self.prefersStatusBarHidden;
self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen
|| hasScrolledRootViewDueToVirtualKeyboard;
self.preferredStatusBarUpdateAnimation = hasScrolledRootViewDueToVirtualKeyboard ?
UIStatusBarAnimationFade : UIStatusBarAnimationNone;
self.prefersStatusBarHidden = focusWindow->windowState() == Qt::WindowFullScreen;
if (self.prefersStatusBarHidden != currentStatusBarVisibility) {
#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_7_0)