diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-22 12:54:35 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-03-29 10:01:41 +0000 |
commit | bff59f87ba11cac1dfa710f021522372de7a776f (patch) | |
tree | 9fa99636bf623d631abd5f9a0fef073c150b7fe0 /src/gui | |
parent | db7c644cd634cce3b309fb63978f466456e0f559 (diff) |
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>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 20 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwindow.cpp | 11 | ||||
-rw-r--r-- | src/gui/kernel/qwindow_p.h | 2 |
4 files changed, 21 insertions, 13 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index a3046a9b44..bc1aeb8217 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -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,12 +743,28 @@ 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. */ QSize QPlatformWindow::windowMinimumSize() const diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index bba6390694..2fe8ad94e6 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -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. diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index da22d237ac..0a41196b5b 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -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. diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index 7ef73eb410..adc9414b0f 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -124,8 +124,6 @@ public: bool applyCursor(); #endif - void deliverUpdateRequest(); - QPoint globalPosition() const; QWindow *topLevelWindow() const; |