Skip to content

Commit

Permalink
WIP b5
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Aug 13, 2023
1 parent 037c614 commit e407f37
Show file tree
Hide file tree
Showing 11 changed files with 95 additions and 37 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Expand Up @@ -3241,15 +3241,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.2.7beta4;
CURRENT_PROJECT_VERSION = 3.2.7beta5a5;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 3.2.7beta4;
MARKETING_VERSION = 3.2.7beta5a5;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -3270,15 +3270,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.2.7beta4;
CURRENT_PROJECT_VERSION = 3.2.7beta5a5;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 3L54M5L5KK;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/Resources/Old stuff/Info.plist";
INSTALL_PATH = "$(HOME)/Library/Screen Savers";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 3.2.7beta4;
MARKETING_VERSION = 3.2.7beta5a5;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>
13 changes: 13 additions & 0 deletions Aerial/Source/Header.h
@@ -0,0 +1,13 @@
//
// Header.h
// Aerial
//
// Created by Guillaume Louel on 26/07/2023.
// Copyright © 2023 Guillaume Louel. All rights reserved.
//

#ifndef Header_h
#define Header_h


#endif /* Header_h */
2 changes: 1 addition & 1 deletion Aerial/Source/Models/Downloads/DownloadManager.swift
Expand Up @@ -178,7 +178,7 @@ extension DownloadOperation: URLSessionTaskDelegate {
} else if folder == "tvOS 12" {
FileHelpers.unTar(file: destinationDirectory.appending("/resources.tar"), atPath: destinationDirectory)
} else if folder == "macOS 14b1" {
FileHelpers.unTar(file: destinationDirectory.appending("/resources-14-0.tar"), atPath: destinationDirectory)
FileHelpers.unTar(file: destinationDirectory.appending("/resources-14-0-3.tar"), atPath: destinationDirectory)
}

