Add QGuiApplication::sync() function
This will allow applications to make sure Qt has the same state as the window system at any given point. The use of this function is discouraged but it is very useful for auto tests. Change-Id: I691bff365fc391e9d7213f2607008983505bb774 Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
This commit is contained in:
parent
396aa7fade
commit
ac693bf754
@ -2801,6 +2801,27 @@ bool QGuiApplication::isSavingSession() const
|
||||
return d->is_saving_session;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 5.2
|
||||
|
||||
Function that can be used to sync Qt state with the Window Systems state.
|
||||
|
||||
This function will first empty Qts events by calling QCoreApplication::processEvents(),
|
||||
then the platform plugin will sync up with the windowsystem, and finally Qts events
|
||||
will be delived by another call to QCoreApplication::processEvents();
|
||||
|
||||
This function is timeconsuming and its use is discouraged.
|
||||
*/
|
||||
void QGuiApplication::sync()
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
if (QGuiApplicationPrivate::platform_integration
|
||||
&& QGuiApplicationPrivate::platform_integration->hasCapability(QPlatformIntegration::SyncState)) {
|
||||
QGuiApplicationPrivate::platform_integration->sync();
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
}
|
||||
|
||||
void QGuiApplicationPrivate::commitData()
|
||||
{
|
||||
Q_Q(QGuiApplication);
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
bool isSavingSession() const;
|
||||
#endif
|
||||
|
||||
static void sync();
|
||||
Q_SIGNALS:
|
||||
void fontDatabaseChanged();
|
||||
void screenAdded(QScreen *screen);
|
||||
|
@ -435,4 +435,19 @@ QPlatformSessionManager *QPlatformIntegration::createPlatformSessionManager(cons
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\since 5.2
|
||||
|
||||
Function to sync the platform integrations state with the window system.
|
||||
|
||||
This is often implemented as a roundtrip from the platformintegration to the window system.
|
||||
|
||||
This function should not call QWindowSystemInterface::flushWindowSystemEvents() or
|
||||
QCoreApplication::processEvents()
|
||||
*/
|
||||
void QPlatformIntegration::sync()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -94,7 +94,8 @@ public:
|
||||
ForeignWindows,
|
||||
NonFullScreenWindows,
|
||||
NativeWidgets,
|
||||
WindowManagement
|
||||
WindowManagement,
|
||||
SyncState
|
||||
};
|
||||
|
||||
virtual ~QPlatformIntegration() { }
|
||||
@ -162,6 +163,8 @@ public:
|
||||
#ifndef QT_NO_SESSIONMANAGER
|
||||
virtual QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const;
|
||||
#endif
|
||||
|
||||
virtual void sync();
|
||||
protected:
|
||||
void screenAdded(QPlatformScreen *screen);
|
||||
};
|
||||
|
@ -282,6 +282,7 @@ bool QXcbIntegration::hasCapability(QPlatformIntegration::Capability cap) const
|
||||
case WindowMasks: return true;
|
||||
case MultipleWindows: return true;
|
||||
case ForeignWindows: return true;
|
||||
case SyncState: return true;
|
||||
default: return QPlatformIntegration::hasCapability(cap);
|
||||
}
|
||||
}
|
||||
@ -458,4 +459,11 @@ QPlatformSessionManager *QXcbIntegration::createPlatformSessionManager(const QSt
|
||||
}
|
||||
#endif
|
||||
|
||||
void QXcbIntegration::sync()
|
||||
{
|
||||
for (int i = 0; i < m_connections.size(); i++) {
|
||||
m_connections.at(i)->sync();
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -106,6 +106,7 @@ public:
|
||||
QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE;
|
||||
#endif
|
||||
|
||||
void sync();
|
||||
private:
|
||||
QList<QXcbConnection *> m_connections;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user