Skip to content

Commit

Permalink
Fix touchbar and iTL for Mojave
Browse files Browse the repository at this point in the history
  • Loading branch information
xzzz9097 committed Sep 25, 2018
1 parent 5c24c0e commit 0fdd666
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 46 deletions.
24 changes: 4 additions & 20 deletions Muse.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
0C9B62331E1EAE9100660633 /* ButtonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0C9B62321E1EAE9100660633 /* ButtonCell.swift */; };
0CA45AC31F17D0DB00B2DD21 /* DFRPrivateHeader.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CA45AC21F17D0DB00B2DD21 /* DFRPrivateHeader.m */; };
0CA5FA621ED1DC9500248A91 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 0CA5FA611ED1DC9500248A91 /* dsa_pub.pem */; };
0CAB4ED221064F8600CC118A /* iTunesLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0CAB4ED121064F8600CC118A /* iTunesLibrary.framework */; };
0CB0E0511DEE04AD00B4DF17 /* PlayerHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CB0E0501DEE04AD00B4DF17 /* PlayerHelper.swift */; };
0CC8466B1DF728AE00941787 /* MPRemoteCommand+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC8466A1DF728AE00941787 /* MPRemoteCommand+Extensions.swift */; };
0CCD27661DF01F440039ACDC /* DDHotKeyCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 0CCD27611DF01F440039ACDC /* DDHotKeyCenter.m */; };
Expand All @@ -61,6 +60,7 @@
0CEAEB3F1E16624800BD68D5 /* DispatchQueue+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CEAEB3E1E16624800BD68D5 /* DispatchQueue+Extensions.swift */; };
0CF8B7E41DF9772900CDD130 /* NSHoverableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CF8B7E31DF9772900CDD130 /* NSHoverableView.swift */; };
0CFA0FDD1DF37059007DA6AE /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0CFA0FDC1DF37059007DA6AE /* MediaPlayer.framework */; };
0CFAE22121597E400010215E /* iTunesLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0CFAE22021597E3F0010215E /* iTunesLibrary.framework */; };
0CFF466A1DE3826300A3BE8E /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CFF46691DE3826300A3BE8E /* AppDelegate.swift */; };
0CFF466C1DE3826300A3BE8E /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CFF466B1DE3826300A3BE8E /* ViewController.swift */; };
0CFF466E1DE3826300A3BE8E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0CFF466D1DE3826300A3BE8E /* Assets.xcassets */; };
Expand Down Expand Up @@ -205,6 +205,7 @@
0CEAEB3E1E16624800BD68D5 /* DispatchQueue+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "DispatchQueue+Extensions.swift"; sourceTree = "<group>"; };
0CF8B7E31DF9772900CDD130 /* NSHoverableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSHoverableView.swift; sourceTree = "<group>"; };
0CFA0FDC1DF37059007DA6AE /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
0CFAE22021597E3F0010215E /* iTunesLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = iTunesLibrary.framework; path = ../../../../../System/Library/Frameworks/iTunesLibrary.framework; sourceTree = "<group>"; };
0CFF46661DE3826300A3BE8E /* Muse.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Muse.app; sourceTree = BUILT_PRODUCTS_DIR; };
0CFF46691DE3826300A3BE8E /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
0CFF466B1DE3826300A3BE8E /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
Expand All @@ -229,10 +230,10 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
0CAB4ED221064F8600CC118A /* iTunesLibrary.framework in Frameworks */,
0C1B1F5F1F17C065009D4588 /* DFRFoundation.framework in Frameworks */,
0CFA0FDD1DF37059007DA6AE /* MediaPlayer.framework in Frameworks */,
0C9A60D91DE79B6D0051CDC6 /* Carbon.framework in Frameworks */,
0CFAE22121597E400010215E /* iTunesLibrary.framework in Frameworks */,
FD9F763CA855EFBC8846FCDC /* Pods_Muse.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -481,6 +482,7 @@
isa = PBXGroup;
children = (
0CAB4ED121064F8600CC118A /* iTunesLibrary.framework */,
0CFAE22021597E3F0010215E /* iTunesLibrary.framework */,
0C3382CD1F14F372000D74F9 /* DFRFoundation.framework */,
0C676BD61DF443C900B75164 /* AVKit.framework */,
0C676BD41DF443AD00B75164 /* AVFoundation.framework */,
Expand All @@ -506,7 +508,6 @@
0CFF46631DE3826300A3BE8E /* Frameworks */,
0CFF46641DE3826300A3BE8E /* Resources */,
1A4CC0C78FE35E1A8380752A /* [CP] Embed Pods Frameworks */,
F4864ADC8C3C6DC2FFECCE72 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -705,14 +706,12 @@
"${SRCROOT}/Pods/Target Support Files/Pods-Muse/Pods-Muse-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/MASPreferences/MASPreferences.framework",
"${PODS_ROOT}/Sparkle/Sparkle.framework",
"${PODS_ROOT}/Sparkle/Sparkle.framework.dSYM",
"${BUILT_PRODUCTS_DIR}/SpotifyKit/SpotifyKit.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MASPreferences.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Sparkle.framework",
"${DWARF_DSYM_FOLDER_PATH}/Sparkle.framework.dSYM",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SpotifyKit.framework",
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -738,21 +737,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
F4864ADC8C3C6DC2FFECCE72 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Muse/Pods-Muse-resources.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
17 changes: 13 additions & 4 deletions Muse/Libraries/DFRPrivate/DFRPrivateHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#import <AppKit/AppKit.h>

