Skip to content

Commit

Permalink
Merge pull request #806 from glouel/master
Browse files Browse the repository at this point in the history
1.5.1beta2
  • Loading branch information
glouel authored Jun 6, 2019
2 parents 1768cee + aa27f45 commit f46a887
Show file tree
Hide file tree
Showing 13 changed files with 201 additions and 129 deletions.
27 changes: 20 additions & 7 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@
CreatedOnToolsVersion = 7.0;
DevelopmentTeam = 3L54M5L5KK;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
};
};
Expand Down Expand Up @@ -770,7 +770,7 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-AerialApp/Pods-AerialApp-frameworks.sh",
"${PODS_ROOT}/Target Support Files/Pods-AerialApp/Pods-AerialApp-frameworks.sh",
"${PODS_ROOT}/Sparkle/Sparkle.framework",
"${PODS_ROOT}/Sparkle/Sparkle.framework.dSYM",
);
Expand All @@ -781,7 +781,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AerialApp/Pods-AerialApp-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-AerialApp/Pods-AerialApp-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
7E9B50FB2187D302002895ED /* Run Script - Swiftlint */ = {
Expand Down Expand Up @@ -1083,6 +1083,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -1102,6 +1103,7 @@
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
OTHER_SWIFT_FLAGS = "-D DEBUG";
SDKROOT = macosx;
SWIFT_VERSION = 4.2;
Expand Down Expand Up @@ -1137,6 +1139,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
Expand All @@ -1149,6 +1152,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
SDKROOT = macosx;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2;
Expand All @@ -1162,14 +1166,18 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta2;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.5.1beta2;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1187,14 +1195,19 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = NO;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Mac Developer";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta2;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.9;
MARKETING_VERSION = 1.5.1beta2;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
22 changes: 18 additions & 4 deletions Aerial/App/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!
lazy var preferencesWindowController: PreferencesWindowController = PreferencesWindowController()
//lazy var preferencesWindowController: PreferencesWindowController = PreferencesWindowController()
var preferencesWindowController: PreferencesWindowController

/*func applicationWillTerminate(_ notification: Notification) {
debugLog("Received application will terminate")
preferencesWindowController.close(self)
}*/

override init() {
preferencesWindowController = PreferencesWindowController()
print("pwc : \(preferencesWindowController)")
super.init()

}

func applicationDidFinishLaunching(_ notification: Notification) {

let objects = objectsFromNib(loadNibNamed: "PreferencesWindow")
preferencesWindowController.appMode = true
// We need to find the correct window in our nib
Expand Down Expand Up @@ -47,10 +56,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
private func objectsFromNib(loadNibNamed nibName: String) -> [AnyObject] {
let bundle = Bundle.main
var topLevelObjects: NSArray? = NSArray()
bundle.loadNibNamed(NSNib.Name(nibName),
owner: preferencesWindowController,
topLevelObjects: &topLevelObjects)
print("bundle \(bundle)")

let res = Bundle.main.loadNibNamed(nibName, owner: preferencesWindowController, topLevelObjects: &topLevelObjects)

/*let res = bundle.loadNibNamed(nibName,
owner: preferencesWindowController,
topLevelObjects: &topLevelObjects)
*/
print("res")
return topLevelObjects! as [AnyObject]
}
}
6 changes: 6 additions & 0 deletions Aerial/Source/Controllers/PWC Tabs/PWC+Displays.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ extension PreferencesWindowController {
// Displays Tab
newDisplayModePopup.selectItem(at: preferences.newDisplayMode!)
newViewingModePopup.selectItem(at: preferences.newViewingMode!)
aspectModePopup.selectItem(at: preferences.aspectMode!)

if preferences.newDisplayMode == Preferences.NewDisplayMode.selection.rawValue {
displayInstructionLabel.isHidden = false
Expand Down Expand Up @@ -54,6 +55,11 @@ extension PreferencesWindowController {
}
}

@IBAction func aspectModePopupClick(_ sender: NSPopUpButton) {
debugLog("UI aspectModeClick: \(sender.indexOfSelectedItem)")
preferences.aspectMode = sender.indexOfSelectedItem
}

@IBAction func horizontalDisplayMarginChange(_ sender: NSTextField) {
debugLog("UI horizontalDisplayMarginChange \(sender.stringValue)")
preferences.horizontalMargin = sender.doubleValue
Expand Down
19 changes: 17 additions & 2 deletions Aerial/Source/Controllers/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ final class Preferences {
case verticalMargin = "verticalMargin"

case synchronizedMode = "synchronizedMode"
case aspectMode = "aspectMode"
}

enum AspectMode: Int {
case fill, fit
}

enum NewDisplayMode: Int {
Expand Down Expand Up @@ -187,8 +192,8 @@ final class Preferences {
defaultValues[.extraFontName] = "Monaco"
defaultValues[.extraFontSize] = 28
defaultValues[.extraCorner] = ExtraCorner.same
defaultValues[.debugMode] = false
defaultValues[.logToDisk] = false
defaultValues[.debugMode] = true
defaultValues[.logToDisk] = true
defaultValues[.versionCheck] = VersionCheck.weekly
defaultValues[.alsoVersionCheckBeta] = false
defaultValues[.latitude] = ""
Expand Down Expand Up @@ -222,6 +227,7 @@ final class Preferences {
defaultValues[.horizontalMargin] = 0
defaultValues[.verticalMargin] = 0
defaultValues[.synchronizedMode] = false
defaultValues[.aspectMode] = AspectMode.fill

// Set today's date as default
let dateFormatter = DateFormatter()
Expand Down Expand Up @@ -276,6 +282,15 @@ final class Preferences {
}
}

var aspectMode: Int? {
get {
return optionalValue(forIdentifier: .aspectMode)
}
set {
setValue(forIdentifier: .aspectMode, value: newValue)
}
}

var newDisplayMode: Int? {
get {
return optionalValue(forIdentifier: .newDisplayMode)
Expand Down
2 changes: 2 additions & 0 deletions Aerial/Source/Controllers/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
@IBOutlet var displayInstructionLabel: NSTextField!
@IBOutlet var newDisplayModePopup: NSPopUpButton!
@IBOutlet var newViewingModePopup: NSPopUpButton!
@IBOutlet var aspectModePopup: NSPopUpButton!

@IBOutlet var displayMarginBox: NSBox!
@IBOutlet var horizontalDisplayMarginTextfield: NSTextField!
Expand Down Expand Up @@ -308,6 +309,7 @@ final class PreferencesWindowController: NSWindowController, NSOutlineViewDataSo
} else if let version = Bundle(identifier: "com.JohnCoates.Aerial")?.infoDictionary?["CFBundleShortVersionString"] as? String {
versionButton.title = version
}
debugLog("Aerial control panel V\(versionButton.title)")

setupVideosTab()
setupDisplaysTab()
Expand Down
60 changes: 25 additions & 35 deletions Aerial/Source/Models/Cache/VideoCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,66 +40,56 @@ final class VideoCache {
}

if cacheDirectory == nil {
let localCachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
.localDomainMask,
true)
let userCachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
.userDomainMask,
true)

if localCachePaths.isEmpty || userCachePaths.isEmpty {
debugLog("userCachePath : \(userCachePaths)")
if userCachePaths.isEmpty {
errorLog("Couldn't find cache paths!")
return nil
}

let localCacheDirectory = localCachePaths[0] as NSString
let userCacheDirectory = userCachePaths[0] as NSString
if #available(OSX 10.15, *) {
} else {
// Still look for /Library for pre Catalina OS
let localCachePaths = NSSearchPathForDirectoriesInDomains(.cachesDirectory,
.localDomainMask,
true)
let localCacheDirectory = localCachePaths[0] as NSString
if aerialCacheExists(at: localCacheDirectory) {
debugLog("local cache exists")
cacheDirectory = localCacheDirectory.appendingPathComponent("Aerial")
}
}

if aerialCacheExists(at: localCacheDirectory) {
debugLog("local cache exists")
cacheDirectory = localCacheDirectory.appendingPathComponent("Aerial")
} else if aerialCacheExists(at: userCacheDirectory) {
if cacheDirectory == nil && aerialCacheExists(at: userCacheDirectory) {
debugLog("user cache exists")
cacheDirectory = userCacheDirectory.appendingPathComponent("Aerial")
} else {
debugLog("create local cache")
// We create in local cache directory (/Library/Caches)
cacheDirectory = localCacheDirectory.appendingPathComponent("Aerial")
debugLog("create user cache")
// We create in user cache directory (~/Library/Caches)
cacheDirectory = userCacheDirectory.appendingPathComponent("Aerial")

let fileManager = FileManager.default
var didCreate = true
if fileManager.fileExists(atPath: cacheDirectory!) == false {
do {
try fileManager.createDirectory(atPath: cacheDirectory!,
withIntermediateDirectories: false, attributes: nil)
} catch let error {
errorLog("Couldn't create cache directory in Library: \(error)")
didCreate = false
}
}

if !didCreate {
// Last ditch effort, probably the user has some restriction on its account,
// so we try creating in its user directory as a fallback
cacheDirectory = userCacheDirectory.appendingPathComponent("Aerial")

let fileManager = FileManager.default
if fileManager.fileExists(atPath: cacheDirectory!) == false {
do {
try fileManager.createDirectory(atPath: cacheDirectory!,
withIntermediateDirectories: false, attributes: nil)
} catch let error {
errorLog("Couldn't create cache directory in user Library: \(error)")
errorLog("FATAL : There's nothing more we can do at this point")
return nil
}
errorLog("Couldn't create cache directory in User directory: \(error)")
errorLog("FATAL : There's nothing more we can do at this point")
return nil
}
}
}
}

// Cache the computed value
computedCacheDirectory = cacheDirectory

// Save it
preferences.customCacheDirectory = computedCacheDirectory
preferences.synchronize()
debugLog("cache to be used : \(String(describing: cacheDirectory))")
return cacheDirectory
}
Expand Down
4 changes: 4 additions & 0 deletions Aerial/Source/Models/DisplayDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ final class DisplayDetection: NSObject {
cmInPoints = CGFloat(wide) / CGFloat(mmsize.width) * 10
debugLog("1cm = \(cmInPoints) points")
}
// swiftlint:disable:next line_length
debugLog("pass1: id \(currentDisplay), width: \(CGDisplayPixelsWide(currentDisplay)), height: \(CGDisplayPixelsHigh(currentDisplay)), bottomLeftFrame: \(rect), isMain isMain \(isMain)")
screens.append(Screen(id: currentDisplay,
width: CGDisplayPixelsWide(currentDisplay),
height: CGDisplayPixelsHigh(currentDisplay),
Expand All @@ -95,6 +97,8 @@ final class DisplayDetection: NSObject {

// Second pass on NSScreen to grab the retina factor
for screen in NSScreen.screens {
debugLog("pass2: dict \(screen.deviceDescription)")
debugLog(" bottomLeftFrame \(screen.frame)")
let dscreen = findScreenWith(frame: screen.frame)

if dscreen != nil {
Expand Down
Loading

0 comments on commit f46a887

Please sign in to comment.