History

mac/apphub: move mac options into AppHub

der richter committed 2 years ago

Commit 23db34d1 parent 1acca1d8 files · +91 −85Browse files

Unified · Split

8 files
  1. osdep/mac/app_bridge.h +26 −0
  2. osdep/mac/app_bridge.m +53 −0
  3. osdep/mac/app_bridge_objc.h +2 −0
  4. osdep/mac/app_hub.swift +8 −0
  5. osdep/mac/application.h +0 −28
  6. osdep/mac/application.m +0 −53
  7. osdep/mac/application_objc.h +0 −2
  8. osdep/mac/option_helper.swift +2 −2
osdep/mac/app_bridge.h+26−0
@@ -19,8 +19,34 @@ · 18 unmodified lines
1919
2020 #include "input/input.h"
2121
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+
2246 void cocoa_init_media_keys(void);
2347 void cocoa_uninit_media_keys(void);
2448 void cocoa_set_input_context(struct input_ctx *input_context);
2549 void cocoa_set_mpv_handle(struct mpv_handle *ctx);
2650 void cocoa_init_cocoa_cb(void);
51+
52+extern const struct m_sub_options macos_conf;
osdep/mac/app_bridge.m+53−0
@@ -23,6 +23,49 @@ · 22 unmodified lines
2323 #include "osdep/mac/swift.h"
2424 #endif
2525
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+
2669 static const char app_icon[] =
2770 #include "TOOLS/osxbundle/icon.icns.inc"
2871 ;
@@ -32,6 +75,16 @@ NSData *app_bridge_icon(void) · 3 unmodified lines
3275 return [NSData dataWithBytesNoCopy:(void *)app_icon length:sizeof(app_icon) - 1 freeWhenDone:NO];
3376 }
3477
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+
3588 void cocoa_init_media_keys(void)
3689 {
3790 [[AppHub shared] startRemote];
osdep/mac/app_bridge_objc.h+2−0
@@ -20,3 +20,5 @@ · 19 unmodified lines
2020 #include "osdep/mac/app_bridge.h"
2121
2222 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);
osdep/mac/app_hub.swift+8−0
@@ -77,4 +77,12 @@ class AppHub: NSObject { · 76 unmodified lines
7777 }
7878 return icon
7979 }
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+ }
8088 }
osdep/mac/application.h+0−28
@@ -17,33 +17,5 @@ · 16 unmodified lines
1717
1818 #pragma once
1919
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−
4620 // multithreaded wrapper for mpv_main
4721 int cocoa_main(int argc, char *argv[]);
48−
49−extern const struct m_sub_options macos_conf;
osdep/mac/application.m+0−53
@@ -35,49 +35,6 @@ · 34 unmodified lines
3535
3636 #define MPV_PROTOCOL @"mpv://"
3737
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−
8138 // Whether the NSApplication singleton was created. If this is false, we are
8239 // running in libmpv mode, and cocoa_main() was never called.
8340 static bool application_instantiated;
@@ -158,16 +115,6 @@ static void terminate_cocoa_application(void) · 74 unmodified lines
158115 #endif
159116 }
160117
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−
171118 - (void)applicationWillFinishLaunching:(NSNotification *)notification
172119 {
173120 NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
osdep/mac/application_objc.h+0−2
@@ -26,8 +26,6 @@ struct mpv_handle; · 25 unmodified lines
2626 @interface Application : NSApplication
2727
2828 - (void)initCocoaCb:(struct mpv_handle *)ctx;
29−+ (const struct m_sub_options *)getMacConf;
30−+ (const struct m_sub_options *)getVoConf;
3129
3230 @property(nonatomic, retain) MenuBar *menuBar;
3331 @property(nonatomic, assign) size_t openCount;
osdep/mac/option_helper.swift+2−2
@@ -35,8 +35,8 @@ class OptionHelper: NSObject { · 34 unmodified lines
3535 var mac: macos_opts { get { return macPtr.pointee } }
3636
3737 init(_ taParent: UnsafeMutableRawPointer, _ global: OpaquePointer?) {
38− voCachePtr = m_config_cache_alloc(taParent, global, Application.getVoConf())
39− macCachePtr = m_config_cache_alloc(taParent, global, Application.getMacConf())
38+ voCachePtr = m_config_cache_alloc(taParent, global, AppHub.shared.getVoConf())
39+ macCachePtr = m_config_cache_alloc(taParent, global, AppHub.shared.getMacConf())
4040 }
4141
4242 func nextChangedOption(property: inout UnsafeMutableRawPointer?) -> Bool {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t