1
mirror of https://github.com/mpv-player/mpv synced 2024-11-03 03:19:24 +01:00

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
This commit is contained in:
Akemi 2017-02-13 20:08:43 +01:00
parent 34b7d52317
commit 64b0d81c32
4 changed files with 25 additions and 6 deletions

View File

@ -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.

View File

@ -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,
},
};

View File

@ -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;

View File

@ -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) {