summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2020-12-13 17:13:18 +0100
committerJan Ekström <jeebjp@gmail.com>2020-12-19 21:37:55 +0200
commitaf264029483656e04458a678849165f0340433ab (patch)
treed09a264ac37f67089b7baeb6003efeaed985119a
parent93d071dbd8fb8b9561e1830754c40f3de87cf3ca (diff)
downloadmpv-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
-rw-r--r--DOCS/interface-changes.rst7
-rw-r--r--DOCS/man/options.rst10
-rw-r--r--osdep/macosx_application.h6
-rw-r--r--osdep/macosx_application.m2
-rw-r--r--video/out/mac/common.swift30
5 files changed, 42 insertions, 13 deletions
diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst
index 60109b5aae..1f5fda5b02 100644
--- a/DOCS/interface-changes.rst
+++ b/DOCS/interface-changes.rst
@@ -27,8 +27,13 @@ Interface changes
::
--- mpv 0.34.0 ---
- - add `--screen-name` and `--fs-screen-name` flags to allow selecting the
+ - add `--screen-name` and `--fs-screen-name` flags to allow selecting the
screen by its name instead of the index
+ - add `--macos-geometry-calculation` to change the rectangle used for screen
+ position and size calculation. the old behavior used the whole screen,
+ which didn't take the menu bar and Dock into account. The new default
+ behaviour includes both. To revert to the old behavior set this to
+ `whole`.
--- mpv 0.33.0 ---
- add `--d3d11-exclusive-fs` flag to enable D3D11 exclusive fullscreen mode
when the player enters fullscreen.
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index db3a8db500..c92353a2a6 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -5914,6 +5914,16 @@ The following video options are currently all specific to ``--vo=gpu`` and
macOS only.
+``--macos-geometry-calculation=<visible|whole>``
+ This changes the rectangle which is used to calculate the screen position
+ and size of the window (default: visible). ``visible`` takes the the menu
+ bar and Dock into account and the window is only positioned/sized within the
+ visible screen frame rectangle, ``whole`` takes the whole screen frame
+ rectangle and ignores the menu bar and Dock. Other previous restrictions
+ still apply, like the window can't be placed on top of the menu bar etc.
+
+ macOS only.
+
``--android-surface-size=<WxH>``
Set dimensions of the rendering surface used by the Android gpu context.
Needs to be set by the embedding application if the dimensions change during
diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h
index 9a366d81fb..05d0b07c07 100644
--- a/osdep/macosx_application.h
+++ b/osdep/macosx_application.h
@@ -21,6 +21,11 @@
#include "osdep/macosx_menubar.h"
#include "options/m_option.h"
+enum {
+ FRAME_VISIBLE = 0,
+ FRAME_WHOLE,
+};
+
struct macos_opts {
int macos_title_bar_style;
int macos_title_bar_appearance;
@@ -29,6 +34,7 @@ struct macos_opts {
int macos_fs_animation_duration;
int macos_force_dedicated_gpu;
int macos_app_activation_policy;
+ int macos_geometry_calculation;
int cocoa_cb_sw_renderer;
int cocoa_cb_10bit_context;
};
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index 95c6a3f953..bb8b67b575 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -65,6 +65,8 @@ const struct m_sub_options macos_conf = {
{"macos-force-dedicated-gpu", OPT_FLAG(macos_force_dedicated_gpu)},
{"macos-app-activation-policy", OPT_CHOICE(macos_app_activation_policy,
{"regular", 0}, {"accessory", 1}, {"prohibited", 2})},
+ {"macos-geometry-calculation", OPT_CHOICE(macos_geometry_calculation,
+ {"visible", FRAME_VISIBLE}, {"whole", FRAME_WHOLE})},
{"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer,
{"auto", -1}, {"no", 0}, {"yes", 1})},
{"cocoa-cb-10bit-context", OPT_FLAG(cocoa_cb_10bit_context)},
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)
}