extern void DFRElementSetControlStripPresenceForIdentifier(NSString *, BOOL);
extern void DFRElementSetControlStripPresenceForIdentifier(NSTouchBarItemIdentifier, BOOL);
extern void DFRSystemModalShowsCloseBoxWhenFrontMost(BOOL);

@interface NSTouchBarItem ()
Expand All @@ -28,19 +28,28 @@ extern void DFRSystemModalShowsCloseBoxWhenFrontMost(BOOL);

@interface NSTouchBar ()

+ (void)presentSystemModalTouchBar:(NSTouchBar *)touchBar
systemTrayItemIdentifier:(NSTouchBarItemIdentifier)identifier NS_AVAILABLE_MAC(10.14);

+ (void)presentSystemModalFunctionBar:(NSTouchBar *)touchBar
systemTrayItemIdentifier:(NSString *)identifier;
systemTrayItemIdentifier:(NSTouchBarItemIdentifier)identifier NS_DEPRECATED_MAC(10.12.2, 10.14);

+ (void)dismissSystemModalTouchBar:(NSTouchBar *)touchBar NS_AVAILABLE_MAC(10.14);

+ (void)dismissSystemModalFunctionBar:(NSTouchBar *)touchBar;
+ (void)minimizeSystemModalTouchBar:(NSTouchBar *)touchBar NS_AVAILABLE_MAC(10.14);

+ (void)minimizeSystemModalFunctionBar:(NSTouchBar *)touchBar;
+ (void)dismissSystemModalFunctionBar:(NSTouchBar *)touchBar NS_DEPRECATED_MAC(10.12.2, 10.14);

+ (void)minimizeSystemModalFunctionBar:(NSTouchBar *)touchBar NS_DEPRECATED_MAC(10.12.2, 10.14);

@end

@interface NSTouchBar (DFRAccess)

- (void)presentAsSystemModalForItem:(NSTouchBarItem *)item;

- (void)presentAsSystemModalForItemIdentifier:(NSTouchBarItemIdentifier)identifier;

- (void)dismissSystemModal;

