Browse Source

macOS: Fixed a bug when de-minimising an always on top NSView

tags/2021-05-28
ed 7 years ago
parent
commit
fda5aaafd1
1 changed files with 39 additions and 1 deletions
  1. +39
    -1
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 39
- 1
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -158,7 +158,12 @@ public:
object: window];
[notificationCenter addObserver: view
selector: @selector (frameChanged:)
selector: @selector (windowWillMiniaturize:)
name: NSWindowWillMiniaturizeNotification
object: window];
[notificationCenter addObserver: view
selector: @selector (windowDidDeminiaturize:)
name: NSWindowDidDeminiaturizeNotification
object: window];
}
@@ -472,10 +477,14 @@ public:
bool setAlwaysOnTop (bool alwaysOnTop) override
{
if (! isSharedWindow)
{
[window setLevel: alwaysOnTop ? ((getStyleFlags() & windowIsTemporary) != 0 ? NSPopUpMenuWindowLevel
: NSFloatingWindowLevel)
: NSNormalWindowLevel];
isAlwaysOnTop = alwaysOnTop;
}
return true;
}
@@ -1394,6 +1403,7 @@ public:
bool isZooming = false, isFirstLiveResize = false, textWasInserted = false;
bool isStretchingTop = false, isStretchingLeft = false, isStretchingBottom = false, isStretchingRight = false;
bool windowRepresentsFile = false;
bool isAlwaysOnTop = false, wasAlwaysOnTop = false;
String stringBeingComposed;
NSNotificationCenter* notificationCenter = nil;
@@ -1563,6 +1573,8 @@ struct JuceNSViewClass : public ObjCClass<NSView>
addMethod (@selector (magnifyWithEvent:), magnify, "v@:@");
addMethod (@selector (acceptsFirstMouse:), acceptsFirstMouse, "c@:@");
addMethod (@selector (frameChanged:), frameChanged, "v@:@");
addMethod (@selector (windowWillMiniaturize:), windowWillMiniaturize, "v@:@");
addMethod (@selector (windowDidDeminiaturize:), windowDidDeminiaturize, "v@:@");
addMethod (@selector (wantsDefaultClipping:), wantsDefaultClipping, "c@:");
addMethod (@selector (worksWhenModal), worksWhenModal, "c@:");
addMethod (@selector (viewDidMoveToWindow), viewDidMoveToWindow, "v@:");
@@ -1658,6 +1670,32 @@ 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 windowWillMiniaturize (id self, SEL, NSNotification*)
{
if (auto* p = getOwner (self))
{
if (p->isAlwaysOnTop)
{
// there is a bug when restoring minimised always on top windows so we need
// to remove this behaviour before minimising and restore it afterwards
p->setAlwaysOnTop (false);
p->wasAlwaysOnTop = true;
}
}
}
static void windowDidDeminiaturize (id self, SEL, NSNotification*)
{
if (auto* p = getOwner (self))
{
if (p->wasAlwaysOnTop)
{
p->setAlwaysOnTop (true);
p->redirectMovedOrResized();
}
}
}
static BOOL isOpaque (id self, SEL)
{
auto* owner = getOwner (self);


Loading…
Cancel
Save