summaryrefslogtreecommitdiffstats
path: root/osdep
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2024-03-26 19:52:37 +0100
committerder richter <der.richter@gmx.de>2024-03-29 14:20:40 +0100
commit23db34dd6da8454aea0507343ee30aafce1d60cc (patch)
tree1a5b7387ec7c7986c34bd2b0f9c4cd040eef015c /osdep
parent1acca1d3c4c5952911a4b6ea4b8102898a244b57 (diff)
downloadmpv-23db34dd6da8454aea0507343ee30aafce1d60cc.tar.bz2
mpv-23db34dd6da8454aea0507343ee30aafce1d60cc.tar.xz
mac/apphub: move mac options into AppHub
Diffstat (limited to 'osdep')
-rw-r--r--osdep/mac/app_bridge.h26
-rw-r--r--osdep/mac/app_bridge.m53
-rw-r--r--osdep/mac/app_bridge_objc.h2
-rw-r--r--osdep/mac/app_hub.swift8
-rw-r--r--osdep/mac/application.h28
-rw-r--r--osdep/mac/application.m53
-rw-r--r--osdep/mac/application_objc.h2
-rw-r--r--osdep/mac/option_helper.swift4
8 files changed, 91 insertions, 85 deletions
diff --git a/osdep/mac/app_bridge.h b/osdep/mac/app_bridge.h
index 32c161b493..72553b409b 100644
--- a/osdep/mac/app_bridge.h
+++ b/osdep/mac/app_bridge.h
@@ -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;
diff --git a/osdep/mac/app_bridge.m b/osdep/mac/app_bridge.m
index e5e4712ffe..d0f17465a8 100644
--- a/osdep/mac/app_bridge.m
+++ b/osdep/mac/app_bridge.m
@@ -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];
diff --git a/osdep/mac/app_bridge_objc.h b/osdep/mac/app_bridge_objc.h
index 1655a60f0c..31cf90662b 100644
--- a/osdep/mac/app_bridge_objc.h
+++ b/osdep/mac/app_bridge_objc.h
@@ -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);
diff --git a/osdep/mac/app_hub.swift b/osdep/mac/app_hub.swift
index e77bf9381e..c74333383c 100644
--- a/osdep/mac/app_hub.swift
+++ b/osdep/mac/app_hub.swift
@@ -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()
+ }
}
diff --git a/osdep/mac/application.h b/osdep/mac/application.h
index 52bae7a104..3a87cd42a7 100644
--- a/osdep/mac/application.h
+++ b/osdep/mac/application.h
@@ -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;
diff --git a/osdep/mac/application.m b/osdep/mac/application.m
index 1e9cbee64b..898f6dd0c3 100644
--- a/osdep/mac/application.m
+++ b/osdep/mac/application.m
@@ -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];
diff --git a/osdep/mac/application_objc.h b/osdep/mac/application_objc.h
index 123f938a47..f2f2ca8e27 100644
--- a/osdep/mac/application_objc.h
+++ b/osdep/mac/application_objc.h
@@ -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;
diff --git a/osdep/mac/option_helper.swift b/osdep/mac/option_helper.swift
index 0763a04315..8610c4ec46 100644
--- a/osdep/mac/option_helper.swift
+++ b/osdep/mac/option_helper.swift
@@ -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 {