summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/ios/quiview.mm
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-10-11 16:43:42 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-10-14 01:57:43 +0000
commitd8c72f41548a01bf39f82e77da01a2be57a06d95 (patch)
tree4410ae85bd2ecfd718d9988229abdcc526639d2e /src/plugins/platforms/ios/quiview.mm
parent815341dbec1fd4f04fe76fc438cc9b3308ffafe9 (diff)
iOS: Take advantage of new synchronous API for QPA event delivery
By using the SynchronousDelivery specialization instead of flushing all window system events, we remove the risk of flushing an event that was added without our knowledge. For example, QGuiApplicationPrivate::processMouseEvent() used to prepend a mouse move event to the QPA queue, which is why we had a check for QWidgetWindow when flushing geometry changes. processMouseEvent no longer sends the move event via the QPA queue, so that's no longer an issue, but if it were to be reintroduced, we wouldn't need to check for QWidgetWindow, as we're not flushing all events anymore. Change-Id: Ib346ea9501cd88ddda6c2137981d3eb0922192a0 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios/quiview.mm')
-rw-r--r--src/plugins/platforms/ios/quiview.mm35
1 files changed, 11 insertions, 24 deletions
diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm
index 5c493617b1..2a1444e9e5 100644
--- a/src/plugins/platforms/ios/quiview.mm
+++ b/src/plugins/platforms/ios/quiview.mm
@@ -164,8 +164,7 @@
requestedGeometry : qt_window_private(m_qioswindow->window())->geometry;
QWindow *window = m_qioswindow->window();
- QWindowSystemInterface::handleGeometryChange(window, actualGeometry, previousGeometry);
- QWindowSystemInterface::flushWindowSystemEvents(window->inherits("QWidgetWindow") ? QEventLoop::ExcludeUserInputEvents : QEventLoop::AllEvents);
+ QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(window, actualGeometry, previousGeometry);
if (actualGeometry.size() != previousGeometry.size()) {
// Trigger expose event on resize
@@ -197,8 +196,7 @@
region = QRect(QPoint(), bounds);
}
- QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region);
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), region);
}
// -------------------------------------------------------------------------
@@ -223,13 +221,10 @@
qImDebug() << m_qioswindow->window() << "became first responder";
- if (qGuiApp->focusWindow() != m_qioswindow->window()) {
- QWindowSystemInterface::handleWindowActivated(m_qioswindow->window());
- QWindowSystemInterface::flushWindowSystemEvents();
- } else {
- qImDebug() << m_qioswindow->window()
- << "already active, not sending window activation";
- }
+ if (qGuiApp->focusWindow() != m_qioswindow->window())
+ QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window());
+ else
+ qImDebug() << m_qioswindow->window() << "already active, not sending window activation";
return YES;
}
@@ -264,10 +259,8 @@
qImDebug() << m_qioswindow->window() << "resigned first responder";
UIResponder *newResponder = FirstResponderCandidate::currentCandidate();
- if ([self responderShouldTriggerWindowDeactivation:newResponder]) {
- QWindowSystemInterface::handleWindowActivated(0);
- QWindowSystemInterface::flushWindowSystemEvents();
- }
+ if ([self responderShouldTriggerWindowDeactivation:newResponder])
+ QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(0);
return YES;
}
@@ -357,10 +350,8 @@
- (void)sendTouchEventWithTimestamp:(ulong)timeStamp
{
- // Send touch event synchronously
QIOSIntegration *iosIntegration = QIOSIntegration::instance();
- QWindowSystemInterface::handleTouchEvent(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values());
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values());
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@@ -438,10 +429,8 @@
NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime];
- // Send cancel touch event synchronously
QIOSIntegration *iosIntegration = static_cast<QIOSIntegration *>(QGuiApplicationPrivate::platformIntegration());
- QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
- QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemInterface::handleTouchCancelEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
}
- (int)mapPressTypeToKey:(UIPress*)press
@@ -464,14 +453,12 @@
// When handling the event (for example, as a back button), both press and
// release events must be handled accordingly.
- QScopedValueRollback<bool> syncRollback(QWindowSystemInterfacePrivate::synchronousWindowSystemEvents, true);
-
bool handled = false;
for (UIPress* press in presses) {
int key = [self mapPressTypeToKey:press];
if (key == Qt::Key_unknown)
continue;
- if (QWindowSystemInterface::handleKeyEvent(m_qioswindow->window(), type, key, Qt::NoModifier))
+ if (QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), type, key, Qt::NoModifier))
handled = true;
}