iOS: implement QPlatformWindow::requestActivateWindow()
Dispite the name, 'requestActivateWindow' means raise and transfer focus to the window. Change-Id: Ib97321ed7ec8da90e924ff8155a95896c12160c9 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
This commit is contained in:
parent
e83bed82c1
commit
73e8796603
@ -69,6 +69,7 @@ public:
|
||||
|
||||
void raise() { raiseOrLower(true); }
|
||||
void lower() { raiseOrLower(false); }
|
||||
void requestActivateWindow();
|
||||
|
||||
qreal devicePixelRatio() const;
|
||||
int effectiveWidth() const;
|
||||
|
@ -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<QIOSWindow *>(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
|
||||
|
Loading…
Reference in New Issue
Block a user