From b5f972361aa01f55511712016fb2f4f540cdbc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 24 Aug 2020 18:59:54 +0200 Subject: Introduce QWindow::paintEvent with QPA plumbing The explicit paint event on QtGui and QPA level allows us to untangle the expose event, which today has at least 3 different meanings. It also allows us to follow the platform more closely in its semantics of when painting can happen. On some platforms a paint can come in before a window is exposed, e.g. to prepare the first frame. On others a paint can come in after a window has been de-exposed, to save a snapshot of the window for use in an application switcher or similar. The expose keeps its semantics of being a barrier signaling that the application can now render at will, for example in a threaded render loop. There are two compatibility code paths in this patch: 1. For platform plugins that do not yet report the PaintEvents capability, QtGui will synthesize paint events on the platform's behalf, based on the existing expose events coming from the platform. 2. For applications that do not yet implement paintEvent, QtGui will send expose events instead, ensuring the same behavior as before. For now none of the platform plugins deliver paint events natively, so the first compatibility code path is always active. Task-numnber: QTBUG-82676 Change-Id: I0fbe0d4cf451d6a1f07f5eab8d376a6c8a53ce8c Reviewed-by: Paul Olav Tvete --- src/gui/kernel/qevent.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/gui/kernel/qevent.cpp') diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index a54d0d2d14..1a6a43a4cb 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -1510,12 +1510,16 @@ QMoveEvent::~QMoveEvent() \ingroup events - Expose events are sent to windows when an area of the window is invalidated, - for example when window exposure in the windowing system changes. + Expose events are sent to windows when they move between the un-exposed and + exposed states. - A Window with a client area that is completely covered by another window, or - is otherwise not visible may be considered obscured by Qt and may in such - cases not receive expose events. + An exposed window is potentially visible to the user. If the window is moved + off screen, is made totally obscured by another window, is minimized, or + similar, an expose event is sent to the window, and isExposed() might + change to false. + + Expose events should not be used to paint. Handle QPaintEvent + instead. The event handler QWindow::exposeEvent() receives expose events. */ @@ -3834,7 +3838,10 @@ QDebug operator<<(QDebug dbg, const QEvent *e) const QEvent::Type type = e->type(); switch (type) { case QEvent::Expose: +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED dbg << "QExposeEvent(" << static_cast(e)->region() << ')'; +QT_WARNING_POP break; case QEvent::Paint: dbg << "QPaintEvent(" << static_cast(e)->region() << ')'; -- cgit v1.2.3