1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-16 00:34:19 +00:00

NSViewComponentPeer: Force repaint when window becomes key

This resolves an issue on macOS Catalina when using
JUCE_COREGRAPHICS_DRAW_ASYNC where windows would sometimes fail to
completely repaint when they were unminimized.
This commit is contained in:
reuk 2021-03-16 13:24:19 +00:00
parent 3fe0b07a82
commit 5bcd2b0dfb
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -726,6 +726,12 @@ public:
[notificationCenter removeObserver: view
name: NSWindowWillMiniaturizeNotification
object: currentWindow];
#if JUCE_COREGRAPHICS_DRAW_ASYNC
[notificationCenter removeObserver: view
name: NSWindowDidBecomeKeyNotification
object: currentWindow];
#endif
}
if (isSharedWindow && [view window] == window && newWindow == nullptr)
@ -1112,6 +1118,13 @@ public:
selector: dismissModalsSelector
name: NSWindowWillMiniaturizeNotification
object: currentWindow];
#if JUCE_COREGRAPHICS_DRAW_ASYNC
[notificationCenter addObserver: view
selector: becomeKeySelector
name: NSWindowDidBecomeKeyNotification
object: currentWindow];
#endif
}
}
@ -1121,6 +1134,11 @@ public:
sendModalInputAttemptIfBlocked();
}
void becomeKey()
{
component.repaint();
}
void liveResizingStart()
{
if (constrainer == nullptr)
@ -1488,6 +1506,7 @@ public:
static const SEL frameChangedSelector;
static const SEL asyncMouseDownSelector;
static const SEL asyncMouseUpSelector;
static const SEL becomeKeySelector;
private:
static NSView* createViewInstance();
@ -1657,6 +1676,7 @@ const SEL NSViewComponentPeer::dismissModalsSelector = @selector (dismissModals
const SEL NSViewComponentPeer::frameChangedSelector = @selector (frameChanged:);
const SEL NSViewComponentPeer::asyncMouseDownSelector = @selector (asyncMouseDown:);
const SEL NSViewComponentPeer::asyncMouseUpSelector = @selector (asyncMouseUp:);
const SEL NSViewComponentPeer::becomeKeySelector = @selector (becomeKey:);
JUCE_END_IGNORE_WARNINGS_GCC_LIKE
//==============================================================================
@ -1727,6 +1747,7 @@ struct JuceNSViewClass : public ObjCClass<NSView>
addMethod (NSViewComponentPeer::asyncMouseDownSelector, asyncMouseDown, "v@:@");
addMethod (NSViewComponentPeer::asyncMouseUpSelector, asyncMouseUp, "v@:@");
addMethod (NSViewComponentPeer::frameChangedSelector, frameChanged, "v@:@");
addMethod (NSViewComponentPeer::becomeKeySelector, becomeKey, "v@:@");
addProtocol (@protocol (NSTextInput));
@ -1795,6 +1816,7 @@ 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 dismissModals (id self, SEL) { if (auto* p = getOwner (self)) p->dismissModals(); }
static void becomeKey (id self, SEL) { if (auto* p = getOwner (self)) p->becomeKey(); }
static void viewWillDraw (id self, SEL)
{