summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2017-02-13 20:08:43 +0100
committerAkemi <der.richter@gmx.de>2017-02-13 22:49:11 +0100
commit64b0d81c32d90fe29485bdb218fb76608b9aa31b (patch)
treecff0ad349d3d85e8207c5c05b3fcbbe21657fd96
parent34b7d523173a0db0f04fa6904f816e0033662802 (diff)
downloadmpv-64b0d81c32d90fe29485bdb218fb76608b9aa31b.tar.bz2
mpv-64b0d81c32d90fe29485bdb218fb76608b9aa31b.tar.xz
cocoa: add --ontop-level option for modifying ontop window level
since there are different views on what ontop is, we make the ontop window level modifiable. at the moment only support for macOS was added. the default for macOS was changed from 'system' to 'window' since this fixes an unwanted behaviour in fullscreen and in general causes less issues with expected behaviour. Fixes #2376 #3974
-rw-r--r--DOCS/man/options.rst8
-rw-r--r--options/options.c3
-rw-r--r--options/options.h1
-rw-r--r--video/out/cocoa_common.m19
4 files changed, 25 insertions, 6 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index af9a3b913d..6c83c49a0f 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -2130,6 +2130,14 @@ Window
treated as exclusive fullscreen window that bypasses the Desktop Window
Manager.
+``--ontop-level=<window|system|level>``
+ (OS X only)
+ Sets the level of an ontop window (default: window).
+
+ :window: On top of all other windows.
+ :system: On top of system elements like Taskbar, Menubar and Dock.
+ :level: A level as integer.
+
``--border``, ``--no-border``
Play video with window border and decorations. Since this is on by
default, use ``--no-border`` to disable the standard window decorations.
diff --git a/options/options.c b/options/options.c
index 0bb36ad3fc..d33c2e05d1 100644
--- a/options/options.c
+++ b/options/options.c
@@ -160,6 +160,8 @@ static const m_option_t mp_vo_opt_list[] = {
OPT_FLAG("taskbar-progress", taskbar_progress, 0),
OPT_FLAG("snap-window", snap_window, 0),
OPT_FLAG("ontop", ontop, 0),
+ OPT_CHOICE_OR_INT("ontop-level", ontop_level, 0, 0, INT_MAX,
+ ({"window", -1}, {"system", -2})),
OPT_FLAG("border", border, 0),
OPT_FLAG("fit-border", fit_border, 0),
OPT_FLAG("on-all-workspaces", all_workspaces, 0),
@@ -233,6 +235,7 @@ const struct m_sub_options vo_sub_opts = {
.window_scale = 1.0,
.x11_bypass_compositor = 2,
.mmcss_profile = "Playback",
+ .ontop_level = -1,
},
};
diff --git a/options/options.h b/options/options.h
index f465c0f862..926b238b06 100644
--- a/options/options.h
+++ b/options/options.h
@@ -12,6 +12,7 @@ typedef struct mp_vo_opts {
int taskbar_progress;
int snap_window;
int ontop;
+ int ontop_level;
int fullscreen;
int border;
int fit_border;
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index 0420b0dda2..45581ec191 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -474,14 +474,21 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
return kCVReturnSuccess;
}
-static void vo_set_level(struct vo *vo, int ontop)
+static void vo_set_level(struct vo *vo, int ontop, int ontop_level)
{
struct vo_cocoa_state *s = vo->cocoa;
if (ontop) {
- // +1 is not enough as that will show the icon layer on top of the
- // menubar when the application is not frontmost. so use +2
- s->window_level = NSMainMenuWindowLevel + 2;
+ switch (ontop_level) {
+ case -1:
+ s->window_level = NSFloatingWindowLevel;
+ break;
+ case -2:
+ s->window_level = NSStatusWindowLevel;
+ break;
+ default:
+ s->window_level = ontop_level;
+ }
} else {
s->window_level = NSNormalWindowLevel;
}
@@ -499,7 +506,7 @@ static int vo_cocoa_ontop(struct vo *vo)
return VO_NOTIMPL;
struct mp_vo_opts *opts = vo->opts;
- vo_set_level(vo, opts->ontop);
+ vo_set_level(vo, opts->ontop, opts->ontop_level);
return VO_TRUE;
}
@@ -679,7 +686,7 @@ int vo_cocoa_config_window(struct vo *vo)
if (opts->fullscreen && !s->fullscreen)
vo_cocoa_fullscreen(vo);
cocoa_set_window_title(vo);
- vo_set_level(vo, opts->ontop);
+ vo_set_level(vo, opts->ontop, opts->ontop_level);
GLint o;
if (!CGLGetParameter(s->cgl_ctx, kCGLCPSurfaceOpacity, &o) && !o) {