From 77389ad8ff9fd3dc56f5a398fab11a993e7a621c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Sun, 10 Feb 2019 17:39:06 +0100 Subject: [PATCH] macOS: Remove screen-update disable during resize MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was needed as a workaround for the window border and window content becoming out of sync when we were drawing and flushing to the layer from another thread using OpenGL. Since we've disabled ThreadedOpenGL we can remove this workaround for now. The workaround also had other problems, as windowWillResize: did not turn out to be a reliable signal to know when a window was about to resize. Since we override windowWillUseStandardFrame:, we would not get the callback when zooming windows. Conversely, if we removed the windowWillUseStandardFrame: override, we would get a single callback for windowWillResize:, and then multiple callbacks that the window had resized. In addition, windowWillResize: is not only used as a callback, but also as a way to let the window delegate restrict the size, so it's called when e.g. AppKit determines the standard frame of the window -- an operation that doesn't involve an actual resize operation. If we re-introduce a workaround using screen-update disabling we need a better hook than windowWillResize:, and we need to track when we disable screen updates so that we can pair them up with corresponding screen update enables, otherwise we'll get log messages in the console about "SLSReenableUpdate: unbalanced enable/disable update". Change-Id: Ifca8892083c8666976391a4ada8f8d1471493943 Fixes: QTBUG-73726 Task-number: QTBUG-69321 Reviewed-by: Morten Johan Sørvig Reviewed-by: Tor Arne Vestbø --- .../platforms/cocoa/qnswindowdelegate.mm | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 14f1ca0114..087cb3651f 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -102,40 +102,6 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window) return QCocoaScreen::mapToNative(maximizedFrame); } -#pragma clang diagnostic push -// NSDisableScreenUpdates and NSEnableScreenUpdates are deprecated, but the -// NSAnimationContext API that replaces them doesn't handle the use-case of -// cross-thread screen update synchronization. -#pragma clang diagnostic ignored "-Wdeprecated-declarations" -- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)frameSize -{ - Q_ASSERT(toPlatformWindow(window)); - - qCDebug(lcQpaWindow) << window << "will resize to" << QSizeF::fromCGSize(frameSize) - << "- disabling screen updates temporarily"; - - // There may be separate threads rendering to CA layers in this window, - // and if any of them do a swap while the resize is still in progress, - // the visual bounds of that layer will be updated before the visual - // bounds of the window frame, resulting in flickering while resizing. - - // To prevent this we disable screen updates for the whole process until - // the resize is complete, which makes the whole thing visually atomic. - NSDisableScreenUpdates(); - - return frameSize; -} - -- (void)windowDidResize:(NSNotification *)notification -{ - NSWindow *window = notification.object; - Q_ASSERT(toPlatformWindow(window)); - - qCDebug(lcQpaWindow) << window << "was resized - re-enabling screen updates"; - NSEnableScreenUpdates(); -} -#pragma clang diagnostic pop - - (BOOL)window:(NSWindow *)window shouldPopUpDocumentPathMenu:(NSMenu *)menu { Q_UNUSED(menu);