diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 807cdb02b7..2ca227874d 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -1646,6 +1646,7 @@ struct JuceNSViewClass : public ObjCClass 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 (self, @selector (viewWillDraw)); + } + static void windowWillMiniaturize (id self, SEL, NSNotification*) { if (auto* p = getOwner (self))