From 73e879660376a40fd21ded84020f2e527f22cd13 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 15 Jan 2013 14:30:20 +0100 Subject: [PATCH] iOS: implement QPlatformWindow::requestActivateWindow() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dispite the name, 'requestActivateWindow' means raise and transfer focus to the window. Change-Id: Ib97321ed7ec8da90e924ff8155a95896c12160c9 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.h | 1 + src/plugins/platforms/ios/qioswindow.mm | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index e7b04c53eb..01c1978a56 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -69,6 +69,7 @@ public: void raise() { raiseOrLower(true); } void lower() { raiseOrLower(false); } + void requestActivateWindow(); qreal devicePixelRatio() const; int effectiveWidth() const; diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 488962ab66..59f82fb64e 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -153,10 +153,8 @@ { // Transfer focus to the touched window: QWindow *window = m_qioswindow->window(); - if (window != QGuiApplication::focusWindow()) { - m_qioswindow->raise(); - QWindowSystemInterface::handleWindowActivated(window); - } + if (window != QGuiApplication::focusWindow()) + m_qioswindow->requestActivateWindow(); [self sendMouseEventForTouches:touches withEvent:event fakeButtons:Qt::LeftButton]; } @@ -270,8 +268,7 @@ 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) { - raise(); - QWindowSystemInterface::handleWindowActivated(window()); + requestActivateWindow(); } else { // Activate top-most visible QWindow: NSArray *subviews = rootViewController().view.subviews; @@ -279,7 +276,7 @@ void QIOSWindow::setVisible(bool visible) UIView *view = [subviews objectAtIndex:i]; if (!view.hidden) { if (QWindow *window = view.qwindow) { - QWindowSystemInterface::handleWindowActivated(window); + static_cast(window->handle())->requestActivateWindow(); break; } } @@ -324,6 +321,15 @@ void QIOSWindow::setWindowState(Qt::WindowState state) } } +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: + raise(); + QPlatformWindow::requestActivateWindow(); +} + void QIOSWindow::raiseOrLower(bool raise) { // Re-insert m_view at the correct index among its sibling views (QWindows), and ensure