summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-12 15:28:12 +0100
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2015-02-16 15:56:29 +0000
commiteffc6b4cd15aefa1bef30c27f0458390735fafb5 (patch)
treed77f1e07cf62e80f53e43bdeb117c0b4efa9843b /src
parent1748b7e7d2f619dc32df7ccbd3aa24316aa63c82 (diff)
Add widget support for requestUpdate() and improve its docs and tests
We must do something when requestUpdate() is called on a QWidgetWindow. The semantics of UpdateRequest for QWindow and QWidget are unfortunately different: for widgets an UpdateRequest means "sync the backing store". For QWindow it also involves marking as dirty. Change-Id: Idf40b3fc0873652dc081edeb12c96b3007a126ef Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com> Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qwindow.cpp13
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp12
2 files changed, 20 insertions, 5 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 1fbb67fb8a..4a88988322 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2078,11 +2078,16 @@ void QWindowPrivate::deliverUpdateRequest()
Calling this function multiple times will result in a single event
being delivered to the window.
- Subclasses of QWindow should reimplement QWindow::event(), intercept
- the event and call the application's rendering code, then call the
- base class implementation.
-*/
+ Subclasses of QWindow should reimplement event(), intercept the event and
+ call the application's rendering code, then call the base class
+ implementation.
+ \note The subclass' reimplementation of event() must invoke the base class
+ implementation, unless it is absolutely sure that the event does not need to
+ be handled by the base class. For example, the default implementation of
+ this function relies on QEvent::Timer events. Filtering them away would
+ therefore break the delivery of the update events.
+*/
void QWindow::requestUpdate()
{
Q_D(QWindow);
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index 11dfe8a6d5..6c7dc070d5 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -292,11 +292,21 @@ bool QWidgetWindow::event(QEvent *event)
case QEvent::WindowBlocked:
qt_button_down = 0;
break;
+
+ case QEvent::UpdateRequest:
+ // This is not the same as an UpdateRequest for a QWidget. That just
+ // syncs the backing store while here we also must mark as dirty.
+ m_widget->repaint();
+ return true;
+
default:
break;
}
- return m_widget->event(event) || QWindow::event(event);
+ if (m_widget->event(event) && event->type() != QEvent::Timer)
+ return true;
+
+ return QWindow::event(event);
}
QPointer<QWidget> qt_last_mouse_receiver = 0;