From 113de68543b7d9ea5acf00ea34bf26c92cd0ac56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 11 Sep 2017 13:45:32 +0200 Subject: macOS: Don't send expose event as update request when becoming visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QGuiApplicationPrivate::processExposeEvent updates the QWindow's exposed state, so we need to call QWindowSystemInterface::handleExposeEvent() when going from non-exposed to exposed. Change-Id: I461b2fb27cd8fd4bdb250d05d47f9af6cb3eb15c Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 63ee8c10ac..1ef02f5274 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1079,6 +1079,8 @@ void QCocoaWindow::handleGeometryChange() void QCocoaWindow::handleExposeEvent(const QRegion ®ion) { + const bool wasExposed = isExposed(); + // Ideally we'd implement isExposed() in terms of these properties, // plus the occlusionState of the NSWindow, and let the expose event // pull the exposed state out when needed. However, when the window @@ -1096,13 +1098,21 @@ void QCocoaWindow::handleExposeEvent(const QRegion ®ion) && !region.isEmpty() && !m_view.hiddenOrHasHiddenAncestor; - QWindowPrivate *windowPrivate = qt_window_private(window()); - if (m_isExposed && windowPrivate->updateRequestPending) { - // FIXME: Should this logic for expose events be in QGuiApplication? - qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "as update request"; - windowPrivate->deliverUpdateRequest(); - return; + if (windowPrivate->updateRequestPending) { + // We can only deliver update request events when the window is exposed, + // and we also have to make sure we deliver the first expose event after + // becoming exposed as a real expose event, otherwise the exposed state + // of the QWindow is never updated. + // FIXME: Should this logic live in QGuiApplication? + if (wasExposed && m_isExposed) { + qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "as update request"; + windowPrivate->deliverUpdateRequest(); + return; + } + + // FIXME: Should we re-trigger setNeedsDisplay in case of !wasExposed && m_isExposed? + // Or possibly send the expose event first, and then the update request? } qCDebug(lcQpaCocoaWindow) << "QCocoaWindow::handleExposeEvent" << window() << region << "isExposed" << isExposed(); -- cgit v1.2.3