2010-01-30 13:22:24 +00:00
|
|
|
/*
|
2013-06-02 15:39:05 +00:00
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
2017-06-24 14:08:17 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2010-01-30 13:22:24 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 13:22:24 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-06-24 14:08:17 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2010-01-30 13:22:24 +00:00
|
|
|
*
|
2017-06-24 14:08:17 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 13:22:24 +00:00
|
|
|
*/
|
|
|
|
|
2024-03-23 19:09:15 +00:00
|
|
|
#include "config.h"
|
2010-01-30 13:22:24 +00:00
|
|
|
|
2024-03-25 23:06:42 +00:00
|
|
|
#import "osdep/mac/app_bridge_objc.h"
|
|
|
|
|
2024-03-23 19:09:15 +00:00
|
|
|
#if HAVE_SWIFT
|
|
|
|
#include "osdep/mac/swift.h"
|
|
|
|
#endif
|
2014-04-16 02:33:58 +00:00
|
|
|
|
2024-03-26 18:52:37 +00:00
|
|
|
#define OPT_BASE_STRUCT struct macos_opts
|
|
|
|
const struct m_sub_options macos_conf = {
|
|
|
|
.opts = (const struct m_option[]) {
|
|
|
|
{"macos-title-bar-appearance", OPT_CHOICE(macos_title_bar_appearance,
|
|
|
|
{"auto", 0}, {"aqua", 1}, {"darkAqua", 2},
|
|
|
|
{"vibrantLight", 3}, {"vibrantDark", 4},
|
|
|
|
{"aquaHighContrast", 5}, {"darkAquaHighContrast", 6},
|
|
|
|
{"vibrantLightHighContrast", 7},
|
|
|
|
{"vibrantDarkHighContrast", 8})},
|
|
|
|
{"macos-title-bar-material", OPT_CHOICE(macos_title_bar_material,
|
|
|
|
{"titlebar", 0}, {"selection", 1}, {"menu", 2},
|
|
|
|
{"popover", 3}, {"sidebar", 4}, {"headerView", 5},
|
|
|
|
{"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8},
|
|
|
|
{"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11},
|
|
|
|
{"underWindowBackground", 12}, {"underPageBackground", 13},
|
|
|
|
{"dark", 14}, {"light", 15}, {"mediumLight", 16},
|
|
|
|
{"ultraDark", 17})},
|
|
|
|
{"macos-title-bar-color", OPT_COLOR(macos_title_bar_color)},
|
|
|
|
{"macos-fs-animation-duration",
|
|
|
|
OPT_CHOICE(macos_fs_animation_duration, {"default", -1}),
|
|
|
|
M_RANGE(0, 1000)},
|
|
|
|
{"macos-force-dedicated-gpu", OPT_BOOL(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})},
|
|
|
|
{"macos-render-timer", OPT_CHOICE(macos_render_timer,
|
|
|
|
{"callback", RENDER_TIMER_CALLBACK}, {"precise", RENDER_TIMER_PRECISE},
|
2024-04-06 21:31:05 +00:00
|
|
|
{"system", RENDER_TIMER_SYSTEM}, {"feedback", RENDER_TIMER_PRESENTATION_FEEDBACK})},
|
2024-06-22 11:38:32 +00:00
|
|
|
{"macos-menu-shortcuts", OPT_BOOL(macos_menu_shortcuts)},
|
2024-03-26 18:52:37 +00:00
|
|
|
{"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer,
|
|
|
|
{"auto", -1}, {"no", 0}, {"yes", 1})},
|
|
|
|
{"cocoa-cb-10bit-context", OPT_BOOL(cocoa_cb_10bit_context)},
|
2024-04-28 17:21:01 +00:00
|
|
|
{"cocoa-cb-output-csp", OPT_CHOICE(cocoa_cb_output_csp,
|
|
|
|
{"auto", MAC_CSP_AUTO},
|
|
|
|
{"display-p3", MAC_CSP_DISPLAY_P3},
|
|
|
|
{"display-p3-hlg", MAC_CSP_DISPLAY_P3_HLG},
|
|
|
|
{"display-p3-pq", MAC_CSP_DISPLAY_P3_PQ},
|
|
|
|
{"display-p3-linear", MAC_CSP_DISPLAY_P3_LINEAR},
|
|
|
|
{"dci-p3", MAC_CSP_DCI_P3},
|
|
|
|
{"bt.2020", MAC_CSP_BT_2020},
|
|
|
|
{"bt.2020-linear", MAC_CSP_BT_2020_LINEAR},
|
|
|
|
{"bt.2100-hlg", MAC_CSP_BT_2100_HLG},
|
|
|
|
{"bt.2100-pq", MAC_CSP_BT_2100_PQ},
|
|
|
|
{"bt.709", MAC_CSP_BT_709},
|
|
|
|
{"srgb", MAC_CSP_SRGB},
|
|
|
|
{"srgb-linear", MAC_CSP_SRGB_LINEAR},
|
|
|
|
{"rgb-linear", MAC_CSP_RGB_LINEAR},
|
|
|
|
{"adobe", MAC_CSP_ADOBE})},
|
2024-03-26 18:52:37 +00:00
|
|
|
{0}
|
|
|
|
},
|
|
|
|
.size = sizeof(struct macos_opts),
|
|
|
|
.defaults = &(const struct macos_opts){
|
|
|
|
.macos_title_bar_color = {0, 0, 0, 0},
|
|
|
|
.macos_fs_animation_duration = -1,
|
2024-04-06 21:31:05 +00:00
|
|
|
.macos_render_timer = RENDER_TIMER_CALLBACK,
|
2024-06-22 11:38:32 +00:00
|
|
|
.macos_menu_shortcuts = true,
|
2024-03-26 18:52:37 +00:00
|
|
|
.cocoa_cb_sw_renderer = -1,
|
2024-04-28 17:21:01 +00:00
|
|
|
.cocoa_cb_10bit_context = true,
|
|
|
|
.cocoa_cb_output_csp = MAC_CSP_AUTO,
|
2024-03-26 18:52:37 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2024-03-25 23:06:42 +00:00
|
|
|
static const char app_icon[] =
|
|
|
|
#include "TOOLS/osxbundle/icon.icns.inc"
|
|
|
|
;
|
|
|
|
|
|
|
|
NSData *app_bridge_icon(void)
|
|
|
|
{
|
|
|
|
return [NSData dataWithBytesNoCopy:(void *)app_icon length:sizeof(app_icon) - 1 freeWhenDone:NO];
|
|
|
|
}
|
|
|
|
|
2024-03-27 22:22:56 +00:00
|
|
|
void app_bridge_tarray_append(void *t, char ***a, int *i, char *s)
|
|
|
|
{
|
|
|
|
MP_TARRAY_APPEND(t, *a, *i, s);
|
|
|
|
}
|
|
|
|
|
2024-03-26 18:52:37 +00:00
|
|
|
const struct m_sub_options *app_bridge_mac_conf(void)
|
|
|
|
{
|
|
|
|
return &macos_conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct m_sub_options *app_bridge_vo_conf(void)
|
|
|
|
{
|
|
|
|
return &vo_sub_opts;
|
|
|
|
}
|
|
|
|
|
2024-10-05 14:19:48 +00:00
|
|
|
#if HAVE_SWIFT
|
2024-03-23 19:09:15 +00:00
|
|
|
void cocoa_init_media_keys(void)
|
|
|
|
{
|
|
|
|
[[AppHub shared] startRemote];
|
|
|
|
}
|
2010-01-30 13:22:24 +00:00
|
|
|
|
2024-03-23 19:09:15 +00:00
|
|
|
void cocoa_uninit_media_keys(void)
|
|
|
|
{
|
|
|
|
[[AppHub shared] stopRemote];
|
|
|
|
}
|
2014-04-16 02:33:58 +00:00
|
|
|
|
2024-03-23 19:09:15 +00:00
|
|
|
void cocoa_set_input_context(struct input_ctx *input_context)
|
|
|
|
{
|
|
|
|
[[AppHub shared] initInput:input_context];
|
|
|
|
}
|
|
|
|
|
|
|
|
void cocoa_set_mpv_handle(struct mpv_handle *ctx)
|
|
|
|
{
|
|
|
|
[[AppHub shared] initMpv:ctx];
|
|
|
|
}
|
|
|
|
|
|
|
|
void cocoa_init_cocoa_cb(void)
|
|
|
|
{
|
|
|
|
[[AppHub shared] initCocoaCb];
|
|
|
|
}
|
2024-03-30 18:26:45 +00:00
|
|
|
|
|
|
|
int cocoa_main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
return [(Application *)[Application sharedApplication] main:argc :argv];
|
|
|
|
}
|
2024-10-05 14:19:48 +00:00
|
|
|
#endif
|