From 3475dba53c34f986776b3c8b2a11e322c3ad4d71 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 4 Feb 2014 14:53:15 +0100 Subject: iOS: activate window on touchesBegan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/plugins/platforms/ios/qioswindow.mm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/plugins/platforms/ios/qioswindow.mm') diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 41a253e605..f0f436f405 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -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([[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)]; -- cgit v1.2.3