macOS: Invalidate window shadow after flushing backingstore to CALayer

The macOS bug preventing us from doing this has now been fixed:

  http://openradar.appspot.com/radar?id=4976602949615616

Change-Id: I3bfa75d6bf982a051a9b274f530529f4ec4351a0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-07-18 12:29:50 +02:00
parent 99c3ef0789
commit 8c91070606
2 changed files with 88 additions and 93 deletions

View File

@ -132,9 +132,7 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
// The contentsRect is in unit coordinate system
CGAffineTransformMakeScale(1.0 / m_image.width(), 1.0 / m_image.height()));
}
return;
}
} else {
// Normally a NSView is drawn via drawRect, as part of the display cycle in the
// main runloop, via setNeedsDisplay and friends. AppKit will lock focus on each
// individual view, starting with the top level and then traversing any subviews,
@ -224,12 +222,6 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
#endif
}
QCocoaWindow *topLevelCocoaWindow = static_cast<QCocoaWindow *>(topLevelWindow->handle());
if (Q_UNLIKELY(topLevelCocoaWindow->m_needsInvalidateShadow)) {
[topLevelView.window invalidateShadow];
topLevelCocoaWindow->m_needsInvalidateShadow = false;
}
// -------------------------------------------------------------------------
if (shouldHandleViewLockManually)
@ -239,6 +231,15 @@ void QCocoaBackingStore::flush(QWindow *window, const QRegion &region, const QPo
redrawRoundedBottomCorners([view convertRect:region.boundingRect().toCGRect() toView:nil]);
[view.window flushWindow];
}
}
// Done flushing to either CALayer or NSWindow backingstore
QCocoaWindow *topLevelCocoaWindow = static_cast<QCocoaWindow *>(topLevelWindow->handle());
if (Q_UNLIKELY(topLevelCocoaWindow->m_needsInvalidateShadow)) {
[topLevelView.window invalidateShadow];
topLevelCocoaWindow->m_needsInvalidateShadow = false;
}
}
/*

View File

@ -1032,12 +1032,6 @@ void QCocoaWindow::setMask(const QRegion &region)
// time, and so would not result in an updated backingstore.
m_needsInvalidateShadow = true;
[m_view setNeedsDisplay:YES];
// FIXME: [NSWindow invalidateShadow] has no effect when in layer-backed mode,
// so if the mask is changed after the initial mask is applied, it will not
// result in any visual change to the shadow. This is an Apple bug, and there
// may be ways to work around it, such as calling setFrame on the window to
// trigger some internal invalidation, but that needs more research.
}
}