From 58415530aacc5ef92f0076f7dff04d4f5074c4da Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 25 Jan 2013 11:00:54 +0100 Subject: iOS: avoid activating modally blocked windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that the user cannot activate a window that is modally shaddowed. Change-Id: Ib92be319d017460bbc1ef63ad7556cb4758dfa6c Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.h | 1 + src/plugins/platforms/ios/qioswindow.mm | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index 2d7c4c9103..31fd8d3185 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -94,6 +94,7 @@ private: void raiseOrLower(bool raise); void updateWindowLevel(); + bool blockedByModal(); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 4aa6b8a24e..9bc2541715 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -345,6 +345,12 @@ QIOSWindow::~QIOSWindow() [m_view release]; } +bool QIOSWindow::blockedByModal() +{ + QWindow *modalWindow = QGuiApplication::modalWindow(); + return modalWindow && modalWindow != window(); +} + void QIOSWindow::setVisible(bool visible) { QPlatformWindow::setVisible(visible); @@ -355,8 +361,16 @@ void QIOSWindow::setVisible(bool visible) // Since iOS doesn't do window management the way a Qt application // expects, we need to raise and activate windows ourselves: - if (visible) { + if (visible) updateWindowLevel(); + + if (blockedByModal()) { + if (visible) + raise(); + return; + } + + if (visible) { requestActivateWindow(); } else { // Activate top-most visible QWindow: @@ -415,6 +429,9 @@ void QIOSWindow::requestActivateWindow() // Note that several windows can be active at the same time if they exist in the same // hierarchy (transient children). But only one window can be QGuiApplication::focusWindow(). // Dispite the name, 'requestActivateWindow' means raise and transfer focus to the window: + if (blockedByModal()) + return; + raise(); QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext(); static_cast(context)->focusViewChanged(m_view); -- cgit v1.2.3