debugLog("Finished downloading \(task.originalRequest!.url!.absoluteString)")
Expand Down
40 changes: 33 additions & 7 deletions Aerial/Source/Models/Hardware/DisplayDetection.swift
Expand Up @@ -42,6 +42,8 @@ final class DisplayDetection: NSObject {
static let sharedInstance = DisplayDetection()

var screens = [Screen]()
var unusedScreens = [Screen]()

var cmInPoints: CGFloat = 40
var maxLeftScreens: CGFloat = 0
var maxBelowScreens: CGFloat = 0
Expand All @@ -52,18 +54,23 @@ final class DisplayDetection: NSObject {
// MARK: - Lifecycle
override init() {
super.init()
debugLog("Display Detection initialized")
debugLog("📺 Display Detection initialized")
detectDisplays()
}

func resetUnusedScreens() {
debugLog("📺 reset unused screens")
unusedScreens = screens
debugLog("📺☢️ s \(screens.count) us \(unusedScreens.count)")
}

// MARK: - Detection
func detectDisplays() {
// Display detection is done in two passes :
// - Through CGDisplay, we grab all online screens (connected, but
// may or may not be powered on !) and get most information needed
// - Through NSScreen to get the backingScaleFactor (retinaness of a screen)

debugLog("***Display Detection***")
// Cleanup a bit in case of redetection
screens = [Screen]()
maxLeftScreens = 0
Expand Down Expand Up @@ -100,9 +107,6 @@ final class DisplayDetection: NSObject {
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),
Expand All @@ -120,11 +124,13 @@ final class DisplayDetection: NSObject {
}

for screen in screens {
debugLog("\(screen)")
debugLog("📺 found \(screen)")
}

// We store the list to pluck it later
unusedScreens = screens

debugLog("\(getGlobalScreenRect())")
debugLog("***Display Detection Done***")
}

func getScreenCount() -> Int {
Expand Down Expand Up @@ -232,6 +238,26 @@ final class DisplayDetection: NSObject {

return nil
}

func alternateFindScreenWith(frame: CGRect, backingScaleFactor: CGFloat) -> Screen? {
debugLog("📺☢️ fs : \(frame.size.debugDescription) bsf : \(backingScaleFactor)")
// This is a really simple workaround, we look at the size only, and with the screen list in reverse which seems to kindaaaa match ?
// We temporarily ignore bsf as we may not be able to access view.window this early it seems

debugLog("📺☢️ s \(screens.count) us \(unusedScreens.count)")

for i in (0 ..< unusedScreens.count).reversed() {
if unusedScreens[i].bottomLeftFrame.size == frame.size {
let foundScreen = unusedScreens[i]
unusedScreens.remove(at: i)
debugLog("foundScreen : \(foundScreen.bottomLeftFrame.debugDescription)")
return foundScreen
}
}

return nil
}


func findScreenWith(id: CGDirectDisplayID) -> Screen? {
for screen in screens where screen.id == id {
Expand Down
2 changes: 1 addition & 1 deletion Aerial/Source/Models/Sources/SourceList.swift
Expand Up @@ -18,7 +18,7 @@ struct SourceList {
// This is the current one until next fall
static let macOS14 = Source(name: "macOS 14b1",
description: "High framerate videos from macOS 14 Sonoma",
manifestUrl: "https://sylvan.apple.com/itunes-assets/Aerials126/v4/82/2e/34/822e344c-f5d2-878c-3d56-508d5b09ed61/resources-14-0.tar",
manifestUrl: "https://sylvan.apple.com/itunes-assets/Aerials126/v4/82/2e/34/822e344c-f5d2-878c-3d56-508d5b09ed61/resources-14-0-3.tar",
type: .tvOS12,
scenes: [.nature, .city, .space, .sea],
isCachable: true,
Expand Down
4 changes: 2 additions & 2 deletions Aerial/Source/Views/AerialView+Player.swift
Expand Up @@ -40,8 +40,8 @@ extension AerialView {
// In case of span mode we need to compute the size of our layer
if PrefsDisplays.viewingMode == .spanned && !isPreview {
let zRect = displayDetection.getZeroedActiveSpannedRect()
let screen = displayDetection.findScreenWith(frame: self.frame)
if let scr = screen {
//let screen = displayDetection.findScreenWith(frame: self.frame)
if let scr = foundScreen {
let tRect = CGRect(x: zRect.origin.x - scr.zeroedOrigin.x,
y: zRect.origin.y - scr.zeroedOrigin.y,
width: zRect.width,
Expand Down
44 changes: 29 additions & 15 deletions Aerial/Source/Views/AerialView.swift
Expand Up @@ -36,10 +36,15 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
var brightnessToRestore: Float?

var globalSpeed: Float = 1.0

var globalPause = false

// We use this for tentative Catalina bug workaround
var originalWidth, originalHeight: CGFloat

// We use this for tentative Sonoma bug workaround
var foundScreen: Screen?
var foundFrame: NSRect?

// Tentative improvement when only one video in playlist
var shouldLoop = false

Expand Down Expand Up @@ -114,13 +119,7 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
// MARK: - Init / Setup
// This is the one used by System Preferences/ScreenSaverEngine
override init?(frame: NSRect, isPreview: Bool) {
// First thing, we migrate preferences if needed
Aerial.helper.checkCompanion()
/*if !Aerial.helper.underCompanion && !Aerial.helper.appMode {
Aerial.helper.migratePreferences()
} else {
debugLog("Not migrating under companion")
}*/

// Clear log if > 1MB on startup
rollLogIfNeeded()
Expand Down Expand Up @@ -156,13 +155,7 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
required init?(coder: NSCoder) {
Aerial.helper.appMode = true

// First thing, we migrate preferences if needed
Aerial.helper.checkCompanion()
/*if !Aerial.helper.underCompanion && !Aerial.helper.appMode {
Aerial.helper.migratePreferences()
} else {
debugLog("Not migrating under companion")
}*/

// Clear log if > 1MB on startup
rollLogIfNeeded()
Expand Down Expand Up @@ -264,13 +257,31 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
// We look for the screen in our detected list.
// In case of preview or unknown screen result will be nil
let displayDetection = DisplayDetection.sharedInstance
let thisScreen = displayDetection.findScreenWith(frame: self.frame)

let screenCount = displayDetection.getScreenCount()
debugLog("🖼️ Real screen count : \(screenCount)")

debugLog("🥬 window \(String(describing: self.window))")

var thisScreen: Screen? = nil
if #available(macOS 14.0, *) {
thisScreen = displayDetection.alternateFindScreenWith(frame: self.frame, backingScaleFactor: self.window?.backingScaleFactor ?? 1)
} else {
thisScreen = displayDetection.findScreenWith(frame: self.frame)
}

// We note the foundFrame as this is more accurate than the reported one! We need this for coordinates mapping
if let thisScreen = thisScreen {
foundFrame = thisScreen.bottomLeftFrame
foundScreen = thisScreen
}


var localPlayer: AVPlayer?
debugLog("🖼️ Using : \(String(describing: thisScreen))")

debugLog("🥬 window.screen \(String(describing: self.window?.screen))")

// Is the current screen disabled by user ?
if !isPreview {
// If it's an unknown screen, we leave it enabled
Expand Down Expand Up @@ -423,6 +434,7 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
}
}


teardown()
}

Expand Down Expand Up @@ -470,7 +482,7 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
}

debugLog("🖼️ start playback: \(frame) \(bounds) rate: \(player.rate)")

debugLog("🥬🥬 window2 \(String(describing: window?.screen))")
// If we share a player, we need to add the fades and the text to all the
// instanciated views using it (eg: in mirrored mode)
if AerialView.sharingPlayers {
Expand Down Expand Up @@ -573,6 +585,8 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
}

@objc func willStop(_ aNotification: Notification) {
DisplayDetection.sharedInstance.resetUnusedScreens()

if #available(macOS 14.0, *) {
debugLog("🖼️ 📢📢📢 🖼️ 📢📢📢 ☢️sonoma☢️ workaround IGNORING willStop")
} else {
Expand Down
6 changes: 3 additions & 3 deletions Resources/MainUI/Settings panels/AdvancedViewController.xib
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22113.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22152" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22113.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22152"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down Expand Up @@ -453,7 +453,7 @@
<rect key="frame" x="1" y="461" width="809" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="0.9850746268656716" horizontal="NO" id="68Y-fx-VNM">
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="0.89552238805970152" horizontal="NO" id="68Y-fx-VNM">
<rect key="frame" x="794" y="1" width="16" height="476"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
Expand Down
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22113.1" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22152" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22113.1"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22152"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down
4 changes: 2 additions & 2 deletions Resources/MainUI/Settings panels/OverlaysViewController.xib
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22113.3" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22152" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22113.3"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22152"/>
<capability name="Image references" minToolsVersion="12.0"/>
<capability name="System colors introduced in macOS 10.14" minToolsVersion="10.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand Down

0 comments on commit e407f37

Please sign in to comment.