Skip to content

Commit

Permalink
Merge pull request #810 from glouel/master
Browse files Browse the repository at this point in the history
Disable video format choice on < 10.13
  • Loading branch information
glouel authored Jun 11, 2019
2 parents c8386f5 + b54461a commit 4152d8f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 25 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1169,15 +1169,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta3;
CURRENT_PROJECT_VERSION = 1.5.1beta4;
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.1beta3;
MARKETING_VERSION = 1.5.1beta4;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -1198,15 +1198,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application: Guillaume Louel (3L54M5L5KK)";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.5.1beta3;
CURRENT_PROJECT_VERSION = 1.5.1beta4;
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.1beta3;
MARKETING_VERSION = 1.5.1beta4;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
8 changes: 7 additions & 1 deletion Aerial/Source/Controllers/PWC Tabs/PWC+Videos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ extension PreferencesWindowController {
rightArrowKeyPlaysNextCheckbox.state = .off
}

popupVideoFormat.selectItem(at: preferences.videoFormat!)
if #available(OSX 10.13, *) {
popupVideoFormat.selectItem(at: preferences.videoFormat!)
} else {
preferences.videoFormat = Preferences.VideoFormat.v1080pH264.rawValue
popupVideoFormat.selectItem(at: preferences.videoFormat!)
popupVideoFormat.isEnabled = false
}

alternatePopupVideoFormat.selectItem(at: preferences.alternateVideoFormat!)

Expand Down
2 changes: 1 addition & 1 deletion Aerial/Source/Controllers/Preferences.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ final class Preferences {
defaultValues[.verticalMargin] = 0
defaultValues[.synchronizedMode] = false
defaultValues[.aspectMode] = AspectMode.fill
defaultValues[.useHDR] = true
defaultValues[.useHDR] = false

// Set today's date as default
let dateFormatter = DateFormatter()
Expand Down
40 changes: 21 additions & 19 deletions Aerial/Source/Models/DisplayDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Screen: NSObject {
var isMain: Bool
var backingScaleFactor: CGFloat

init(id: CGDirectDisplayID, width: Int, height: Int, bottomLeftFrame: CGRect, isMain: Bool) {
init(id: CGDirectDisplayID, width: Int, height: Int, bottomLeftFrame: CGRect, isMain: Bool, backingScaleFactor: CGFloat) {
self.id = id
self.width = width
self.height = height
Expand All @@ -29,7 +29,7 @@ class Screen: NSObject {
y: bottomLeftFrame.origin.y + CGFloat(height))
self.zeroedOrigin = CGPoint(x: 0, y: 0)
self.isMain = isMain
self.backingScaleFactor = 1
self.backingScaleFactor = backingScaleFactor
}

override var description: String {
Expand Down Expand Up @@ -73,40 +73,42 @@ final class DisplayDetection: NSObject {

_ = CGGetOnlineDisplayList(maxDisplays, &onlineDisplays, &displayCount)
debugLog("\(displayCount) display(s) detected")
var mainID: CGDirectDisplayID?

for currentDisplay in onlineDisplays[0..<Int(displayCount)] {
let isMain = CGDisplayIsMain(currentDisplay)

var rect = CGDisplayBounds(currentDisplay)
if isMain == 0 {
rect = convertTopLeftToBottomLeft(rect: rect)
} else {
if isMain == 1 {
// We calculate the equivalent of a centimeter in points on the main screen as a reference
let mmsize = CGDisplayScreenSize(currentDisplay)
let wide = CGDisplayPixelsWide(currentDisplay)
cmInPoints = CGFloat(wide) / CGFloat(mmsize.width) * 10
debugLog("1cm = \(cmInPoints) points")
mainID = currentDisplay
}

// 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),
bottomLeftFrame: rect, isMain: isMain == 1 ? true : false))
//debugLog("pass1: id \(currentDisplay), width: \(CGDisplayPixelsWide(currentDisplay)), height: \(CGDisplayPixelsHigh(currentDisplay)),isMain isMain \(isMain)")
}

// 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)
let screenID = screen.deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as! CGDirectDisplayID

if dscreen != nil {
dscreen?.backingScaleFactor = screen.backingScaleFactor
} else {
debugLog("Unkown screen on second pass please report")
var thisIsMain = false
if screenID == mainID {
thisIsMain = true
}

debugLog("npass: dict \(screen.deviceDescription)")
debugLog(" bottomLeftFrame \(screen.frame)")

screens.append(Screen(id: screenID,
width: Int(screen.frame.width),
height: Int(screen.frame.height),
bottomLeftFrame: screen.frame,
isMain: thisIsMain,
backingScaleFactor: screen.backingScaleFactor))
}

// Before we finish, we calculate the origin of each screen from a 0,0 perspective
Expand Down

0 comments on commit 4152d8f

Please sign in to comment.