Skip to content

Commit

Permalink
mac: remove runtime checks and compatibility for macOS older than 10.15
Browse files Browse the repository at this point in the history
we stopped supporting macOS older than 10.15 and hence can remove all
the unnecessary runtime checks and compatibility layers.
  • Loading branch information
Akemi authored and Dudemanguy committed Nov 9, 2023
1 parent a5bf211 commit 23de1de
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 214 deletions.
5 changes: 1 addition & 4 deletions osdep/macos/remote_command_center.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import MediaPlayer

@available(macOS 10.12.2, *)
class RemoteCommandCenter: NSObject {
enum KeyType {
case normal
Expand Down Expand Up @@ -105,9 +104,7 @@ class RemoteCommandCenter: NSObject {
}
}

if let app = NSApp as? Application, let icon = app.getMPVIcon(),
#available(macOS 10.13.2, *)
{
if let app = NSApp as? Application, let icon = app.getMPVIcon() {
let albumArt = MPMediaItemArtwork(boundsSize: icon.size) { _ in
return icon
}
Expand Down
17 changes: 0 additions & 17 deletions osdep/macos/swift_compat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/

extension NSPasteboard.PasteboardType {
static let fileURLCompat: NSPasteboard.PasteboardType = {
if #available(OSX 10.13, *) {
return .fileURL
} else {
return NSPasteboard.PasteboardType(kUTTypeURL as String)
}
} ()

static let URLCompat: NSPasteboard.PasteboardType = {
if #available(OSX 10.13, *) {
return .URL
} else {
return NSPasteboard.PasteboardType(kUTTypeFileURL as String)
}
} ()
}

#if !swift(>=5.0)
extension Data {
Expand Down
4 changes: 1 addition & 3 deletions osdep/macosx_application.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "options/options.h"

#import "osdep/macosx_application_objc.h"
#include "osdep/macosx_compat.h"
#import "osdep/macosx_events_objc.h"
#include "osdep/threads.h"
#include "osdep/main-fn.h"
Expand Down Expand Up @@ -177,8 +176,7 @@ - (NSTouchBar *)makeTouchBar
- (void)processEvent:(struct mpv_event *)event
{
#if HAVE_MACOS_TOUCHBAR
if ([self respondsToSelector:@selector(touchBar)])
[(TouchBar *)self.touchBar processEvent:event];
[(TouchBar *)self.touchBar processEvent:event];
#endif
if (_cocoa_cb) {
[_cocoa_cb processEvent:event];
Expand Down
63 changes: 0 additions & 63 deletions osdep/macosx_compat.h

This file was deleted.

4 changes: 1 addition & 3 deletions osdep/macosx_events.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
// doesn't make much sense, but needed to access keymap functionality
#include "video/out/vo.h"

#include "osdep/macosx_compat.h"
#import "osdep/macosx_events_objc.h"
#import "osdep/macosx_application_objc.h"

Expand Down Expand Up @@ -299,8 +298,7 @@ -(void)processEvent:(struct mpv_event *)event
- (void)startMediaKeys
{
#if HAVE_MACOS_MEDIA_PLAYER
// 10.12.2 runtime availability check
if (_remoteCommandCenter == nil && [NSApp respondsToSelector:@selector(touchBar)]) {
if (_remoteCommandCenter == nil) {
_remoteCommandCenter = [[RemoteCommandCenter alloc] init];
}
#endif
Expand Down
8 changes: 2 additions & 6 deletions osdep/macosx_menubar.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#import "macosx_menubar_objc.h"
#import "osdep/macosx_application_objc.h"
#include "osdep/macosx_compat.h"

@implementation MenuBar
{
Expand All @@ -34,9 +33,7 @@ - (id)init
[userDefaults setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"];
[userDefaults setBool:YES forKey:@"NSDisabledDictationMenuItem"];
[userDefaults setBool:YES forKey:@"NSDisabledCharacterPaletteMenuItem"];

if ([NSWindow respondsToSelector:@selector(setAllowsAutomaticWindowTabbing:)])
[NSWindow setAllowsAutomaticWindowTabbing: NO];
[NSWindow setAllowsAutomaticWindowTabbing: NO];

menuTree = @[
@{
Expand Down Expand Up @@ -640,8 +637,7 @@ - (NSMenu *)mainMenu

#if HAVE_MACOS_TOUCHBAR
if ([action isEqual:@"toggleTouchBarCustomizationPalette:"]) {
if (![NSApp respondsToSelector:@selector(touchBar)])
continue;
continue;
}
#endif

Expand Down
33 changes: 0 additions & 33 deletions osdep/macosx_versions.h

This file was deleted.

1 change: 0 additions & 1 deletion video/out/cocoa/events_view.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "input/input.h"
#include "input/keycodes.h"

#include "osdep/macosx_compat.h"
#include "video/out/cocoa_common.h"
#include "events_view.h"

Expand Down
1 change: 0 additions & 1 deletion video/out/cocoa/video_view.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/

#include "osdep/macosx_compat.h"
#include "video/out/cocoa_common.h"
#include "video_view.h"

Expand Down
1 change: 0 additions & 1 deletion video/out/cocoa/window.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "input/keycodes.h"

#include "osdep/macosx_events.h"
#include "osdep/macosx_compat.h"
#include "video/out/cocoa_common.h"

#include "window.h"
Expand Down
4 changes: 1 addition & 3 deletions video/out/cocoa_cb_common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,7 @@ class CocoaCB: Common {
}

libmpv.setRenderICCProfile(colorSpace)
if #available(macOS 10.11, *) {
layer?.colorspace = colorSpace.cgColorSpace
}
layer?.colorspace = colorSpace.cgColorSpace
}

override func windowDidEndAnimation() {
Expand Down
1 change: 0 additions & 1 deletion video/out/cocoa_common.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#import "video/out/cocoa/mpvadapter.h"

#include "osdep/threads.h"
#include "osdep/macosx_compat.h"
#include "osdep/macosx_events_objc.h"

#include "osdep/timer.h"
Expand Down
19 changes: 2 additions & 17 deletions video/out/mac/common.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,6 @@ class Common: NSObject {
view?.removeFromSuperview()
}

let linkCallback: CVDisplayLinkOutputCallback = {
(displayLink: CVDisplayLink,
inNow: UnsafePointer<CVTimeStamp>,
inOutputTime: UnsafePointer<CVTimeStamp>,
flagsIn: CVOptionFlags,
flagsOut: UnsafeMutablePointer<CVOptionFlags>,
displayLinkContext: UnsafeMutableRawPointer?) -> CVReturn in
let com = unsafeBitCast(displayLinkContext, to: Common.self)
return com.displayLinkCallback(displayLink, inNow, inOutputTime, flagsIn, flagsOut)
}

func displayLinkCallback(_ displayLink: CVDisplayLink,
_ inNow: UnsafePointer<CVTimeStamp>,
_ inOutputTime: UnsafePointer<CVTimeStamp>,
Expand All @@ -195,12 +184,8 @@ class Common: NSObject {
}

CVDisplayLinkSetCurrentCGDisplay(link, screen.displayID)
if #available(macOS 10.12, *) {
CVDisplayLinkSetOutputHandler(link) { link, now, out, inFlags, outFlags -> CVReturn in
return self.displayLinkCallback(link, now, out, inFlags, outFlags)
}
} else {
CVDisplayLinkSetOutputCallback(link, linkCallback, MPVHelper.bridge(obj: self))
CVDisplayLinkSetOutputHandler(link) { link, now, out, inFlags, outFlags -> CVReturn in
return self.displayLinkCallback(link, now, out, inFlags, outFlags)
}
CVDisplayLinkStart(link)
}
Expand Down
2 changes: 1 addition & 1 deletion video/out/mac/gl_layer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class GLLayer: CAOpenGLLayer {
autoresizingMask = [.layerWidthSizable, .layerHeightSizable]
backgroundColor = NSColor.black.cgColor

if #available(macOS 10.12, *), bufferDepth > 8 {
if bufferDepth > 8 {
contentsFormat = .RGBA16Float
}

Expand Down

2 comments on commit 23de1de

@barracuda156
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dudemanguy @Akemi Hmm, what was the need to break it?

@Akemi
Copy link
Member Author

@Akemi Akemi commented on 23de1de Dec 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

various reasons:

  • required dependency on libplacebo
  • only latest 3 OS support from Apple
  • other places/commits that already restricted the OS support
  • my limited time
  • possibility to test everything
  • a needed hard cut and cleanup
  • many more

Please sign in to comment.