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
19 19
20#include "input/input.h"20#include "input/input.h"
21 21
22enum {
23 FRAME_VISIBLE = 0,
24 FRAME_WHOLE,
25};
26
27enum {
28 RENDER_TIMER_CALLBACK = 0,
29 RENDER_TIMER_PRECISE,
30 RENDER_TIMER_SYSTEM,
31};
32
33struct 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
22void cocoa_init_media_keys(void);46void cocoa_init_media_keys(void);
23void cocoa_uninit_media_keys(void);47void cocoa_uninit_media_keys(void);
24void cocoa_set_input_context(struct input_ctx *input_context);48void cocoa_set_input_context(struct input_ctx *input_context);
25void cocoa_set_mpv_handle(struct mpv_handle *ctx);49void cocoa_set_mpv_handle(struct mpv_handle *ctx);
26void cocoa_init_cocoa_cb(void);50void cocoa_init_cocoa_cb(void);
51
52extern const struct m_sub_options macos_conf;
osdep/mac/app_bridge.m+53−0
@@ -23,6 +23,49 @@ · 22 unmodified lines
23#include "osdep/mac/swift.h"23#include "osdep/mac/swift.h"
24#endif24#endif
25 25
26#define OPT_BASE_STRUCT struct macos_opts
27const 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
26static const char app_icon[] =69static 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
78const struct m_sub_options *app_bridge_mac_conf(void)
79{
80 return &macos_conf;
81}
82
83const struct m_sub_options *app_bridge_vo_conf(void)
84{
85 return &vo_sub_opts;
86}
87
35void cocoa_init_media_keys(void)88void cocoa_init_media_keys(void)
36{89{
37 [[AppHub shared] startRemote];90 [[AppHub shared] startRemote];
osdep/mac/app_bridge_objc.h+2−0
@@ -20,3 +20,5 @@ · 19 unmodified lines
20#include "osdep/mac/app_bridge.h"20#include "osdep/mac/app_bridge.h"
21 21
22NSData *app_bridge_icon(void);22NSData *app_bridge_icon(void);
23const struct m_sub_options *app_bridge_mac_conf(void);
24const 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
77 }77 }
78 return icon78 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}
osdep/mac/application.h+0−28
@@ -17,33 +17,5 @@ · 16 unmodified lines
17 17
18#pragma once18#pragma once
19 19
20#include "options/m_option.h"
21
22enum {
23 FRAME_VISIBLE = 0,
24 FRAME_WHOLE,
25};
26
27enum {
28 RENDER_TIMER_CALLBACK = 0,
29 RENDER_TIMER_PRECISE,
30 RENDER_TIMER_SYSTEM,
31};
32
33struct 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_main20// multithreaded wrapper for mpv_main
47int cocoa_main(int argc, char *argv[]);21int cocoa_main(int argc, char *argv[]);
48
49extern const struct m_sub_options macos_conf;
osdep/mac/application.m+0−53
@@ -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
39const 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 are38// 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.
83static bool application_instantiated;40static bool application_instantiated;
@@ -158,16 +115,6 @@ static void terminate_cocoa_application(void) · 74 unmodified lines
158#endif115#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 *)notification118- (void)applicationWillFinishLaunching:(NSNotification *)notification
172{119{
173 NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];120 NSAppleEventManager *em = [NSAppleEventManager sharedAppleEventManager];
osdep/mac/application_objc.h+0−2
@@ -26,8 +26,6 @@ struct mpv_handle; · 25 unmodified lines
26@interface Application : NSApplication26@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;
osdep/mac/option_helper.swift+2−2
@@ -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 {

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