Move delivery of update requests into QPlatformWindow

Having deliverUpdateRequest in QWindowPrivate was a bit awkward and
asymmetric to the QPlatformWindow::requestUpdate() API. Keeping
them together follows the existing pattern of plumbing things
through the platform window, and also allows us to move away
from platform plugins relying on QWindowPrivate implementation
details.

Change-Id: Ib131ccdd1c2bdd6ff1c8d95facbc3f6f88a1abcf
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-03-22 12:54:35 +01:00
parent db7c644cd6
commit bff59f87ba
6 changed files with 30 additions and 17 deletions

View File

@ -724,7 +724,7 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w,
QPlatformWindow subclasses can re-implement this function to
provide display refresh synchronized updates. The event
should be delivered using QWindowPrivate::deliverUpdateRequest()
should be delivered using QPlatformWindow::deliverUpdateRequest()
to not get out of sync with the the internal state of QWindow.
The default implementation posts an UpdateRequest event to the
@ -743,11 +743,27 @@ void QPlatformWindow::requestUpdate()
}
QWindow *w = window();
QWindowPrivate *wp = (QWindowPrivate *) QObjectPrivate::get(w);
QWindowPrivate *wp = qt_window_private(w);
Q_ASSERT(wp->updateTimer == 0);
wp->updateTimer = w->startTimer(timeout, Qt::PreciseTimer);
}
/*!
Delivers an QEvent::UpdateRequest event to the window.
QPlatformWindow subclasses can re-implement this function to
provide e.g. logging or tracing of the delivery, but should
always call the base class function.
*/
void QPlatformWindow::deliverUpdateRequest()
{
QWindow *w = window();
QWindowPrivate *wp = qt_window_private(w);
wp->updateRequestPending = false;
QEvent request(QEvent::UpdateRequest);
QCoreApplication::sendEvent(w, &request);
}
/*!
Returns the QWindow minimum size.
*/

View File

@ -144,6 +144,7 @@ public:
const QRect &initialGeometry, int defaultWidth, int defaultHeight);
virtual void requestUpdate();
virtual void deliverUpdateRequest();
// Window property accessors. Platform plugins should use these
// instead of accessing QWindow directly.

View File

@ -2333,7 +2333,8 @@ bool QWindow::event(QEvent *ev)
if (static_cast<QTimerEvent *>(ev)->timerId() == d->updateTimer) {
killTimer(d->updateTimer);
d->updateTimer = 0;
d->deliverUpdateRequest();
if (d->platformWindow)
d->platformWindow->deliverUpdateRequest();
} else {
QObject::event(ev);
}
@ -2357,14 +2358,6 @@ bool QWindow::event(QEvent *ev)
return true;
}
void QWindowPrivate::deliverUpdateRequest()
{
Q_Q(QWindow);
updateRequestPending = false;
QEvent request(QEvent::UpdateRequest);
QCoreApplication::sendEvent(q, &request);
}
/*!
Schedules a QEvent::UpdateRequest event to be delivered to this window.

View File

@ -124,8 +124,6 @@ public:
bool applyCursor();
#endif
void deliverUpdateRequest();
QPoint globalPosition() const;
QWindow *topLevelWindow() const;

View File

@ -120,7 +120,7 @@
if (m_updateRequested) {
Q_ASSERT(windowPrivate->updateRequestPending);
qCDebug(lcQpaWindow) << "Delivering update request to" << m_platformWindow->window();
windowPrivate->deliverUpdateRequest();
m_platformWindow->deliverUpdateRequest();
m_updateRequested = false;
} else {
m_platformWindow->handleExposeEvent(dirtyRegion);

View File

@ -390,14 +390,19 @@ void QIOSScreen::deliverUpdateRequests() const
QList<QWindow*> windows = QGuiApplication::allWindows();
for (int i = 0; i < windows.size(); ++i) {
if (platformScreenForWindow(windows.at(i)) != this)
QWindow *window = windows.at(i);
if (platformScreenForWindow(window) != this)
continue;
QWindowPrivate *wp = static_cast<QWindowPrivate *>(QObjectPrivate::get(windows.at(i)));
QWindowPrivate *wp = qt_window_private(window);
if (!wp->updateRequestPending)
continue;
wp->deliverUpdateRequest();
QPlatformWindow *platformWindow = window->handle();
if (!platformWindow)
continue;
platformWindow->deliverUpdateRequest();
// Another update request was triggered, keep the display link running
if (wp->updateRequestPending)