iOS: Deliver all QWindowSystemInterface events synchronously

On iOS we want all delivery of events from the system to be handled
synchronously, as that's what the system expects.

We don't need to add a delivery template argument to each function
in QWindowSystemInterface that we want to delivery synchronously;
that's only needed for functions that a platform normally sends
asynch, but in some cases want to delivery synchronously.

For always delivering events synchronously we just need to change
the default delivery method.

The only events affected by this are the screen changes, and
window state change, which were not synchronous before, but
should be. All other events were already synchronous, though
either explicit delivery, of a flush.

Change-Id: Ib20ca342d1c076be0fbcf018c83735a416769cfe
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-11-27 11:40:12 +01:00
parent 5f66f87181
commit a0871ad225
4 changed files with 10 additions and 9 deletions

View File

@ -75,7 +75,7 @@ static void handleApplicationStateChanged(UIApplicationState uiApplicationState)
{
Qt::ApplicationState state = qtApplicationState(uiApplicationState);
qCDebug(lcQpaApplication) << "moved to" << state;
QWindowSystemInterface::handleApplicationStateChanged<QWindowSystemInterface::SynchronousDelivery>(state);
QWindowSystemInterface::handleApplicationStateChanged(state);
}
QT_BEGIN_NAMESPACE

View File

@ -422,6 +422,8 @@ QIOSEventDispatcher::QIOSEventDispatcher(QObject *parent)
, m_processEventLevel(0)
, m_runLoopExitObserver(this, &QIOSEventDispatcher::handleRunLoopExit, kCFRunLoopExit)
{
// We want all delivery of events from the system to be handled synchronously
QWindowSystemInterface::setSynchronousWindowSystemEvents(true);
}
bool __attribute__((returns_twice)) QIOSEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)

View File

@ -377,7 +377,6 @@
QScopedValueRollback<BOOL> rollback(m_inSendEventToFocusObject, true);
QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyPress, key, modifiers);
QWindowSystemInterface::handleKeyEvent(qApp->focusWindow(), QEvent::KeyRelease, key, modifiers);
QWindowSystemInterface::flushWindowSystemEvents();
}
#ifndef QT_NO_SHORTCUT

View File

@ -166,7 +166,7 @@
QWindow *window = m_qioswindow->window();
qCDebug(lcQpaWindow) << m_qioswindow->window() << "new geometry is" << actualGeometry;
QWindowSystemInterface::handleGeometryChange<QWindowSystemInterface::SynchronousDelivery>(window, actualGeometry, previousGeometry);
QWindowSystemInterface::handleGeometryChange(window, actualGeometry, previousGeometry);
if (actualGeometry.size() != previousGeometry.size()) {
// Trigger expose event on resize
@ -199,7 +199,7 @@
}
qCDebug(lcQpaWindow) << m_qioswindow->window() << region << "isExposed" << m_qioswindow->isExposed();
QWindowSystemInterface::handleExposeEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), region);
QWindowSystemInterface::handleExposeEvent(m_qioswindow->window(), region);
}
// -------------------------------------------------------------------------
@ -230,7 +230,7 @@
}
if (qGuiApp->focusWindow() != m_qioswindow->window())
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window());
QWindowSystemInterface::handleWindowActivated(m_qioswindow->window());
else
qImDebug() << m_qioswindow->window() << "already active, not sending window activation";
@ -268,7 +268,7 @@
UIResponder *newResponder = FirstResponderCandidate::currentCandidate();
if ([self responderShouldTriggerWindowDeactivation:newResponder])
QWindowSystemInterface::handleWindowActivated<QWindowSystemInterface::SynchronousDelivery>(0);
QWindowSystemInterface::handleWindowActivated(0);
return YES;
}
@ -359,7 +359,7 @@
- (void)sendTouchEventWithTimestamp:(ulong)timeStamp
{
QIOSIntegration *iosIntegration = QIOSIntegration::instance();
QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values());
QWindowSystemInterface::handleTouchEvent(m_qioswindow->window(), timeStamp, iosIntegration->touchDevice(), m_activeTouches.values());
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
@ -438,7 +438,7 @@
NSTimeInterval timestamp = event ? event.timestamp : [[NSProcessInfo processInfo] systemUptime];
QIOSIntegration *iosIntegration = static_cast<QIOSIntegration *>(QGuiApplicationPrivate::platformIntegration());
QWindowSystemInterface::handleTouchCancelEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
QWindowSystemInterface::handleTouchCancelEvent(m_qioswindow->window(), ulong(timestamp * 1000), iosIntegration->touchDevice());
}
- (int)mapPressTypeToKey:(UIPress*)press
@ -466,7 +466,7 @@
int key = [self mapPressTypeToKey:press];
if (key == Qt::Key_unknown)
continue;
if (QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(m_qioswindow->window(), type, key, Qt::NoModifier))
if (QWindowSystemInterface::handleKeyEvent(m_qioswindow->window(), type, key, Qt::NoModifier))
handled = true;
}