mirror of https://github.com/mpv-player/mpv
mac/apphub: move mac options into AppHub
This commit is contained in:
parent
1acca1d3c4
commit
23db34dd6d
|
@ -19,8 +19,34 @@
|
|||
|
||||
#include "input/input.h"
|
||||
|
||||
enum {
|
||||
FRAME_VISIBLE = 0,
|
||||
FRAME_WHOLE,
|
||||
};
|
||||
|
||||
enum {
|
||||
RENDER_TIMER_CALLBACK = 0,
|
||||
RENDER_TIMER_PRECISE,
|
||||
RENDER_TIMER_SYSTEM,
|
||||
};
|
||||
|
||||
struct macos_opts {
|
||||
int macos_title_bar_appearance;
|
||||
int macos_title_bar_material;
|
||||
struct m_color macos_title_bar_color;
|
||||
int macos_fs_animation_duration;
|
||||
bool macos_force_dedicated_gpu;
|
||||
int macos_app_activation_policy;
|
||||
int macos_geometry_calculation;
|
||||
int macos_render_timer;
|
||||
int cocoa_cb_sw_renderer;
|
||||
bool cocoa_cb_10bit_context;
|
||||
};
|
||||
|
||||
void cocoa_init_media_keys(void);
|
||||
void cocoa_uninit_media_keys(void);
|
||||
void cocoa_set_input_context(struct input_ctx *input_context);
|
||||
void cocoa_set_mpv_handle(struct mpv_handle *ctx);
|
||||
void cocoa_init_cocoa_cb(void);
|
||||
|
||||
extern const struct m_sub_options macos_conf;
|
||||
|
|
|
@ -23,6 +23,49 @@
|
|||
#include "osdep/mac/swift.h"
|
||||
#endif
|
||||
|
||||
#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},
|
||||
{"system", RENDER_TIMER_SYSTEM})},
|
||||
{"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)},
|
||||
{0}
|
||||
},
|
||||
.size = sizeof(struct macos_opts),
|
||||
.defaults = &(const struct macos_opts){
|
||||
.macos_title_bar_color = {0, 0, 0, 0},
|
||||
.macos_fs_animation_duration = -1,
|
||||
.cocoa_cb_sw_renderer = -1,
|
||||
.cocoa_cb_10bit_context = true
|
||||
},
|
||||
};
|
||||
|
||||
static const char app_icon[] =
|
||||
#include "TOOLS/osxbundle/icon.icns.inc"
|
||||
;
|
||||
|
@ -32,6 +75,16 @@ NSData *app_bridge_icon(void)
|
|||
return [NSData dataWithBytesNoCopy:(void *)app_icon length:sizeof(app_icon) - 1 freeWhenDone:NO];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void cocoa_init_media_keys(void)
|
||||
{
|
||||
[[AppHub shared] startRemote];
|
||||
|
|
|
@ -20,3 +20,5 @@
|
|||
#include "osdep/mac/app_bridge.h"
|
||||
|
||||
NSData *app_bridge_icon(void);
|
||||
const struct m_sub_options *app_bridge_mac_conf(void);
|
||||
const struct m_sub_options *app_bridge_vo_conf(void);
|
||||
|
|
|
@ -77,4 +77,12 @@ class AppHub: NSObject {
|
|||
}
|
||||
return icon
|
||||
}
|
||||
|
||||
func getMacConf() -> UnsafePointer<m_sub_options>? {
|
||||
return app_bridge_mac_conf()
|
||||
}
|
||||
|
||||
func getVoConf() -> UnsafePointer<m_sub_options>? {
|
||||
return app_bridge_vo_conf()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,33 +17,5 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "options/m_option.h"
|
||||
|
||||
enum {
|
||||
FRAME_VISIBLE = 0,
|
||||
FRAME_WHOLE,
|
||||
};
|
||||
|
||||
enum {
|
||||
RENDER_TIMER_CALLBACK = 0,
|
||||
RENDER_TIMER_PRECISE,
|
||||
RENDER_TIMER_SYSTEM,
|
||||
};
|
||||
|
||||
struct macos_opts {
|
||||
int macos_title_bar_appearance;
|
||||
int macos_title_bar_material;
|
||||
struct m_color macos_title_bar_color;
|
||||
int macos_fs_animation_duration;
|
||||
bool macos_force_dedicated_gpu;
|
||||
int macos_app_activation_policy;
|
||||
int macos_geometry_calculation;
|
||||
int macos_render_timer;
|
||||
int cocoa_cb_sw_renderer;
|
||||
bool cocoa_cb_10bit_context;
|
||||
};
|
||||
|
||||
// multithreaded wrapper for mpv_main
|
||||
int cocoa_main(int argc, char *argv[]);
|
||||
|
||||
extern const struct m_sub_options macos_conf;
|
||||
|
|
|
@ -35,49 +35,6 @@
|
|||
|
||||
#define MPV_PROTOCOL @"mpv://"
|
||||
|
||||
#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},
|
||||
{"system", RENDER_TIMER_SYSTEM})},
|
||||
{"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)},
|
||||
{0}
|
||||
},
|
||||
.size = sizeof(struct macos_opts),
|
||||
.defaults = &(const struct macos_opts){
|
||||
.macos_title_bar_color = {0, 0, 0, 0},
|
||||
.macos_fs_animation_duration = -1,
|
||||
.cocoa_cb_sw_renderer = -1,
|
||||
.cocoa_cb_10bit_context = true
|
||||
},
|
||||
};
|
||||
|
||||
// Whether the NSApplication singleton was created. If this is false, we are
|
||||
// running in libmpv mode, and cocoa_main() was never called.
|
||||
static bool application_instantiated;
|
||||
|
@ -158,16 +115,6 @@ static void terminate_cocoa_application(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
+ (const struct m_sub_options *)getMacConf
|
||||
{
|
||||
return &macos_conf;
|
||||
}
|
||||
|
||||
+ (const struct m_sub_options *)getVoConf
|
||||
{
|
||||
return &vo_sub_opts;
|
||||
}
|
||||
|
||||
- (void)applicationWillFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
|
||||
|
|
|
@ -26,8 +26,6 @@ struct mpv_handle;
|
|||
@interface Application : NSApplication
|
||||
|
||||
- (void)initCocoaCb:(struct mpv_handle *)ctx;
|
||||
+ (const struct m_sub_options *)getMacConf;
|
||||
+ (const struct m_sub_options *)getVoConf;
|
||||
|
||||
@property(nonatomic, retain) MenuBar *menuBar;
|
||||
@property(nonatomic, assign) size_t openCount;
|
||||
|
|
|
@ -35,8 +35,8 @@ class OptionHelper: NSObject {
|
|||
var mac: macos_opts { get { return macPtr.pointee } }
|
||||
|
||||
init(_ taParent: UnsafeMutableRawPointer, _ global: OpaquePointer?) {
|
||||
voCachePtr = m_config_cache_alloc(taParent, global, Application.getVoConf())
|
||||
macCachePtr = m_config_cache_alloc(taParent, global, Application.getMacConf())
|
||||
voCachePtr = m_config_cache_alloc(taParent, global, AppHub.shared.getVoConf())
|
||||
macCachePtr = m_config_cache_alloc(taParent, global, AppHub.shared.getMacConf())
|
||||
}
|
||||
|
||||
func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool {
|
||||
|
|
Loading…
Reference in New Issue