From 3946cf0ad8185b4932372c1e98d9e9ff59642929 Mon Sep 17 00:00:00 2001 From: Niklas Rousset <75939868+niklasr22@users.noreply.github.com> Date: Sat, 11 Jan 2025 11:19:38 +0100 Subject: [PATCH] 196 move white pixel behind notch on macbooks (#198) * move get xdr displays function to utils and extract isBuiltInScreen function * move white pixel to horizontal center of screen when the pixel is on a built in screen * bump version --- BrightIntosh.xcodeproj/project.pbxproj | 16 ++++++++-------- BrightIntosh/BrightnessManager.swift | 12 ------------ BrightIntosh/OverlayWindow.swift | 3 +++ BrightIntosh/Utils.swift | 18 +++++++++++++++++- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/BrightIntosh.xcodeproj/project.pbxproj b/BrightIntosh.xcodeproj/project.pbxproj index a265d9a..5348010 100644 --- a/BrightIntosh.xcodeproj/project.pbxproj +++ b/BrightIntosh.xcodeproj/project.pbxproj @@ -392,7 +392,7 @@ CODE_SIGN_ENTITLEMENTS = BrightIntosh/BrightIntosh_SE.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 61; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 9K32WDUN2H; @@ -419,7 +419,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 3.5.1; + MARKETING_VERSION = 3.6.0; PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app; PRODUCT_NAME = BrightIntosh; SDKROOT = auto; @@ -444,7 +444,7 @@ CODE_SIGN_ENTITLEMENTS = BrightIntosh/BrightIntosh_SE.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 61; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 9K32WDUN2H; @@ -471,7 +471,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 3.5.1; + MARKETING_VERSION = 3.6.0; PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app; PRODUCT_NAME = BrightIntosh; SDKROOT = auto; @@ -494,7 +494,7 @@ CODE_SIGN_ENTITLEMENTS = BrightIntosh/BrightIntosh.entitlements; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 61; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 9K32WDUN2H; @@ -521,7 +521,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 3.5.1; + MARKETING_VERSION = 3.6.0; PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; @@ -545,7 +545,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 60; + CURRENT_PROJECT_VERSION = 61; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 9K32WDUN2H; @@ -572,7 +572,7 @@ LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks"; "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks"; MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 3.5.1; + MARKETING_VERSION = 3.6.0; PRODUCT_BUNDLE_IDENTIFIER = de.brightintosh.app; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; diff --git a/BrightIntosh/BrightnessManager.swift b/BrightIntosh/BrightnessManager.swift index 54e5b13..4b08fc5 100644 --- a/BrightIntosh/BrightnessManager.swift +++ b/BrightIntosh/BrightnessManager.swift @@ -142,15 +142,3 @@ class BrightnessManager { self.brightnessTechnique?.enable() } } - -func getXDRDisplays() -> [NSScreen] { - var xdrScreens: [NSScreen] = [] - for screen in NSScreen.screens { - let screenNumber = screen.deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] - let displayId: CGDirectDisplayID = screenNumber as! CGDirectDisplayID - if ((CGDisplayIsBuiltin(displayId) != 0 && isDeviceSupported()) || (externalXdrDisplays.contains(screen.localizedName) && !Settings.shared.brightIntoshOnlyOnBuiltIn)) { - xdrScreens.append(screen) - } - } - return xdrScreens -} diff --git a/BrightIntosh/OverlayWindow.swift b/BrightIntosh/OverlayWindow.swift index 823d3be..bc5a524 100644 --- a/BrightIntosh/OverlayWindow.swift +++ b/BrightIntosh/OverlayWindow.swift @@ -89,6 +89,9 @@ final class OverlayWindowController: NSWindowController, NSWindowDelegate { func getIdealPosition(screen: NSScreen) -> CGPoint { var position = screen.frame.origin + if isBuiltInScreen(screen: screen) { + position.x += screen.frame.width / 2 + } position.y += screen.frame.height - 1 return position } diff --git a/BrightIntosh/Utils.swift b/BrightIntosh/Utils.swift index 36fc772..381c9f3 100644 --- a/BrightIntosh/Utils.swift +++ b/BrightIntosh/Utils.swift @@ -5,9 +5,25 @@ // Created by Niklas Rousset on 01.01.24. // -import Foundation import IOKit import StoreKit +import Cocoa + +func getXDRDisplays() -> [NSScreen] { + var xdrScreens: [NSScreen] = [] + for screen in NSScreen.screens { + if ((isBuiltInScreen(screen: screen) && isDeviceSupported()) || (externalXdrDisplays.contains(screen.localizedName) && !Settings.shared.brightIntoshOnlyOnBuiltIn)) { + xdrScreens.append(screen) + } + } + return xdrScreens +} + +func isBuiltInScreen(screen: NSScreen) -> Bool { + let screenNumber = screen.deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] + let displayId: CGDirectDisplayID = screenNumber as! CGDirectDisplayID + return CGDisplayIsBuiltin(displayId) != 0 +} func getModelIdentifier() -> String? { let service = IOServiceGetMatchingService(