summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa/window.m
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2014-04-01 19:14:15 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2014-04-28 21:32:59 +0200
commit8eb7e2aa0ba6d843cc4a4c01a7067a4135103486 (patch)
tree01617c644d26e07180862371122248be2feeb6f8 /video/out/cocoa/window.m
parent2c08ab1c6a68943ee1ae3ff1b641e11544091ced (diff)
downloadmpv-8eb7e2aa0ba6d843cc4a4c01a7067a4135103486.tar.bz2
mpv-8eb7e2aa0ba6d843cc4a4c01a7067a4135103486.tar.xz
cocoa: disallow the titlebar to exit the visibleFrame on the bottom edge
Diffstat (limited to 'video/out/cocoa/window.m')
-rw-r--r--video/out/cocoa/window.m13
1 files changed, 7 insertions, 6 deletions
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.