From 03047a0169495c3323ecbaf1c7ea8029c082dc2e Mon Sep 17 00:00:00 2001 From: der richter Date: Tue, 15 Sep 2020 16:44:12 +0200 Subject: mac: add an option to change the App activation policy useful to hide the app icon in the Dock if necessary. --- DOCS/man/options.rst | 7 +++++++ osdep/macosx_application.h | 1 + osdep/macosx_application.m | 2 ++ video/out/mac/common.swift | 19 ++++++++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 75a7871c4a..b75e55e48d 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -5858,6 +5858,13 @@ The following video options are currently all specific to ``--vo=gpu`` and set anyway. OS X and cocoa-cb only + +``--macos-app-activation-policy=`` + Changes the App activation policy. With accessory the mpv icon in the Dock + can be hidden. (default: regular) + + macOS only. + ``--android-surface-size=`` 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 19babc5458..9a366d81fb 100644 --- a/osdep/macosx_application.h +++ b/osdep/macosx_application.h @@ -28,6 +28,7 @@ struct macos_opts { struct m_color macos_title_bar_color; int macos_fs_animation_duration; int macos_force_dedicated_gpu; + int macos_app_activation_policy; int cocoa_cb_sw_renderer; int cocoa_cb_10bit_context; }; diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m index 225d6c59fa..95c6a3f953 100644 --- a/osdep/macosx_application.m +++ b/osdep/macosx_application.m @@ -63,6 +63,8 @@ const struct m_sub_options macos_conf = { OPT_CHOICE(macos_fs_animation_duration, {"default", -1}), M_RANGE(0, 1000)}, {"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})}, {"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 4b5e1265c0..fb52b80610 100644 --- a/video/out/mac/common.swift +++ b/video/out/mac/common.swift @@ -61,7 +61,24 @@ class Common: NSObject { } func initApp() { - NSApp.setActivationPolicy(.regular) + guard let mpv = mpv else { + log.sendError("Something went wrong, no MPVHelper was initialized") + exit(1) + } + + var policy: NSApplication.ActivationPolicy = .regular + switch mpv.macOpts.macos_app_activation_policy { + case 0: + policy = .regular + case 1: + policy = .accessory + case 2: + policy = .prohibited + default: + break + } + + NSApp.setActivationPolicy(policy) setAppIcon() } -- cgit v1.2.3