summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/qioswindow.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/ios/qioswindow.mm')
-rw-r--r--src/plugins/platforms/ios/qioswindow.mm32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm
index 0c3ae8e834..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<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)];
@@ -247,6 +249,23 @@
return YES;
}
+- (BOOL)becomeFirstResponder
+{
+ // On iOS, a QWindow should only have input focus when the input panel is
+ // open. This is to stop cursors and focus rects from being drawn when the
+ // user cannot type. And since the keyboard will open when a view becomes
+ // the first responder, it's now a good time to inform QPA that the QWindow
+ // this view backs became active:
+ QWindowSystemInterface::handleWindowActivated(m_qioswindow->window());
+ return [super becomeFirstResponder];
+}
+
+- (BOOL)resignFirstResponder
+{
+ QWindowSystemInterface::handleWindowActivated(0);
+ return [super resignFirstResponder];
+}
+
- (BOOL)hasText
{
return YES;
@@ -416,7 +435,6 @@ void QIOSWindow::requestActivateWindow()
raise();
QPlatformInputContext *context = QGuiApplicationPrivate::platformIntegration()->inputContext();
static_cast<QIOSInputContext *>(context)->focusViewChanged(m_view);
- QPlatformWindow::requestActivateWindow();
}
void QIOSWindow::raiseOrLower(bool raise)