1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

macOS: Set CALayer format to fix Big Sur invalidation region

This commit is contained in:
Tom Poole 2021-01-13 09:54:47 +00:00
parent 99112cf71f
commit 8fc1195c35

View file

@ -1646,6 +1646,7 @@ struct JuceNSViewClass : public ObjCClass<NSView>
addMethod (@selector (wantsDefaultClipping), wantsDefaultClipping, "c@:");
addMethod (@selector (worksWhenModal), worksWhenModal, "c@:");
addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:");
addMethod (@selector (viewWillDraw), viewWillDraw, "v@:");
addMethod (@selector (keyDown:), keyDown, "v@:@");
addMethod (@selector (keyUp:), keyUp, "v@:@");
addMethod (@selector (insertText:), insertText, "v@:@");
@ -1758,6 +1759,18 @@ private:
static void frameChanged (id self, SEL, NSNotification*) { if (auto* p = getOwner (self)) p->redirectMovedOrResized(); }
static void viewDidMoveToWindow (id self, SEL) { if (auto* p = getOwner (self)) p->viewMovedToWindow(); }
static void viewWillDraw (id self, SEL)
{
// Without setting contentsFormat macOS Big Sur will always set the invalid area
// to be the entire frame.
#if defined (MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
CALayer* layer = ((NSView*) self).layer;
layer.contentsFormat = kCAContentsFormatRGBA8Uint;
#endif
sendSuperclassMessage<void> (self, @selector (viewWillDraw));
}
static void windowWillMiniaturize (id self, SEL, NSNotification*)
{
if (auto* p = getOwner (self))