diff options
author | der richter <der.richter@gmx.de> | 2020-12-13 17:13:18 +0100 |
---|---|---|
committer | Jan Ekström <jeebjp@gmail.com> | 2020-12-19 21:37:55 +0200 |
commit | af264029483656e04458a678849165f0340433ab (patch) | |
tree | d09a264ac37f67089b7baeb6003efeaed985119a /video/out | |
parent | 93d071dbd8fb8b9561e1830754c40f3de87cf3ca (diff) | |
download | mpv-af264029483656e04458a678849165f0340433ab.tar.bz2 mpv-af264029483656e04458a678849165f0340433ab.tar.xz |
mac: use visible frame rectangle for window geometry calculation
currently we use the whole screen rectangle to calculate the window
geometry. this doesn't take the menu bar or the Dock into account.
by default use the visible screen rectangle instead. this is also a
change in behaviour, since the window can't be placed outside of this
rectangle anymore. also add an option to change to the old behaviour,
because it can still be useful in certain cases, like placing the window
directly underneath the menu bar when used a desktop background.
Fixes #8272
Diffstat (limited to 'video/out')
-rw-r--r-- | video/out/mac/common.swift | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/video/out/mac/common.swift b/video/out/mac/common.swift index e3f1405c02..e27d17d621 100644 --- a/video/out/mac/common.swift +++ b/video/out/mac/common.swift @@ -440,21 +440,27 @@ class Common: NSObject { func getWindowGeometry(forScreen targetScreen: NSScreen, videoOut vo: UnsafeMutablePointer<vo>) -> NSRect { let r = targetScreen.convertRectToBacking(targetScreen.frame) - var screenRC: mp_rect = mp_rect(x0: Int32(0), - y0: Int32(0), - x1: Int32(r.size.width), - y1: Int32(r.size.height)) - + let targetFrame = + (mpv?.macOpts.macos_geometry_calculation ?? FRAME_VISIBLE) == FRAME_VISIBLE ? + targetScreen.visibleFrame : targetScreen.frame + let rv = targetScreen.convertRectToBacking(targetFrame) + + // flip the y origin, mp_rect expects the origin at the top-left + // macOS' windowing system operates from the bottom-left + var originY = r.size.height - rv.origin.y - rv.size.height + var screenRC: mp_rect = mp_rect(x0: Int32(rv.origin.x), + y0: Int32(originY), + x1: Int32(rv.origin.x + rv.size.width), + y1: Int32(originY + rv.size.height)) var geo: vo_win_geometry = vo_win_geometry() vo_calc_window_geometry2(vo, &screenRC, Double(targetScreen.backingScaleFactor), &geo) + vo_apply_window_geometry(vo, &geo) - // flip y coordinates - geo.win.y1 = Int32(r.size.height) - geo.win.y1 - geo.win.y0 = Int32(r.size.height) - geo.win.y0 - - let wr = NSMakeRect(CGFloat(geo.win.x0), CGFloat(geo.win.y1), - CGFloat(geo.win.x1 - geo.win.x0), - CGFloat(geo.win.y0 - geo.win.y1)) + // flip the y origin again + let height = CGFloat(geo.win.y1 - geo.win.y0) + originY = r.size.height - CGFloat(geo.win.y0) - height + let wr = NSMakeRect(CGFloat(geo.win.x0), originY, + CGFloat(geo.win.x1 - geo.win.x0), height) return targetScreen.convertRectFromBacking(wr) } |