iOS: activate window on touchesBegan

We need to activate a window on touchesBegan instead of
touchesEnded. The reason we used to do this on touchesEnded was
to delay activating a window in case the user started e.g a
flick. But delaying the activation can cause problems if the app
activates a different window on press. We will then cancel
this out on release since we then raise the pressed window instead.
This is e.g typical when opening popups, and will cause focus to
not be restored properly when later closing the popup again.

Change-Id: I709b2f2e2633c9dc85c2761b0b176cd23c2f6b36
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
bb10
Richard Moe Gustavsen 2014-02-04 14:53:15 +01:00 committed by The Qt Project
parent e33eb15811
commit 3475dba53c
1 changed files with 3 additions and 8 deletions

View File

@ -247,6 +247,9 @@
m_activeTouches[touch].id = m_nextTouchId++;
}
if (m_activeTouches.size() == 1 && m_qioswindow->window() != QGuiApplication::focusWindow())
m_qioswindow->requestActivateWindow();
[self updateTouchList:touches withState:Qt::TouchPointPressed];
[self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)];
}
@ -259,14 +262,6 @@
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
QWindow *window = m_qioswindow->window();
if (window != QGuiApplication::focusWindow() && m_activeTouches.size() == 1) {
// Activate the touched window if the last touch was released inside it:
UITouch *touch = static_cast<UITouch *>([[touches allObjects] lastObject]);
if (CGRectContainsPoint([self bounds], [touch locationInView:self]))
m_qioswindow->requestActivateWindow();
}
[self updateTouchList:touches withState:Qt::TouchPointReleased];
[self sendTouchEventWithTimestamp:ulong(event.timestamp * 1000)];