From c540ac8485d132285071aa43a493c3829f4f0d5c Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 14 Apr 2019 15:07:56 +0200 Subject: cocoa-cb: conditional compilation for Dark Mode and Material features Fixes #6621 --- osdep/macOS_swift_compat.swift | 24 ++++++++++++++++++++++++ video/out/cocoa-cb/title_bar.swift | 5 ++++- wscript | 12 +++++++++++- wscript_build.py | 1 + 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 osdep/macOS_swift_compat.swift diff --git a/osdep/macOS_swift_compat.swift b/osdep/macOS_swift_compat.swift new file mode 100644 index 0000000000..1a57a1e1c3 --- /dev/null +++ b/osdep/macOS_swift_compat.swift @@ -0,0 +1,24 @@ +/* + * This file is part of mpv. + * + * mpv is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * mpv is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with mpv. If not, see . + */ + +#if !HAVE_MACOS_10_14_FEATURES +let NSAppearanceNameDarkAqua = "NSAppearanceNameDarkAqua" +let NSAppearanceNameAccessibilityHighContrastAqua = "NSAppearanceNameAccessibilityAqua" +let NSAppearanceNameAccessibilityHighContrastDarkAqua = "NSAppearanceNameAccessibilityDarkAqua" +let NSAppearanceNameAccessibilityHighContrastVibrantLight = "NSAppearanceNameAccessibilityVibrantLight" +let NSAppearanceNameAccessibilityHighContrastVibrantDark = "NSAppearanceNameAccessibilityVibrantDark" +#endif diff --git a/video/out/cocoa-cb/title_bar.swift b/video/out/cocoa-cb/title_bar.swift index 596a13ba7b..f5979c71e9 100644 --- a/video/out/cocoa-cb/title_bar.swift +++ b/video/out/cocoa-cb/title_bar.swift @@ -214,6 +214,7 @@ class TitleBar: NSVisualEffectView { default: break } +#if HAVE_MACOS_10_11_FEATURES if #available(macOS 10.11, *) { switch string { case "2,", "menu": return .menu @@ -224,7 +225,8 @@ class TitleBar: NSVisualEffectView { default: break } } - +#endif +#if HAVE_MACOS_10_14_FEATURES if #available(macOS 10.14, *) { switch string { case "5,", "headerView": return .headerView @@ -239,6 +241,7 @@ class TitleBar: NSVisualEffectView { default: break } } +#endif return .titlebar } diff --git a/wscript b/wscript index 76cfe1ddd3..0670e50a66 100644 --- a/wscript +++ b/wscript @@ -945,7 +945,17 @@ standalone_features = [ framework_name=['AppKit'], compile_filename='test-touchbar.m', linkflags='-fobjc-arc') - }, { + }, { + 'name': '--macos-10-11-features', + 'desc': 'macOS 10.11 SDK Features', + 'deps': 'cocoa', + 'func': check_macos_sdk('10.11') + }, { + 'name': '--macos-10-14-features', + 'desc': 'macOS 10.14 SDK Features', + 'deps': 'cocoa', + 'func': check_macos_sdk('10.14') + }, { 'name': '--macos-cocoa-cb', 'desc': 'macOS opengl-cb backend', 'deps': 'cocoa && swift', diff --git a/wscript_build.py b/wscript_build.py index 4c0a12283e..3e9cfadd34 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -165,6 +165,7 @@ def build(ctx): swift_source = [ ( "osdep/macOS_mpv_helper.swift" ), ( "osdep/macOS_swift_extensions.swift" ), + ( "osdep/macOS_swift_compat.swift" ), ( "video/out/cocoa-cb/events_view.swift" ), ( "video/out/cocoa-cb/video_layer.swift" ), ( "video/out/cocoa-cb/window.swift" ), -- cgit v1.2.3