Skip to content

Commit

Permalink
Fix overlays showing on wrong screens
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Oct 6, 2023
1 parent 010869b commit f9c8fdb
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 29 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.7beta10;
CURRENT_PROJECT_VERSION = 3.3.3;
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.7beta10;
MARKETING_VERSION = 3.3.3;
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.7beta10;
CURRENT_PROJECT_VERSION = 3.3.3;
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.7beta10;
MARKETING_VERSION = 3.3.3;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
20 changes: 19 additions & 1 deletion Aerial/Source/Models/Sources/Source.swift
Expand Up @@ -439,7 +439,7 @@ struct Source: Codable {
var processedVideos: [AerialVideo] = []

for asset in videoManifest.assets {
let (isDupe, _) = SourceInfo.findDuplicate(id: asset.id, url1080pH264: asset.url1080H264 ?? "")
let (isDupe, foundVideo) = SourceInfo.findDuplicate(id: asset.id, url1080pH264: asset.url1080H264 ?? "")

if !isDupe {
let video = AerialVideo(id: asset.id,
Expand All @@ -454,6 +454,24 @@ struct Source: Codable {
communityPoi: PoiStringProvider.sharedInstance.getCommunityPoi(id: asset.id))

processedVideos.append(video)
} else {
// Merge urls with macOS manifest
let assetURLs = urlsFor(asset)
if foundVideo?.urls[.v4KHDR] == "" {
foundVideo?.urls[.v4KHDR] = assetURLs[.v4KHDR]
}
if foundVideo?.urls[.v4KHEVC] == "" {
foundVideo?.urls[.v4KHEVC] = assetURLs[.v4KHEVC]
}
if foundVideo?.urls[.v1080pHDR] == "" {
foundVideo?.urls[.v1080pHDR] = assetURLs[.v1080pHDR]
}
if foundVideo?.urls[.v1080pHEVC] == "" {
foundVideo?.urls[.v1080pHEVC] = assetURLs[.v1080pHEVC]
}
if foundVideo?.urls[.v1080pH264] == "" {
foundVideo?.urls[.v1080pH264] = assetURLs[.v1080pH264]
}
}
}

Expand Down
39 changes: 24 additions & 15 deletions Aerial/Source/Views/AerialView+Player.swift
Expand Up @@ -69,7 +69,12 @@ extension AerialView {


// The layers for descriptions, clock, message
layerManager.setupExtraLayers(layer: layer, frame: self.frame)
// On Sonoma we can't use the reported frame!
if foundFrame != nil {
layerManager.setupExtraLayers(layer: layer, frame: foundFrame!)
} else {
layerManager.setupExtraLayers(layer: layer, frame: self.frame)
}
// Make sure we set the retinaness here
layerManager.setContentScale(scale: self.window?.backingScaleFactor ?? 1.0)

Expand Down Expand Up @@ -114,20 +119,24 @@ extension AerialView {

// Video fade-in/out
func addPlayerFades(view: AerialView, player: AVPlayer, video: AerialVideo) {
// We only fade in/out if we have duration
if video.duration > 0 && AerialView.shouldFade && !shouldLoop {
let playbackSpeed = Double(PlaybackSpeed.forVideo(video.id))

view.playerLayer.opacity = 0
let fadeAnimation = CAKeyframeAnimation(keyPath: "opacity")
fadeAnimation.values = [0, 1, 1, 0] as [Int]
fadeAnimation.keyTimes = [0,
AerialView.fadeDuration/(video.duration/playbackSpeed),
1-(AerialView.fadeDuration/(video.duration/playbackSpeed)), 1 ] as [NSNumber]

fadeAnimation.duration = video.duration/playbackSpeed
fadeAnimation.calculationMode = CAAnimationCalculationMode.cubic
view.playerLayer.add(fadeAnimation, forKey: "mainfade")
if !Aerial.helper.underCompanion {
// We only fade in/out if we have duration
if video.duration > 0 && AerialView.shouldFade && !shouldLoop {
let playbackSpeed = Double(PlaybackSpeed.forVideo(video.id))

view.playerLayer.opacity = 0
let fadeAnimation = CAKeyframeAnimation(keyPath: "opacity")
fadeAnimation.values = [0, 1, 1, 0] as [Int]
fadeAnimation.keyTimes = [0,
AerialView.fadeDuration/(video.duration/playbackSpeed),
1-(AerialView.fadeDuration/(video.duration/playbackSpeed)), 1 ] as [NSNumber]

fadeAnimation.duration = video.duration/playbackSpeed
fadeAnimation.calculationMode = CAAnimationCalculationMode.cubic
view.playerLayer.add(fadeAnimation, forKey: "mainfade")
} else {
view.playerLayer.opacity = 1.0
}
} else {
view.playerLayer.opacity = 1.0
}
Expand Down
13 changes: 10 additions & 3 deletions Aerial/Source/Views/AerialView.swift
Expand Up @@ -626,8 +626,10 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {

@objc func onSleepNote(note: Notification) {
debugLog("🖼️ 📢📢📢 onSleepNote")
if #available(macOS 14.0, *) {
exit(0)
if !Aerial.helper.underCompanion {
if #available(macOS 14.0, *) {
exit(0)
}
}
}

Expand Down Expand Up @@ -889,7 +891,12 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
let fadeOutAnimation = CAKeyframeAnimation(keyPath: "opacity")
fadeOutAnimation.values = [1, 0] as [Int]
fadeOutAnimation.keyTimes = [0, AerialView.fadeDuration] as [NSNumber]
fadeOutAnimation.duration = AerialView.fadeDuration
if !Aerial.helper.underCompanion {
fadeOutAnimation.duration = AerialView.fadeDuration
} else {
fadeOutAnimation.values = [1, 1] as [Int]
fadeOutAnimation.duration = 0.1
}
fadeOutAnimation.delegate = self
fadeOutAnimation.isRemovedOnCompletion = false
fadeOutAnimation.calculationMode = CAAnimationCalculationMode.cubic
Expand Down
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22152" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22152"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
Expand Down
8 changes: 4 additions & 4 deletions Resources/MainUI/Settings panels/TimeViewController.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="22154" 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="22154"/>
<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 @@ -122,8 +122,8 @@
</connections>
</button>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="R2Z-La-EL1">
<rect key="frame" x="395" y="409" width="87" height="17"/>
<textFieldCell key="cell" controlSize="large" lineBreakMode="clipping" title="" id="vcy-lb-T6r">
<rect key="frame" x="395" y="409" width="4" height="17"/>
<textFieldCell key="cell" controlSize="large" lineBreakMode="clipping" id="vcy-lb-T6r">
<font key="font" metaFont="system" size="14"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down

0 comments on commit f9c8fdb

Please sign in to comment.