From ce16e70985384a8371cca65a5c3b8ec4c7563f5c Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 20 Jun 2013 13:18:09 +0200 Subject: [PATCH] iOS: Activate window on touchesEnded instead of touchesBegan MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we await giving focus to a focus object until a press release, it also makes sense to await activating a window until a press release, since they both have to do with focus. By doing so, the input panel now stays open if the user selects a line edit in one window when a line edit in another window still has focus. We also avoid activating a window in case of a touch cancel (e.g as a result of the user flicking or triggering a gesture). Change-Id: Ic00c4be69c257fceb10ce2d5a81cb490ea93710f Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qioswindow.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 4c8a16b0bc..c8d0f823f6 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -183,12 +183,6 @@ - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - QWindow *window = m_qioswindow->window(); - - // Transfer focus to the touched window: - if (window != QGuiApplication::focusWindow()) - m_qioswindow->requestActivateWindow(); - // UIKit generates [Began -> Moved -> Ended] event sequences for // each touch point. Internally we keep a hashmap of active UITouch // points to QWindowSystemInterface::TouchPoints, and assigns each TouchPoint @@ -210,6 +204,14 @@ - (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)];