Browse Source

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.
v6.0.8
reuk 5 years ago
parent
commit
5bcd2b0dfb
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
1 changed files with 22 additions and 0 deletions
  1. +22
    -0
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 22
- 0
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm 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)
{


Loading…
Cancel
Save