Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ jobs:
include:
- os: "macos-13"
arch: "intel"
xcode: "Xcode_14.1"
- os: "macos-14"
arch: "arm"
xcode: "Xcode_15.2"
Expand Down
14 changes: 7 additions & 7 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,25 @@ add_project_link_arguments(link_flags, language: ['c', 'cpp', 'objc'])


# osdep
if darwin
path_source = files('osdep/path-darwin.c')
timer_source = files('osdep/timer-darwin.c')
endif

cocoa = dependency('appleframeworks', modules: ['Cocoa', 'IOKit', 'QuartzCore'],
required: get_option('cocoa'))
features += {'cocoa': cocoa.found()}
if features['cocoa']
dependencies += cocoa
path_source += files('osdep/path-mac.m')
sources += files('osdep/language-mac.c',
'osdep/path-mac.m',
'osdep/utils-mac.c',
'osdep/mac/app_bridge.m',
'player/clipboard/clipboard-mac.m')
main_fn_source = files('osdep/main-fn-mac.c')
endif

if posix
path_source = files('osdep/path-unix.c')
if not get_option('fuzzers') and cc.has_function('fork', prefix : '#include <unistd.h>')
sources += files('osdep/subprocess-posix.c')
else
Expand All @@ -437,12 +441,8 @@ if posix and not features['cocoa']
main_fn_source = files('osdep/main-fn-unix.c')
endif

if darwin
path_source = files('osdep/path-darwin.c')
timer_source = files('osdep/timer-darwin.c')
endif

if posix and not darwin
path_source = files('osdep/path-unix.c')
timer_source = files('osdep/timer-linux.c')
endif

Expand Down
15 changes: 10 additions & 5 deletions osdep/mac/dialog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
*/

import Cocoa
#if HAVE_MACOS_11_FEATURES
import UniformTypeIdentifiers
#endif

class Dialog: NSObject, NSWindowDelegate, NSOpenSavePanelDelegate {
var option: OptionHelper?
Expand All @@ -26,30 +28,33 @@ class Dialog: NSObject, NSWindowDelegate, NSOpenSavePanelDelegate {
}

func openFiles(title: String? = nil, path: URL? = nil) -> [String]? {
let types: [UTType] = (TypeHelper.toStringArray(option?.root.video_exts) +
let types: [String] = TypeHelper.toStringArray(option?.root.video_exts) +
TypeHelper.toStringArray(option?.root.audio_exts) +
TypeHelper.toStringArray(option?.root.image_exts) +
TypeHelper.toStringArray(option?.root.archive_exts) +
TypeHelper.toStringArray(option?.root.playlist_exts)).compactMap { UTType(filenameExtension: $0) }
TypeHelper.toStringArray(option?.root.playlist_exts)
return open(title: title, path: path, types: types)
}

func openPlaylist(title: String? = nil, path: URL? = nil) -> String? {
let types: [UTType] = TypeHelper.toStringArray(option?.root.playlist_exts).compactMap { UTType(filenameExtension: $0) }
let types: [String] = TypeHelper.toStringArray(option?.root.playlist_exts)
return open(title: title, path: path, directories: false, multiple: false, types: types)?.first
}

func open(title: String? = nil, path: URL? = nil, files: Bool = true,
directories: Bool = true, multiple: Bool = true, types: [UTType] = []) -> [String]? {
directories: Bool = true, multiple: Bool = true, types: [String] = []) -> [String]? {
let panel = NSOpenPanel()
panel.title = title ?? panel.title
panel.directoryURL = path
panel.canChooseFiles = files
panel.canChooseDirectories = directories
panel.allowsMultipleSelection = multiple
panel.allowedContentTypes = types
panel.delegate = self

if #available(macOS 11.0, *) {
panel.allowedContentTypes = types.compactMap { UTType(filenameExtension: $0) }
}

if panel.runModal() == .OK {
return panel.urls.map { $0.path }
}
Expand Down
8 changes: 8 additions & 0 deletions osdep/mac/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ module = join_paths(build_root, 'osdep/mac/swift.swiftmodule')
swift_flags = ['-c', '-emit-library', '-static', '-sdk', macos_sdk_path,
'-emit-objc-header', '-parse-as-library']

# fallback to old swift frontend build
if swift_ver.version_compare('<5.8')
message('Falling back to old swift frontend build')
swift_prog = find_program(run_command(xcrun, '-find', 'swift', check: true).stdout().strip())
swift_flags = ['-frontend', '-c', '-sdk', macos_sdk_path,
'-enable-objc-interop', '-emit-objc-header', '-parse-as-library']
endif

if swift_ver.version_compare('>=6.0')
swift_flags += ['-swift-version', '5']
endif
Expand Down
17 changes: 16 additions & 1 deletion osdep/mac/swift_compat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

#if !swift(>=5.7)
extension NSCondition {
extension NSLocking {
func withLock<R>(_ body: () throws -> R) rethrows -> R {
self.lock()
defer { self.unlock() }
Expand Down Expand Up @@ -51,3 +51,18 @@ extension CGColorSpace {
static let itur_2100_PQ: CFString = kCGColorSpaceITUR_2100_PQ
}
#endif

#if !HAVE_MACOS_11_FEATURES
@available(macOS 11.0, *)
public struct UTType: Sendable {
public init?(filenameExtension: String) {}
}

extension NSSavePanel {
@available(macOS 11.0, *)
public var allowedContentTypes: [UTType] {
get { return [] }
set { _ = newValue }
}
}
#endif
4 changes: 2 additions & 2 deletions player/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ static char *append_selected_style(struct MPContext *mpctx, char *str)
mpctx->video_out->osd->opts->osd_selected_color.b,
mpctx->video_out->osd->opts->osd_selected_color.g,
mpctx->video_out->osd->opts->osd_selected_color.r,
255 - mpctx->video_out->osd->opts->osd_selected_color.a,
(uint8_t)(255 - mpctx->video_out->osd->opts->osd_selected_color.a),
mpctx->video_out->osd->opts->osd_selected_outline_color.b,
mpctx->video_out->osd->opts->osd_selected_outline_color.g,
mpctx->video_out->osd->opts->osd_selected_outline_color.r,
255 - mpctx->video_out->osd->opts->osd_selected_outline_color.a,
(uint8_t)(255 - mpctx->video_out->osd->opts->osd_selected_outline_color.a),
OSD_ASS_1);
}

Expand Down
Loading