iOS: avoid activating modally blocked windows
Make sure that the user cannot activate a window that is modally shaddowed. Change-Id: Ib92be319d017460bbc1ef63ad7556cb4758dfa6c Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
parent
38e6d5a915
commit
58415530aa
@ -94,6 +94,7 @@ private:
|
||||
|
||||
void raiseOrLower(bool raise);
|
||||
void updateWindowLevel();
|
||||
bool blockedByModal();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -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<QIOSInputContext *>(context)->focusViewChanged(m_view);
|
||||
|
Loading…
Reference in New Issue
Block a user