Skip to content

Commit

Permalink
3.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
glouel committed Feb 5, 2024
1 parent a324df9 commit 8ba3ab2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Aerial.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3249,15 +3249,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.3.5;
CURRENT_PROJECT_VERSION = 3.3.7;
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.3.5;
MARKETING_VERSION = 3.3.7;
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -3278,15 +3278,15 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3.3.5;
CURRENT_PROJECT_VERSION = 3.3.7;
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.3.5;
MARKETING_VERSION = 3.3.7;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = com.johncoates.Aerial;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
12 changes: 10 additions & 2 deletions Aerial/Source/Models/Hardware/DisplayDetection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ final class DisplayDetection: NSObject {
return nil
}

func alternateFindScreenWith(frame: CGRect, backingScaleFactor: CGFloat) -> Screen? {
debugLog("📺☢️ fs : \(frame.size.debugDescription) bsf : \(backingScaleFactor)")
func alternateFindScreenWith(frame: CGRect) -> Screen? {
debugLog("📺☢️ fs : \(frame.size.debugDescription)")
// 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

Expand All @@ -266,6 +266,14 @@ final class DisplayDetection: NSObject {

return nil
}

func markScreenAsUsed(id: CGDirectDisplayID) {
// remove the screen from the unused list
debugLog("pre filter \(unusedScreens.count)")
let filteredScreens = unusedScreens.filter { $0.id != id }
unusedScreens = filteredScreens
debugLog("post filter \(unusedScreens.count)")
}

// Calculate the size of the global screen (the composite of all the displays attached)
func getGlobalScreenRect() -> CGRect {
Expand Down
18 changes: 15 additions & 3 deletions Aerial/Source/Views/AerialView+Player.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,30 @@ 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)
debugLog("foundScreen check : \(foundScreen.debugDescription)")

if let scr = foundScreen {
let tRect = CGRect(x: zRect.origin.x - scr.zeroedOrigin.x,
y: zRect.origin.y - scr.zeroedOrigin.y,
width: zRect.width,
height: zRect.height)
debugLog("tRect : \(tRect)")
playerLayer.frame = tRect
} else {
errorLog("This is an unknown screen in span mode, this is not good")
playerLayer.frame = layer.bounds
debugLog("This is an unknown screen in span mode, workarounding...")

if let alternateScreen = DisplayDetection.sharedInstance.alternateFindScreenWith(frame: self.frame) {
foundScreen = alternateScreen
debugLog("📺 alternate screen found : \(alternateScreen.description)")
let tRect = CGRect(x: zRect.origin.x - alternateScreen.zeroedOrigin.x,
y: zRect.origin.y - alternateScreen.zeroedOrigin.y,
width: zRect.width,
height: zRect.height)
playerLayer.frame = tRect
} else {
errorLog("No alternate screen found, reverting to single screen mode")
playerLayer.frame = layer.bounds
}
}
} else {
playerLayer.frame = layer.bounds
Expand Down
32 changes: 23 additions & 9 deletions Aerial/Source/Views/AerialView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,20 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {

override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
debugLog("🖼️ \(self.description) viewDidMoveToWindow frame: \(self.frame) window: \(self.window)")
debugLog(self.window?.screen.debugDescription ?? "Unknown")

if let thisScreen = self.window?.screen {
matchScreen(thisScreen: thisScreen)
if foundScreen != nil {
debugLog("🖼️ \(self.description) viewDidMoveToWindow frame: \(self.frame) window: \(String(describing: self.window))")
debugLog(self.window?.screen.debugDescription ?? "Unknown")

if let thisScreen = self.window?.screen {
matchScreen(thisScreen: thisScreen)
} else {
// For some reason we may not have a screen here!
debugLog("🖼️ no screen attached, will try again later")
}
} else {
// For some reason we may not have a screen here!
debugLog("🖼️ no screen attached, will try again later")
debugLog("🖼️ wdmtw after we already have a screen, ignoring")
}

}

func matchScreen(thisScreen: NSScreen) {
Expand All @@ -429,10 +434,19 @@ final class AerialView: ScreenSaverView, CAAnimationDelegate {
debugLog(screenID.description)

foundScreen = DisplayDetection.sharedInstance.findScreenWith(id: screenID)
foundFrame = foundScreen?.bottomLeftFrame

if let foundScreen = foundScreen {
foundFrame = foundScreen.bottomLeftFrame
if #available(macOS 14, *) {
self.frame = foundFrame!

// remove it from the list of unused screens
DisplayDetection.sharedInstance.markScreenAsUsed(id: screenID)
}
}

debugLog("🖼️🌾 Using : \(String(describing: foundScreen))")
debugLog("🥬🌾 window.screen \(String(describing: self.window?.screen.debugDescription))")
debugLog("🖼️🌾 self.frame : \(String(describing: self.frame))")
}

// Handle window resize
Expand Down

0 comments on commit 8ba3ab2

Please sign in to comment.