- (void)minimizeSystemModal;
Expand Down
25 changes: 21 additions & 4 deletions Muse/Libraries/DFRPrivate/DFRPrivateHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,33 @@ - (void)toggleControlStripPresence:(BOOL)present {
@implementation NSTouchBar (DFRAccess)

- (void)presentAsSystemModalForItem:(NSTouchBarItem *)item {
[NSTouchBar presentSystemModalFunctionBar:self
systemTrayItemIdentifier:item.identifier];
[self presentAsSystemModalForItemIdentifier:item.identifier];
}

- (void)presentAsSystemModalForItemIdentifier:(NSTouchBarItemIdentifier)identifier {
if (@available(macOS 10.14, *)) {
[NSTouchBar presentSystemModalTouchBar:self
systemTrayItemIdentifier:identifier];
} else {
[NSTouchBar presentSystemModalFunctionBar:self
systemTrayItemIdentifier:identifier];
}
}

- (void)dismissSystemModal {
[NSTouchBar dismissSystemModalFunctionBar:self];
if (@available(macOS 10.14, *)) {
[NSTouchBar dismissSystemModalTouchBar:self];
} else {
[NSTouchBar dismissSystemModalFunctionBar:self];
}
}

- (void)minimizeSystemModal {
[NSTouchBar minimizeSystemModalFunctionBar:self];
if (@available(macOS 10.14, *)) {
[NSTouchBar minimizeSystemModalTouchBar:self];
} else {
[NSTouchBar minimizeSystemModalFunctionBar:self];
}
}

@end
Expand Down
1 change: 0 additions & 1 deletion Muse/Resources/Muse-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@
#import "DDHotKeyUtilities.h"
#import "PlayerStates.h"
#import "DFRPrivateHeader.h"
#import <iTunesLibrary/ITLibrary.h>
13 changes: 7 additions & 6 deletions Muse/Sources/Controllers/iTunesHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import ScriptingBridge
import iTunesLibrary

// Protocol for iTunes application queries
@objc fileprivate protocol iTunesApplication {
Expand Down Expand Up @@ -280,18 +281,18 @@ class iTunesHelper: PlayerHelper, LikablePlayerHelper, InternalPlayerHelper, Lik

extension ITLibMediaItem {
// TODO: constrain protocl to mediaKindSong items

var song: Song {
return Song(address: self.location?.path ?? "", // TODO: check for remote tracks
name: self.title,
artist: self.artist?.name ?? "",
album: self.album.title ?? "",
duration: Double(self.totalTime))
name: self.title,
artist: self.artist?.name ?? "",
album: self.album.title ?? "",
duration: Double(self.totalTime))
}
}

extension ITLibPlaylist {

var playlist: Playlist {
return Playlist(id: self.persistentID.stringValue,
name: self.name,
Expand Down
5 changes: 1 addition & 4 deletions Muse/Sources/Views/TouchBarMaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,7 @@ extension WindowController: NSTouchBarDelegate {
}

func openPopoverBar(_ sender: NSButton) {
NSTouchBar.presentSystemModalFunctionBar(
popoverBar,
systemTrayItemIdentifier: NSTouchBarItemIdentifier.soundPopoverButton.rawValue
)
popoverBar?.presentAsSystemModal(forItemIdentifier: .soundPopoverButton)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Muse/Sources/Views/WindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class WindowController: NSWindowController, NSWindowDelegate, SliderDelegate {

let controlStripItem = NSControlStripTouchBarItem(identifier: .controlStripButton)

weak var controlStripButton: NSCustomizableButton? {
var controlStripButton: NSCustomizableButton? {
set {
controlStripItem.view = newValue!
}
Expand Down
17 changes: 11 additions & 6 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
PODS:
- MASPreferences (1.3)
- Sparkle (1.18.1)
- SpotifyKit (0.0.4)
- Sparkle (1.20.0)
- SpotifyKit (0.0.5)

DEPENDENCIES:
- MASPreferences
- Sparkle
- SpotifyKit (from `https://github.com/xzzz9097/SpotifyKit.git`)

SPEC REPOS:
https://github.com/cocoapods/specs.git:
- MASPreferences
- Sparkle

EXTERNAL SOURCES:
SpotifyKit:
:git: https://github.com/xzzz9097/SpotifyKit.git

CHECKOUT OPTIONS:
SpotifyKit:
:commit: f223e432c544189a5a43527ed0b5e4c832032d75
:commit: 7c39c1a4d4db97bc15e3b7952b963b595adcfec5
:git: https://github.com/xzzz9097/SpotifyKit.git

SPEC CHECKSUMS:
MASPreferences: c08b8622dd17b47da87669e741efd7c92e970e8c
Sparkle: 06ea33170007c5937ee54da481b4481af98fac79
SpotifyKit: 2c4aeac581823275b46169ba829b49e532979f6c
Sparkle: 48999e7ee032f05ca05e28451eadf4af8ede6b44
SpotifyKit: eea0876200c3b9deed7181bb53eb585a6125c830

PODFILE CHECKSUM: be0c2c61163df39d887731d268cf60f860911d15

COCOAPODS: 1.3.1
COCOAPODS: 1.5.3

0 comments on commit 0fdd666

Please sign in to comment.