From 54c3ab7a1018ee2e5c1767d233e1c1d9e42425c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 4 Sep 2017 20:36:01 +0200 Subject: [PATCH] macOS: Fix support for issuing requestUpdate during expose event AppKit will clear the needsDisplay state of a view when finishing the display cycle, so if the client requested an update when delivering the expose event, the update request would not be delivered unless the view was otherwise exposed in some way at a later point. Task-number: QTBUG-62964 Task-number: QTBUG-62963 Change-Id: I5ac9bf2f19af775294d093c8b7a414af22efee92 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/cocoa/qnsview.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f75ee59142..16207d8de8 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -53,6 +53,7 @@ #include #include #include +#include #include "qcocoabackingstore.h" #ifndef QT_NO_OPENGL #include "qcocoaglcontext.h" @@ -332,6 +333,17 @@ static QTouchDevice *touchDevice = 0; #endif m_platformWindow->handleExposeEvent(exposedRegion); + + // A call to QWindow::requestUpdate was issued during the expose event, but + // AppKit will reset the needsDisplay state of the view after completing the + // current display cycle, so we need to defer the request to redisplay. + // FIXME: Perhaps this should be a trigger to enable CADisplayLink? + if (qt_window_private(m_platformWindow->window())->updateRequestPending) { + qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:] deferring setNeedsDisplay"; + dispatch_async(dispatch_get_main_queue (), ^{ + [self setNeedsDisplay:YES]; + }); + } } - (BOOL)wantsUpdateLayer