Skip to content
Permalink
Browse files

macOS: Added a workaround for non-resizable windows increasing in hei…

…ght by the title-bar height when entering fullscreen
  • Loading branch information...
ed95 committed May 14, 2019
1 parent abe9787 commit 387847efd6f90cbaf6ab118b85c7d5638983d9ad
Showing with 23 additions and 9 deletions.
  1. +23 −9 modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm
@@ -1362,6 +1362,17 @@ void grabFocus() override

void textInputRequired (Point<int>, TextInputTarget&) override {}

void resetWindowPresentation()
{
if (hasNativeTitleBar())
{
[window setStyleMask: (NSViewComponentPeer::getNSWindowStyleMask (getStyleFlags()))];
setTitle (getComponent().getName()); // required to force the OS to update the title
}

[NSApp setPresentationOptions: NSApplicationPresentationDefault];
}

//==============================================================================
NSWindow* window = nil;
NSView* view = nil;
@@ -1911,6 +1922,7 @@ static void concludeDragOperation (id, SEL, id<NSDraggingInfo>) {}
addMethod (@selector (constrainFrameRect:toScreen:), constrainFrameRect, @encode (NSRect), "@:", @encode (NSRect), "@");
addMethod (@selector (windowWillResize:toSize:), windowWillResize, @encode (NSSize), "@:@", @encode (NSSize));
addMethod (@selector (windowDidExitFullScreen:), windowDidExitFullScreen, "v@:@");
addMethod (@selector (windowWillEnterFullScreen:), windowWillEnterFullScreen, "v@:@");
addMethod (@selector (zoom:), zoom, "v@:@");
addMethod (@selector (windowWillMove:), windowWillMove, "v@:@");
addMethod (@selector (windowWillStartLiveResize:), windowWillStartLiveResize, "v@:@");
@@ -1991,9 +2003,17 @@ static NSSize windowWillResize (id self, SEL, NSWindow*, NSSize proposedFrameSiz
return frameRect.size;
}

static void windowDidExitFullScreen (id, SEL, NSNotification*)
static void windowDidExitFullScreen (id self, SEL, NSNotification*)
{
[NSApp setPresentationOptions: NSApplicationPresentationDefault];
if (auto* owner = getOwner (self))
owner->resetWindowPresentation();
}

static void windowWillEnterFullScreen (id self, SEL, NSNotification*)
{
if (auto* owner = getOwner (self))
if (owner->hasNativeTitleBar() && (owner->getStyleFlags() & ComponentPeer::windowIsResizable) == 0)
[owner->window setStyleMask: NSWindowStyleMaskBorderless];
}

static void zoom (id self, SEL, id sender)
@@ -2126,13 +2146,7 @@ static bool shouldAllowIconDrag (id self, SEL, id /*window*/, NSEvent*, NSPoint,
}
else
{
if (peer->hasNativeTitleBar())
{
[peer->window setStyleMask: (NSViewComponentPeer::getNSWindowStyleMask (peer->getStyleFlags()))];
peer->setTitle (peer->getComponent().getName()); // required to force the OS to update the title
}

[NSApp setPresentationOptions: NSApplicationPresentationDefault];
peer->resetWindowPresentation();
}
}
}

0 comments on commit 387847e

Please sign in to comment.
You can’t perform that action at this time.