mac/menu: add option to disable default shortcuts

Fixes #14305
This commit is contained in:
der richter 2024-06-22 13:38:32 +02:00
parent 95ac32220e
commit 88db2d0b61
5 changed files with 12 additions and 2 deletions

View File

@ -6479,6 +6479,11 @@ them.
:system: No manual syncing, depend on the layer mechanic and the next drawable :system: No manual syncing, depend on the layer mechanic and the next drawable
:feedback: Same as precise but uses the presentation feedback core mechanism :feedback: Same as precise but uses the presentation feedback core mechanism
``--macos-menu-shortcuts=<yes|no>``
Enables the default menu bar shortcuts (default: yes). The menu bar shortcuts always take
precedence over any other shortcuts, they are not propagated to the mpv core and they can't be
used in config files like ``input.conf`` or script bindings.
``--android-surface-size=<WxH>`` ``--android-surface-size=<WxH>``
Set dimensions of the rendering surface used by the Android gpu context. 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 Needs to be set by the embedding application if the dimensions change during

View File

@ -62,6 +62,7 @@ struct macos_opts {
int macos_app_activation_policy; int macos_app_activation_policy;
int macos_geometry_calculation; int macos_geometry_calculation;
int macos_render_timer; int macos_render_timer;
bool macos_menu_shortcuts;
int cocoa_cb_sw_renderer; int cocoa_cb_sw_renderer;
bool cocoa_cb_10bit_context; bool cocoa_cb_10bit_context;
int cocoa_cb_output_csp; int cocoa_cb_output_csp;

View File

@ -52,6 +52,7 @@ const struct m_sub_options macos_conf = {
{"macos-render-timer", OPT_CHOICE(macos_render_timer, {"macos-render-timer", OPT_CHOICE(macos_render_timer,
{"callback", RENDER_TIMER_CALLBACK}, {"precise", RENDER_TIMER_PRECISE}, {"callback", RENDER_TIMER_CALLBACK}, {"precise", RENDER_TIMER_PRECISE},
{"system", RENDER_TIMER_SYSTEM}, {"feedback", RENDER_TIMER_PRESENTATION_FEEDBACK})}, {"system", RENDER_TIMER_SYSTEM}, {"feedback", RENDER_TIMER_PRESENTATION_FEEDBACK})},
{"macos-menu-shortcuts", OPT_BOOL(macos_menu_shortcuts)},
{"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer, {"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer,
{"auto", -1}, {"no", 0}, {"yes", 1})}, {"auto", -1}, {"no", 0}, {"yes", 1})},
{"cocoa-cb-10bit-context", OPT_BOOL(cocoa_cb_10bit_context)}, {"cocoa-cb-10bit-context", OPT_BOOL(cocoa_cb_10bit_context)},
@ -78,6 +79,7 @@ const struct m_sub_options macos_conf = {
.macos_title_bar_color = {0, 0, 0, 0}, .macos_title_bar_color = {0, 0, 0, 0},
.macos_fs_animation_duration = -1, .macos_fs_animation_duration = -1,
.macos_render_timer = RENDER_TIMER_CALLBACK, .macos_render_timer = RENDER_TIMER_CALLBACK,
.macos_menu_shortcuts = true,
.cocoa_cb_sw_renderer = -1, .cocoa_cb_sw_renderer = -1,
.cocoa_cb_10bit_context = true, .cocoa_cb_10bit_context = true,
.cocoa_cb_output_csp = MAC_CSP_AUTO, .cocoa_cb_output_csp = MAC_CSP_AUTO,

View File

@ -44,7 +44,6 @@ class AppHub: NSObject {
input = InputHelper() input = InputHelper()
log = LogHelper() log = LogHelper()
super.init() super.init()
if isApplication { menu = MenuBar(self) }
#if HAVE_MACOS_MEDIA_PLAYER #if HAVE_MACOS_MEDIA_PLAYER
remote = RemoteCommandCenter(self) remote = RemoteCommandCenter(self)
#endif #endif
@ -58,6 +57,7 @@ class AppHub: NSObject {
log.log = mp_log_new(nil, mp_client_get_log(mpv), "app") log.log = mp_log_new(nil, mp_client_get_log(mpv), "app")
option = OptionHelper(UnsafeMutablePointer(mpv), mp_client_get_global(mpv)) option = OptionHelper(UnsafeMutablePointer(mpv), mp_client_get_global(mpv))
input.option = option input.option = option
DispatchQueue.main.sync { menu = MenuBar(self) }
} }
#if HAVE_MACOS_MEDIA_PLAYER #if HAVE_MACOS_MEDIA_PLAYER

View File

@ -71,6 +71,7 @@ extension MenuBar {
class MenuBar: NSObject { class MenuBar: NSObject {
unowned let appHub: AppHub unowned let appHub: AppHub
var option: OptionHelper? { return appHub.option }
let mainMenu = NSMenu(title: "Main") let mainMenu = NSMenu(title: "Main")
let servicesMenu = NSMenu(title: "Services") let servicesMenu = NSMenu(title: "Services")
var menuConfigs: [Config] = [] var menuConfigs: [Config] = []
@ -272,7 +273,8 @@ class MenuBar: NSObject {
} }
func createMenuItem(parentMenu: NSMenu, config: Config) -> MenuItem { func createMenuItem(parentMenu: NSMenu, config: Config) -> MenuItem {
var item = MenuItem(title: config.name, action: config.action, keyEquivalent: config.key) var item = MenuItem(title: config.name, action: config.action,
keyEquivalent: (option?.mac.macos_menu_shortcuts ?? true) ? config.key : "")
item.config = config item.config = config
item.target = config.target item.target = config.target
item.keyEquivalentModifierMask = config.modifiers item.keyEquivalentModifierMask = config.modifiers