Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Various fixes and updates for Sequoia
  • Loading branch information
waydabber committed Oct 2, 2024
commit e4af9a55a31a9cc8b22f2e176fecdf17e0c107bd
48 changes: 32 additions & 16 deletions MonitorControl.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@
56754EA31D9A4016007BCDC5 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 0920;
LastUpgradeCheck = 1250;
LastUpgradeCheck = 1610;
ORGANIZATIONNAME = MonitorControl;
TargetAttributes = {
56754EAA1D9A4016007BCDC5 = {
Expand Down Expand Up @@ -521,6 +522,7 @@
/* Begin PBXShellScriptBuildPhase section */
28D1DE0C227FCFAF004CB494 /* [Format] Run SwiftFormat */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 12;
files = (
);
Expand All @@ -539,6 +541,7 @@
};
28F6A5802283515F00A4ADCD /* Increase Build Number */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -557,6 +560,7 @@
};
28F6A5822283548F00A4ADCD /* Sync Version Numbers */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand All @@ -575,6 +579,7 @@
};
6CB1BDB2253C7EBE00B52124 /* [Localization] Run BartyCrouch */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 12;
files = (
);
Expand All @@ -589,10 +594,11 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export PATH=\"$PATH:/opt/homebrew/bin\"\nif which bartycrouch > /dev/null; then\n bartycrouch update -x\n bartycrouch lint -x\nelse\n echo \"warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch\"\nfi\n";
shellScript = "echo Skipping bartycrouch\n# export PATH=\"$PATH:/opt/homebrew/bin\"\n# if which bartycrouch > /dev/null; then\n# bartycrouch update -x\n# bartycrouch lint -x\n# else\n# echo \"warning: BartyCrouch not installed, download it from https://github.com/Flinesoft/BartyCrouch\"\n# fi\n";
};
F03A8DF01FFB9D4C0034DC27 /* [Lint] Run SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 12;
files = (
);
Expand Down Expand Up @@ -769,6 +775,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -830,6 +837,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "-";
COPY_PHASE_STRIP = NO;
DEAD_CODE_STRIPPING = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -856,10 +864,12 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = MonitorControl/MonitorControlDebug.entitlements;
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1179;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 7100;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 299YSU96J7;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/**",
Expand All @@ -871,8 +881,8 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 4.2.1;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControl;
MARKETING_VERSION = 4.3.2;
PRODUCT_BUNDLE_IDENTIFIER = app.monitorcontrol.MonitorControl;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "MonitorControl/Support/Bridging-Header.h";
Expand All @@ -891,10 +901,12 @@
ARCHS = "$(ARCHS_STANDARD)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1179;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 7100;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 299YSU96J7;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(PROJECT_DIR)/**",
Expand All @@ -906,8 +918,8 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 4.2.1;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControl;
MARKETING_VERSION = 4.3.2;
PRODUCT_BUNDLE_IDENTIFIER = app.monitorcontrol.MonitorControl;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "MonitorControl/Support/Bridging-Header.h";
Expand All @@ -929,10 +941,12 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = MonitorControlHelper/MonitorControlHelper.entitlements;
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 631;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 7100;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 299YSU96J7;
ENABLE_HARDENED_RUNTIME = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MonitorControlHelper/Info.plist;
Expand All @@ -942,7 +956,7 @@
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 4.1.0;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControlHelper;
PRODUCT_BUNDLE_IDENTIFIER = app.monitorcontrol.MonitorControlHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.5;
Expand All @@ -958,10 +972,12 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = MonitorControlHelper/MonitorControlHelper.entitlements;
CODE_SIGN_IDENTITY = "-";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 631;
DEVELOPMENT_TEAM = "";
CURRENT_PROJECT_VERSION = 7100;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = 299YSU96J7;
ENABLE_HARDENED_RUNTIME = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = MonitorControlHelper/Info.plist;
Expand All @@ -971,7 +987,7 @@
);
MACOSX_DEPLOYMENT_TARGET = 10.14;
MARKETING_VERSION = 4.1.0;
PRODUCT_BUNDLE_IDENTIFIER = me.guillaumeb.MonitorControlHelper;
PRODUCT_BUNDLE_IDENTIFIER = app.monitorcontrol.MonitorControlHelper;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 5.5;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1610"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions MonitorControl/Enums/PrefKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ enum MenuIcon: Int {
}

enum MenuItemStyle: Int {
case text = 0
case icon = 1
case icon = 0
case text = 1
case hide = 2
}

Expand Down
4 changes: 2 additions & 2 deletions MonitorControl/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>7052</string>
<string>7104</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand All @@ -33,7 +33,7 @@
<key>SUEnableJavaScript</key>
<true/>
<key>SUFeedURL</key>
<string>https://monitorcontrol.app/appcast.xml</string>
<string>https://monitorcontrol.app/appcast2.xml</string>
<key>SUPublicEDKey</key>
<string>KuISgz+2n2/qnP/Rom5nWYAp+Pru+U3UtnAlnUjj6Pw=</string>
</dict>
Expand Down
3 changes: 1 addition & 2 deletions MonitorControl/Model/AppleDisplay.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ class AppleDisplay: Display {
guard !self.isDummy else {
return
}
self.displayQueue.sync {
_ = self.displayQueue.sync {
DisplayServicesSetBrightness(self.identifier, value)
DisplayServicesBrightnessChanged(self.identifier, Double(value))
}
}

Expand Down
5 changes: 4 additions & 1 deletion MonitorControl/Support/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {

@objc func quitClicked(_: AnyObject) {
os_log("Quit clicked", type: .info)
NSApplication.shared.terminate(self)
menu.closeMenu()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
NSApplication.shared.terminate(self)
}
}

@objc func prefsClicked(_: AnyObject) {
Expand Down
2 changes: 1 addition & 1 deletion MonitorControl/Support/Arm64DDC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Arm64DDC: NSObject {
}
if !reply.isEmpty {
usleep(readSleepTime ?? 50000)
if IOAVServiceReadI2C(service, UInt32(ARM64_DDC_7BIT_ADDRESS), UInt32(dataAddress), &reply, UInt32(reply.count)) == 0 {
if IOAVServiceReadI2C(service, UInt32(ARM64_DDC_7BIT_ADDRESS), 0, &reply, UInt32(reply.count)) == 0 {
success = self.checksum(chk: 0x50, data: &reply, start: 0, end: reply.count - 2) == reply[reply.count - 1]
}
}
Expand Down
4 changes: 3 additions & 1 deletion MonitorControl/Support/Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ extern IOReturn IOAVServiceReadI2C(IOAVService service, uint32_t chipAddress, ui
extern IOReturn IOAVServiceWriteI2C(IOAVService service, uint32_t chipAddress, uint32_t dataAddress, void* inputBuffer, uint32_t inputBufferSize);
extern CFDictionaryRef CoreDisplay_DisplayCreateInfoDictionary(CGDirectDisplayID);

extern void DisplayServicesBrightnessChanged(CGDirectDisplayID display, double brightness);
extern int DisplayServicesGetBrightness(CGDirectDisplayID display, float *brightness);
extern int DisplayServicesSetBrightness(CGDirectDisplayID display, float brightness);
extern int DisplayServicesGetLinearBrightness(CGDirectDisplayID display, float *brightness);
extern int DisplayServicesSetLinearBrightness(CGDirectDisplayID display, float brightness);

extern void CGSServiceForDisplayNumber(CGDirectDisplayID display, io_service_t* service);

bool CGSIsHDREnabled(CGDirectDisplayID display) __attribute__((weak_import));
bool CGSIsHDRSupported(CGDirectDisplayID display) __attribute__((weak_import));

@class NSString;

@protocol OSDUIHelperProtocol
Expand Down
10 changes: 6 additions & 4 deletions MonitorControl/Support/DisplayManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,17 @@ class DisplayManager {
}

static func isAppleDisplay(displayID: CGDirectDisplayID) -> Bool {
if #available(macOS 15.0, *) {
if CGDisplayVendorNumber(displayID) != 1552, CGSIsHDRSupported(displayID), CGSIsHDREnabled(displayID) {
return CGDisplayIsBuiltin(displayID) != 0
}
}
var brightness: Float = -1
let ret = DisplayServicesGetBrightness(displayID, &brightness)
if ret == 0, brightness >= 0 { // If brightness read appears to be successful using DisplayServices then it should be an Apple display
return true
}
if CGDisplayIsBuiltin(displayID) != 0 { // If built-in display then it should be Apple (except for hackintosh notebooks...)
return true
}
return false
return CGDisplayIsBuiltin(displayID) != 0 // If built-in display, it should be Apple
}

static func getByDisplayID(displayID: CGDirectDisplayID) -> NSScreen? {
Expand Down
12 changes: 8 additions & 4 deletions MonitorControl/Support/MenuHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class MenuHandler: NSMenu, NSMenuDelegate {
app.keyboardShortcuts.disengage()
}

func closeMenu() {
self.cancelTrackingWithoutAnimation()
}

func updateMenus(dontClose: Bool = false) {
os_log("Menu update initiated", type: .info)
if !dontClose {
Expand Down Expand Up @@ -210,7 +214,7 @@ class MenuHandler: NSMenu, NSMenuDelegate {

func addDefaultMenuOptions() {
if !DEBUG_MACOS10, #available(macOS 11.0, *), prefs.integer(forKey: PrefKey.menuItemStyle.rawValue) == MenuItemStyle.icon.rawValue {
let iconSize = CGFloat(22)
let iconSize = CGFloat(18)
let viewWidth = max(130, self.size.width)
var compensateForBlock: CGFloat = 0
if viewWidth > 230 { // if there are display blocks, we need to compensate a bit for the negative inset of the blocks
Expand All @@ -226,7 +230,7 @@ class MenuHandler: NSMenu, NSMenuDelegate {
preferencesIcon.image = NSImage(systemSymbolName: "gearshape", accessibilityDescription: NSLocalizedString("Preferences…", comment: "Shown in menu"))
preferencesIcon.alternateImage = NSImage(systemSymbolName: "gearshape.fill", accessibilityDescription: NSLocalizedString("Preferences…", comment: "Shown in menu"))
preferencesIcon.alphaValue = 0.3
preferencesIcon.frame = NSRect(x: menuItemView.frame.maxX - iconSize * 3 - 30 - 16 + compensateForBlock, y: menuItemView.frame.origin.y + 5, width: iconSize, height: iconSize)
preferencesIcon.frame = NSRect(x: menuItemView.frame.maxX - iconSize * 3 - 20 - 17 + compensateForBlock, y: menuItemView.frame.origin.y + 5, width: iconSize, height: iconSize)
preferencesIcon.imageScaling = .scaleProportionallyUpOrDown
preferencesIcon.action = #selector(app.prefsClicked)

Expand All @@ -239,7 +243,7 @@ class MenuHandler: NSMenu, NSMenuDelegate {
updateIcon.alternateImage = NSImage(systemSymbolName: symbolName + ".fill", accessibilityDescription: NSLocalizedString("Check for updates…", comment: "Shown in menu"))

updateIcon.alphaValue = 0.3
updateIcon.frame = NSRect(x: menuItemView.frame.maxX - iconSize * 2 - 10 - 16 + compensateForBlock, y: menuItemView.frame.origin.y + 5, width: iconSize, height: iconSize)
updateIcon.frame = NSRect(x: menuItemView.frame.maxX - iconSize * 2 - 14 - 17 + compensateForBlock, y: menuItemView.frame.origin.y + 5, width: iconSize, height: iconSize)
updateIcon.imageScaling = .scaleProportionallyUpOrDown
updateIcon.action = #selector(app.updaterController.checkForUpdates(_:))
updateIcon.target = app.updaterController
Expand All @@ -252,7 +256,7 @@ class MenuHandler: NSMenu, NSMenuDelegate {
quitIcon.image = NSImage(systemSymbolName: symbolName, accessibilityDescription: NSLocalizedString("Quit", comment: "Shown in menu"))
quitIcon.alternateImage = NSImage(systemSymbolName: symbolName + ".fill", accessibilityDescription: NSLocalizedString("Quit", comment: "Shown in menu"))
quitIcon.alphaValue = 0.3
quitIcon.frame = NSRect(x: menuItemView.frame.maxX - iconSize - 16 + compensateForBlock, y: menuItemView.frame.origin.y + 5, width: iconSize, height: iconSize)
quitIcon.frame = NSRect(x: menuItemView.frame.maxX - iconSize - 17 + compensateForBlock, y: menuItemView.frame.origin.y + 5, width: iconSize, height: iconSize)
quitIcon.imageScaling = .scaleProportionallyUpOrDown
quitIcon.action = #selector(app.quitClicked)

Expand Down
Loading