From 8eb7e2aa0ba6d843cc4a4c01a7067a4135103486 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 1 Apr 2014 19:14:15 +0200 Subject: cocoa: disallow the titlebar to exit the visibleFrame on the bottom edge --- video/out/cocoa/window.m | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'video') diff --git a/video/out/cocoa/window.m b/video/out/cocoa/window.m index 515ea5926e..67d140bb6f 100644 --- a/video/out/cocoa/window.m +++ b/video/out/cocoa/window.m @@ -127,17 +127,18 @@ if ([self isInFullScreenMode]) return [super constrainFrameRect:nf toScreen:screen]; - NSRect cf = [self frame]; - NSRect vf = [[self screen] visibleFrame]; + NSRect of = [self frame]; + NSRect vf = [[self screen] visibleFrame]; + NSRect ncf = [self contentRectForFrameRect:nf]; // Prevent the window's titlebar from exiting the screen on the top edge. // This introduces a 'snap to top' behaviour. if (NSMaxY(nf) > NSMaxY(vf)) nf.origin.y = NSMaxY(vf) - NSHeight(nf); - // Prevent window from exiting the screen on the bottom edge - if (NSMaxY(nf) < NSMinY(vf)) - nf.origin.y = NSMinY(vf); + // Prevent the window's titlebar from exiting the screen on the top edge. + if (NSMaxY(ncf) < NSMinY(vf)) + nf.origin.y = NSMinY(vf) + NSMinY(ncf) - NSMaxY(ncf); // Prevent window from exiting the screen on the right edge if (NSMinX(nf) > NSMaxX(vf)) @@ -147,7 +148,7 @@ if (NSMaxX(nf) < NSMinX(vf)) nf.origin.x = NSMinX(vf); - if (NSHeight(nf) < NSHeight(vf) && NSHeight(cf) > NSHeight(vf)) + if (NSHeight(nf) < NSHeight(vf) && NSHeight(of) > NSHeight(vf)) // If the window height is smaller than the visible frame, but it was // bigger previously recenter the smaller window vertically. This is // needed to counter the 'snap to top' behaviour. -- cgit v1.2.3