Unified · Split
| @@ -19,8 +19,34 @@ · 18 unmodified lines | |||
| 19 | 19 | ||
| 20 | #include "input/input.h" | 20 | #include "input/input.h" |
| 21 | 21 | ||
| 22 | enum { | ||
| 23 | FRAME_VISIBLE = 0, | ||
| 24 | FRAME_WHOLE, | ||
| 25 | }; | ||
| 26 | |||
| 27 | enum { | ||
| 28 | RENDER_TIMER_CALLBACK = 0, | ||
| 29 | RENDER_TIMER_PRECISE, | ||
| 30 | RENDER_TIMER_SYSTEM, | ||
| 31 | }; | ||
| 32 | |||
| 33 | struct macos_opts { | ||
| 34 | int macos_title_bar_appearance; | ||
| 35 | int macos_title_bar_material; | ||
| 36 | struct m_color macos_title_bar_color; | ||
| 37 | int macos_fs_animation_duration; | ||
| 38 | bool macos_force_dedicated_gpu; | ||
| 39 | int macos_app_activation_policy; | ||
| 40 | int macos_geometry_calculation; | ||
| 41 | int macos_render_timer; | ||
| 42 | int cocoa_cb_sw_renderer; | ||
| 43 | bool cocoa_cb_10bit_context; | ||
| 44 | }; | ||
| 45 | |||
| 22 | void cocoa_init_media_keys(void); | 46 | void cocoa_init_media_keys(void); |
| 23 | void cocoa_uninit_media_keys(void); | 47 | void cocoa_uninit_media_keys(void); |
| 24 | void cocoa_set_input_context(struct input_ctx *input_context); | 48 | void cocoa_set_input_context(struct input_ctx *input_context); |
| 25 | void cocoa_set_mpv_handle(struct mpv_handle *ctx); | 49 | void cocoa_set_mpv_handle(struct mpv_handle *ctx); |
| 26 | void cocoa_init_cocoa_cb(void); | 50 | void cocoa_init_cocoa_cb(void); |
| 51 | |||
| 52 | extern const struct m_sub_options macos_conf; | ||
| @@ -23,6 +23,49 @@ · 22 unmodified lines | |||
| 23 | #include "osdep/mac/swift.h" | 23 | #include "osdep/mac/swift.h" |
| 24 | #endif | 24 | #endif |
| 25 | 25 | ||
| 26 | #define OPT_BASE_STRUCT struct macos_opts | ||
| 27 | const struct m_sub_options macos_conf = { | ||
| 28 | .opts = (const struct m_option[]) { | ||
| 29 | {"macos-title-bar-appearance", OPT_CHOICE(macos_title_bar_appearance, | ||
| 30 | {"auto", 0}, {"aqua", 1}, {"darkAqua", 2}, | ||
| 31 | {"vibrantLight", 3}, {"vibrantDark", 4}, | ||
| 32 | {"aquaHighContrast", 5}, {"darkAquaHighContrast", 6}, | ||
| 33 | {"vibrantLightHighContrast", 7}, | ||
| 34 | {"vibrantDarkHighContrast", 8})}, | ||
| 35 | {"macos-title-bar-material", OPT_CHOICE(macos_title_bar_material, | ||
| 36 | {"titlebar", 0}, {"selection", 1}, {"menu", 2}, | ||
| 37 | {"popover", 3}, {"sidebar", 4}, {"headerView", 5}, | ||
| 38 | {"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8}, | ||
| 39 | {"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11}, | ||
| 40 | {"underWindowBackground", 12}, {"underPageBackground", 13}, | ||
| 41 | {"dark", 14}, {"light", 15}, {"mediumLight", 16}, | ||
| 42 | {"ultraDark", 17})}, | ||
| 43 | {"macos-title-bar-color", OPT_COLOR(macos_title_bar_color)}, | ||
| 44 | {"macos-fs-animation-duration", | ||
| 45 | OPT_CHOICE(macos_fs_animation_duration, {"default", -1}), | ||
| 46 | M_RANGE(0, 1000)}, | ||
| 47 | {"macos-force-dedicated-gpu", OPT_BOOL(macos_force_dedicated_gpu)}, | ||
| 48 | {"macos-app-activation-policy", OPT_CHOICE(macos_app_activation_policy, | ||
| 49 | {"regular", 0}, {"accessory", 1}, {"prohibited", 2})}, | ||
| 50 | {"macos-geometry-calculation", OPT_CHOICE(macos_geometry_calculation, | ||
| 51 | {"visible", FRAME_VISIBLE}, {"whole", FRAME_WHOLE})}, | ||
| 52 | {"macos-render-timer", OPT_CHOICE(macos_render_timer, | ||
| 53 | {"callback", RENDER_TIMER_CALLBACK}, {"precise", RENDER_TIMER_PRECISE}, | ||
| 54 | {"system", RENDER_TIMER_SYSTEM})}, | ||
| 55 | {"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer, | ||
| 56 | {"auto", -1}, {"no", 0}, {"yes", 1})}, | ||
| 57 | {"cocoa-cb-10bit-context", OPT_BOOL(cocoa_cb_10bit_context)}, | ||
| 58 | {0} | ||
| 59 | }, | ||
| 60 | .size = sizeof(struct macos_opts), | ||
| 61 | .defaults = &(const struct macos_opts){ | ||
| 62 | .macos_title_bar_color = {0, 0, 0, 0}, | ||
| 63 | .macos_fs_animation_duration = -1, | ||
| 64 | .cocoa_cb_sw_renderer = -1, | ||
| 65 | .cocoa_cb_10bit_context = true | ||
| 66 | }, | ||
| 67 | }; | ||
| 68 | |||
| 26 | static const char app_icon[] = | 69 | static const char app_icon[] = |
| 27 | #include "TOOLS/osxbundle/icon.icns.inc" | 70 | #include "TOOLS/osxbundle/icon.icns.inc" |
| 28 | ; | 71 | ; |
| @@ -32,6 +75,16 @@ NSData *app_bridge_icon(void) · 3 unmodified lines | |||
| 32 | return [NSData dataWithBytesNoCopy:(void *)app_icon length:sizeof(app_icon) - 1 freeWhenDone:NO]; | 75 | return [NSData dataWithBytesNoCopy:(void *)app_icon length:sizeof(app_icon) - 1 freeWhenDone:NO]; |
| 33 | } | 76 | } |
| 34 | 77 | ||
| 78 | const struct m_sub_options *app_bridge_mac_conf(void) | ||
| 79 | { | ||
| 80 | return &macos_conf; | ||
| 81 | } | ||
| 82 | |||
| 83 | const struct m_sub_options *app_bridge_vo_conf(void) | ||
| 84 | { | ||
| 85 | return &vo_sub_opts; | ||
| 86 | } | ||
| 87 | |||
| 35 | void cocoa_init_media_keys(void) | 88 | void cocoa_init_media_keys(void) |
| 36 | { | 89 | { |
| 37 | [[AppHub shared] startRemote]; | 90 | [[AppHub shared] startRemote]; |
| @@ -20,3 +20,5 @@ · 19 unmodified lines | |||
| 20 | #include "osdep/mac/app_bridge.h" | 20 | #include "osdep/mac/app_bridge.h" |
| 21 | 21 | ||
| 22 | NSData *app_bridge_icon(void); | 22 | NSData *app_bridge_icon(void); |
| 23 | const struct m_sub_options *app_bridge_mac_conf(void); | ||
| 24 | const struct m_sub_options *app_bridge_vo_conf(void); | ||
| @@ -77,4 +77,12 @@ class AppHub: NSObject { · 76 unmodified lines | |||
| 77 | } | 77 | } |
| 78 | return icon | 78 | return icon |
| 79 | } | 79 | } |
| 80 | |||
| 81 | func getMacConf() -> UnsafePointer<m_sub_options>? { | ||
| 82 | return app_bridge_mac_conf() | ||
| 83 | } | ||
| 84 | |||
| 85 | func getVoConf() -> UnsafePointer<m_sub_options>? { | ||
| 86 | return app_bridge_vo_conf() | ||
| 87 | } | ||
| 80 | } | 88 | } |
| @@ -17,33 +17,5 @@ · 16 unmodified lines | |||
| 17 | 17 | ||
| 18 | #pragma once | 18 | #pragma once |
| 19 | 19 | ||
| 20 | #include "options/m_option.h" | ||
| 21 | |||
| 22 | enum { | ||
| 23 | FRAME_VISIBLE = 0, | ||
| 24 | FRAME_WHOLE, | ||
| 25 | }; | ||
| 26 | |||
| 27 | enum { | ||
| 28 | RENDER_TIMER_CALLBACK = 0, | ||
| 29 | RENDER_TIMER_PRECISE, | ||
| 30 | RENDER_TIMER_SYSTEM, | ||
| 31 | }; | ||
| 32 | |||
| 33 | struct macos_opts { | ||
| 34 | int macos_title_bar_appearance; | ||
| 35 | int macos_title_bar_material; | ||
| 36 | struct m_color macos_title_bar_color; | ||
| 37 | int macos_fs_animation_duration; | ||
| 38 | bool macos_force_dedicated_gpu; | ||
| 39 | int macos_app_activation_policy; | ||
| 40 | int macos_geometry_calculation; | ||
| 41 | int macos_render_timer; | ||
| 42 | int cocoa_cb_sw_renderer; | ||
| 43 | bool cocoa_cb_10bit_context; | ||
| 44 | }; | ||
| 45 | |||
| 46 | // multithreaded wrapper for mpv_main | 20 | // multithreaded wrapper for mpv_main |
| 47 | int cocoa_main(int argc, char *argv[]); | 21 | int cocoa_main(int argc, char *argv[]); |
| 48 | |||
| 49 | extern const struct m_sub_options macos_conf; | ||
| @@ -35,49 +35,6 @@ · 34 unmodified lines | |||
| 35 | 35 | ||
| 36 | #define MPV_PROTOCOL @"mpv://" | 36 | #define MPV_PROTOCOL @"mpv://" |
| 37 | 37 | ||
| 38 | #define OPT_BASE_STRUCT struct macos_opts | ||
| 39 | const struct m_sub_options macos_conf = { | ||
| 40 | .opts = (const struct m_option[]) { | ||
| 41 | {"macos-title-bar-appearance", OPT_CHOICE(macos_title_bar_appearance, | ||
| 42 | {"auto", 0}, {"aqua", 1}, {"darkAqua", 2}, | ||
| 43 | {"vibrantLight", 3}, {"vibrantDark", 4}, | ||
| 44 | {"aquaHighContrast", 5}, {"darkAquaHighContrast", 6}, | ||
| 45 | {"vibrantLightHighContrast", 7}, | ||
| 46 | {"vibrantDarkHighContrast", 8})}, | ||
| 47 | {"macos-title-bar-material", OPT_CHOICE(macos_title_bar_material, | ||
| 48 | {"titlebar", 0}, {"selection", 1}, {"menu", 2}, | ||
| 49 | {"popover", 3}, {"sidebar", 4}, {"headerView", 5}, | ||
| 50 | {"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8}, | ||
| 51 | {"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11}, | ||
| 52 | {"underWindowBackground", 12}, {"underPageBackground", 13}, | ||
| 53 | {"dark", 14}, {"light", 15}, {"mediumLight", 16}, | ||
| 54 | {"ultraDark", 17})}, | ||
| 55 | {"macos-title-bar-color", OPT_COLOR(macos_title_bar_color)}, | ||
| 56 | {"macos-fs-animation-duration", | ||
| 57 | OPT_CHOICE(macos_fs_animation_duration, {"default", -1}), | ||
| 58 | M_RANGE(0, 1000)}, | ||
| 59 | {"macos-force-dedicated-gpu", OPT_BOOL(macos_force_dedicated_gpu)}, | ||
| 60 | {"macos-app-activation-policy", OPT_CHOICE(macos_app_activation_policy, | ||
| 61 | {"regular", 0}, {"accessory", 1}, {"prohibited", 2})}, | ||
| 62 | {"macos-geometry-calculation", OPT_CHOICE(macos_geometry_calculation, | ||
| 63 | {"visible", FRAME_VISIBLE}, {"whole", FRAME_WHOLE})}, | ||
| 64 | {"macos-render-timer", OPT_CHOICE(macos_render_timer, | ||
| 65 | {"callback", RENDER_TIMER_CALLBACK}, {"precise", RENDER_TIMER_PRECISE}, | ||
| 66 | {"system", RENDER_TIMER_SYSTEM})}, | ||
| 67 | {"cocoa-cb-sw-renderer", OPT_CHOICE(cocoa_cb_sw_renderer, | ||
| 68 | {"auto", -1}, {"no", 0}, {"yes", 1})}, | ||
| 69 | {"cocoa-cb-10bit-context", OPT_BOOL(cocoa_cb_10bit_context)}, | ||
| 70 | {0} | ||
| 71 | }, | ||
| 72 | .size = sizeof(struct macos_opts), | ||
| 73 | .defaults = &(const struct macos_opts){ | ||
| 74 | .macos_title_bar_color = {0, 0, 0, 0}, | ||
| 75 | .macos_fs_animation_duration = -1, | ||
| 76 | .cocoa_cb_sw_renderer = -1, | ||
| 77 | .cocoa_cb_10bit_context = true | ||
| 78 | }, | ||
| 79 | }; | ||
| 80 | |||
| 81 | // Whether the NSApplication singleton was created. If this is false, we are | 38 | // Whether the NSApplication singleton was created. If this is false, we are |
| 82 | // running in libmpv mode, and cocoa_main() was never called. | 39 | // running in libmpv mode, and cocoa_main() was never called. |
| 83 | static bool application_instantiated; | 40 | static bool application_instantiated; |
| @@ -158,16 +115,6 @@ static void terminate_cocoa_application(void) · 74 unmodified lines | |||
| 158 | #endif | 115 | #endif |
| 159 | } | 116 | } |
| 160 | 117 | ||
| 161 | + (const struct m_sub_options *)getMacConf | ||
| 162 | { | ||
| 163 | return &macos_conf; | ||
| 164 | } | ||
| 165 | |||
| 166 | + (const struct m_sub_options *)getVoConf | ||
| 167 | { | ||
| 168 | return &vo_sub_opts; | ||
| 169 | } | ||
| 170 | |||
| 171 | - (void)applicationWillFinishLaunching:(NSNotification *)notification | 118 | - (void)applicationWillFinishLaunching:(NSNotification *)notification |
| 172 | { | 119 | { |
| 173 | NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; | 120 | NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager]; |
| @@ -26,8 +26,6 @@ struct mpv_handle; · 25 unmodified lines | |||
| 26 | @interface Application : NSApplication | 26 | @interface Application : NSApplication |
| 27 | 27 | ||
| 28 | - (void)initCocoaCb:(struct mpv_handle *)ctx; | 28 | - (void)initCocoaCb:(struct mpv_handle *)ctx; |
| 29 | + (const struct m_sub_options *)getMacConf; | ||
| 30 | + (const struct m_sub_options *)getVoConf; | ||
| 31 | 29 | ||
| 32 | @property(nonatomic, retain) MenuBar *menuBar; | 30 | @property(nonatomic, retain) MenuBar *menuBar; |
| 33 | @property(nonatomic, assign) size_t openCount; | 31 | @property(nonatomic, assign) size_t openCount; |
| @@ -35,8 +35,8 @@ class OptionHelper: NSObject { · 34 unmodified lines | |||
| 35 | var mac: macos_opts { get { return macPtr.pointee } } | 35 | var mac: macos_opts { get { return macPtr.pointee } } |
| 36 | 36 | ||
| 37 | init(_ taParent: UnsafeMutableRawPointer, _ global: OpaquePointer?) { | 37 | init(_ taParent: UnsafeMutableRawPointer, _ global: OpaquePointer?) { |
| 38 | voCachePtr = m_config_cache_alloc(taParent, global, Application.getVoConf()) | 38 | voCachePtr = m_config_cache_alloc(taParent, global, AppHub.shared.getVoConf()) |
| 39 | macCachePtr = m_config_cache_alloc(taParent, global, Application.getMacConf()) | 39 | macCachePtr = m_config_cache_alloc(taParent, global, AppHub.shared.getMacConf()) |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool { | 42 | func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool { |