Skip to content

Commit

Permalink
6.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alin23 committed Jul 18, 2024
1 parent 83578b8 commit c1f4461
Show file tree
Hide file tree
Showing 26 changed files with 732 additions and 422 deletions.
2 changes: 1 addition & 1 deletion .gitsecret/paths/mapping.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Lunar/Resources/eddsa_priv:d079018c2b1c003c9e239ea8f8cc999b7d98adfd0616911ba0263
Lunar/Modes/SensorMode.swift:63d6565bb8194d89abaa7998c640d3aebe8aa33edcaf687c0f5d385c5ad5f0eb
Lunar/Modes/SyncMode.swift:27e971941b4ac3e19cb91406272eae328bbc494df4039ef8d8175cd2ad07b4e8
Lunar/Modes/LocationMode.swift:33f47b5788bdf89d343a5b64b64f132972b591195f716eac55091dea289b16ee
Lunar/Data/Pro.swift:9e2871a3eeef10e28a91dcae49e7a25e055eadb26b10f9da16ca49676cd78356
Lunar/Data/Pro.swift:916b1eafc94adeefba4229cd855c9828e1db2222ee3d36c4476da6f76e367977
Lunar/Modes/ClockMode.swift:ebda9ca5622a46e1d7435504dc225df496fa824900a1521b71518cf8799922f6
Lunar/DDC/DDC2.h:a6502f46ad8551d91300a58ff27b471352b827a10b73ff3fb62d76a10a315e1d
Lunar/DDC/DDC2.c:8488fdfb13ca9525e44db616c773eb67f1f1d52dcf83115d7666b0d79bbeef5a
Expand Down
8 changes: 4 additions & 4 deletions Lunar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6.7.14b2;
CURRENT_PROJECT_VERSION = 6.8.0;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
Expand Down Expand Up @@ -1370,7 +1370,7 @@
);
LLVM_LTO = YES_THIN;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 6.7.14b2;
MARKETING_VERSION = 6.8.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = fyi.lunar.Lunar;
Expand Down Expand Up @@ -1403,7 +1403,7 @@
CODE_SIGN_INJECT_BASE_ENTITLEMENTS = NO;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6.7.14b2;
CURRENT_PROJECT_VERSION = 6.8.0;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = RDDXV84A73;
Expand Down Expand Up @@ -1434,7 +1434,7 @@
);
LLVM_LTO = YES;
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 6.7.14b2;
MARKETING_VERSION = 6.8.0;
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CODE_SIGN_FLAGS = "--timestamp";
PRODUCT_BUNDLE_IDENTIFIER = fyi.lunar.Lunar;
Expand Down
4 changes: 4 additions & 0 deletions Lunar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2484,6 +2484,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate, CLLocationManagerDeleg
NotificationCenter.default.post(name: displayListChanged, object: nil)
let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "6"
log.info("App finished launching v\(version)")

if !thisIsFirstRun {
DC.askAboutXDR(migration: true)
}
}

@IBAction func toggleCleaningMode(_: Any) {
Expand Down
4 changes: 2 additions & 2 deletions Lunar/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -7263,8 +7263,8 @@ when FaceLight is activated</string>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="clipping" alignment="center" title="⚫︎" id="7EB-Iv-y9Y">
<font key="font" metaFont="system" size="6"/>
<color key="textColor" red="0.5" green="0.5" blue="0.5" alpha="1.0" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.5" green="0.5" blue="0.5" alpha="1.0" colorSpace="custom" customColorSpace="sRGB"/>
<color key="textColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="backgroundColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</textFieldCell>
</textField>
</subviews>
Expand Down
6 changes: 5 additions & 1 deletion Lunar/Controllers/OnboardPageController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ final class OnboardWindowController: ModernWindowController, NSWindowDelegate {
appDelegate!.screenObserver?.cancel()
appDelegate!.screenObserver = nil

guard !clickedSkipButton else { return }
guard !clickedSkipButton else {
DC.askAboutXDR()
return
}
skip?()

guard !useOnboardingForDiagnostics else { return }
completeOnboarding()
DC.askAboutXDR()
}

func completeOnboarding() {
Expand Down
11 changes: 7 additions & 4 deletions Lunar/DDC/DDC.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ let DDC_MIN_REPLY_DELAY_AMD = 30_000_000
let DDC_MIN_REPLY_DELAY_INTEL = 1
let DDC_MIN_REPLY_DELAY_NVIDIA = 1

let DUMMY_VENDOR_IDS: [UInt32] = [0xF0F0, 0x896]
@inline(__always)
func isDummyDisplayID(_ id: UInt32) -> Bool {
id == 0xF0F0 || id == 0x896
}

// MARK: - DDCReadResult

Expand Down Expand Up @@ -1024,7 +1027,7 @@ enum DDC {
}

#if DEBUG
// return displayIDs
// return displayIDs
if !displayIDs.isEmpty {
// displayIDs.append(TEST_DISPLAY_PERSISTENT_ID)
return displayIDs
Expand Down Expand Up @@ -1071,7 +1074,7 @@ enum DDC {

let realName = (name ?? Display.printableName(id)).lowercased()
let vendorID = CGDisplayVendorNumber(id)
return (realName =~ Display.dummyNamePattern || DUMMY_VENDOR_IDS.contains(vendorID)) && vendorID != Display.Vendor.samsung.rawValue
return (realName =~ Display.dummyNamePattern || isDummyDisplayID(vendorID)) && vendorID != Display.Vendor.samsung.rawValue
.u32 && realName !~ Display.notDummyNamePattern
}

Expand All @@ -1082,7 +1085,7 @@ enum DDC {

let realName = (name ?? Display.printableName(id)).lowercased()
let vendorID = CGDisplayVendorNumber(id)
return realName =~ Display.notDummyNamePattern && DUMMY_VENDOR_IDS.contains(vendorID)
return realName =~ Display.notDummyNamePattern && isDummyDisplayID(vendorID)
}

static func isVirtualDisplay(_ id: CGDirectDisplayID, name: String? = nil, checkName: Bool = true) -> Bool {
Expand Down
16 changes: 9 additions & 7 deletions Lunar/DDC/Lunar-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ extern CGError SLSGetDisplayMenubarHeight(uint32_t did, uint32_t *height);

CGRect display_manager_menu_bar_rect(uint32_t did)
{
CGRect bounds = {};

uint32_t height = 0;
SLSGetDisplayMenubarHeight(did, &height);

bounds = CGDisplayBounds(did);
bounds.size.height = height;
CGRect bounds = CGDisplayBounds(did);

if (@available(macOS 12.0, *)) {
uint32_t height = 0;
SLSGetDisplayMenubarHeight(did, &height);
bounds.size.height = height;
} else {
bounds.size.height = 24;
}

//
// NOTE(koekeishiya): Height needs to be offset by 1 because that is the actual
Expand Down
2 changes: 2 additions & 0 deletions Lunar/Data/DataStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ let APP_SETTINGS: [Defaults.Keys] = [
.showNitsOSD,
.showStandardPresets,
.showCustomPresets,
.hidePresetsOnSingleDisplay,
.showXDRSelector,
.showHeaderOnHover,
.showFooterOnHover,
Expand Down Expand Up @@ -408,6 +409,7 @@ final class DataStore: NSObject {
static func firstRun() {
log.debug("First run")
thisIsFirstRun = true
Defaults[.newXDRMode] = true
}

func displays(serials: [String]? = nil) -> [Display]? {
Expand Down
3 changes: 2 additions & 1 deletion Lunar/Data/Display.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,7 @@ let AUDIO_IDENTIFIER_UUID_PATTERN = "([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{4})-[0
DS_LOGGER.debug("Ignoring brightness change notification. Reason: \(reason, privacy: .public)")
return
}
display.lastNativeBrightness = value

guard !display.inSmoothTransition, !display.isBuiltin || !DC.lidClosed else {
let reason = if DC.activeDisplays[id]?.inSmoothTransition ?? false {
Expand All @@ -3576,7 +3577,7 @@ let AUDIO_IDENTIFIER_UUID_PATTERN = "([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{4})-[0
}

DS_LOGGER.debug("newBrightness: \(newBrightness, privacy: .public) display.isUserAdjusting: \(display.isUserAdjusting(), privacy: .public)")
display.lastNativeBrightness = value

display.withoutDisplayServices {
display.brightness = newBrightness.ns
}
Expand Down
Binary file modified Lunar/Data/Pro.swift.secret
Binary file not shown.
65 changes: 44 additions & 21 deletions Lunar/SwiftUIViews/AdvancedSettingsView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import Defaults
import SwiftUI

struct SettingsHeader: View {
let text: String

var body: some View {
Text(text)
.font(.system(size: 13, weight: .semibold, design: .rounded))
.foregroundColor(.blackish.opacity(0.5))
}
}

struct AdvancedSettingsView: View {
@ObservedObject var dc: DisplayController = DC

Expand Down Expand Up @@ -35,8 +45,10 @@ struct AdvancedSettingsView: View {
var body: some View {
ZStack {
Color.clear.frame(maxWidth: .infinity, alignment: .leading)
VStack(alignment: .leading) {
VStack(alignment: .leading, spacing: 5) {
Group {
SettingsHeader(text: "BlackOut")

#if arch(arm64)
if #available(macOS 13, *) {
SettingsToggle(
Expand Down Expand Up @@ -98,7 +110,10 @@ struct AdvancedSettingsView: View {
)
}
#endif
Divider()
Divider().opacity(0.6).padding(.vertical, 2)
}
Group {
SettingsHeader(text: "MacBook")

SettingsToggle(
text: "Use workaround for built-in display", setting: $workaroundBuiltinDisplay,
Expand All @@ -121,18 +136,11 @@ struct AdvancedSettingsView: View {
setting: $clamshellModeDetection
)
}
SettingsToggle(
text: "Re-apply last brightness on screen wake", setting: $reapplyValuesAfterWake,
help: """
On each screen wake/reconnection, Lunar will try to
re-apply previous brightness and contrast 3 times.
Disable this if system appears slow on screen wake.
"""
)
}
Divider()
Divider().opacity(0.6).padding(.vertical, 2)
Group {
SettingsHeader(text: "DDC")

SettingsToggle(
text: "Enable rotation hotkeys",
setting: $enableOrientationHotkeys,
Expand Down Expand Up @@ -172,15 +180,30 @@ struct AdvancedSettingsView: View {
"""
)
}
SettingsToggle(
text: "Check for network light sensors periodically", setting: $sensorCheckerEnabled,
help: """
To enable "Sensor Mode", Lunar periodically checks if a wireless light
sensor is available using local DNS requests. You can disable this if
you never intend to use a wireless ambient light sensor.
"""
)
Divider()
Divider().opacity(0.6).padding(.vertical, 2)
Group {
SettingsHeader(text: "Other")

SettingsToggle(
text: "Re-apply last brightness on screen wake", setting: $reapplyValuesAfterWake,
help: """
On each screen wake/reconnection, Lunar will try to
re-apply previous brightness and contrast 3 times.
Disable this if system appears slow on screen wake.
"""
)

SettingsToggle(
text: "Check for network light sensors periodically", setting: $sensorCheckerEnabled,
help: """
To enable "Sensor Mode", Lunar periodically checks if a wireless light
sensor is available using local DNS requests. You can disable this if
you never intend to use a wireless ambient light sensor.
"""
)
}
Divider().opacity(0.6).padding(.vertical, 2)
Group {
Text("EXPERIMENTAL!")
.foregroundColor(Color.red)
Expand Down
78 changes: 77 additions & 1 deletion Lunar/SwiftUIViews/DisplayRowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ struct DisplayRowView: View {
@Default(.syncNits) var syncNits
#endif

@Default(.askedAboutXDR) var askedAboutXDR
@Default(.newXDRMode) var newXDRMode
@Default(.showInputInQuickActions) var showInputInQuickActions
@Default(.showPowerInQuickActions) var showPowerInQuickActions
@Default(.showXDRSelector) var showXDRSelector
Expand Down Expand Up @@ -172,6 +174,74 @@ struct DisplayRowView: View {
}
}

@ViewBuilder var newSdrXdrSelector: some View {
let color = Color.bg.warm.opacity(colorScheme == .dark ? 0.8 : 0.4)
HStack(spacing: 2) {
SwiftUI.Button("SDR") {
guard display.enhanced || display.fullRange else { return }
withAnimation(.fastSpring) {
if display.enhanced {
display.enhanced = false
}
if display.fullRange {
display.fullRange = false
}
}
}
.buttonStyle(PickerButton(
onColor: Color.warmBlack.opacity(hoveringXDRSelector || !dimNonEssentialUI ? 1.0 : 0.2), offColor: color.opacity(0.4), enumValue: .oneway { display.enhanced || display.fullRange }, onValue: false
))
.font(.system(size: 10, weight: display.enhanced ? .semibold : .bold, design: .monospaced))

if display.supportsFullRangeXDR {
SwiftUI.Button("XDR") {
guard proactive else {
showNeedsLunarProForFullRange = true
return
}
guard fullRangeTipShown || askedAboutXDR else {
fullRangeTipShown = true
showFullRangeTip = true
return
}

guard !km.controlKeyPressed else {
showFullRangeTip = true
return
}

if display.enhanced {
display.enhanced = false
}

withAnimation(.easeInOut(duration: 0.3)) { display.fullRange.toggle() }
}
.buttonStyle(PickerButton(
onColor: Color.fg.primary.opacity(hoveringXDRSelector || !dimNonEssentialUI ? 0.7 : 0.2),
offColor: color.opacity(0.4), onTextColor: .bg.primary, radius: 6, enumValue: $display.fullRange, onValue: true
))
.font(.system(size: 10, weight: display.fullRange ? .bold : .semibold, design: .rounded))
.popover(isPresented: $showNeedsLunarProForFullRange) { NeedsLunarProView() }
.popover(isPresented: $showFullRangeTip) { FullRangeTipView() }
}
}
.padding(2)
.background(RoundedRectangle(cornerRadius: 8, style: .continuous).fill(color))
.overlay(
RoundedRectangle(cornerRadius: 8, style: .continuous)
.trim(from: 0.0, to: display.fullRange ? 1.0 : 0.0)
.stroke(Color.fg.primary.opacity(0.7), lineWidth: 3)
.scaleEffect(x: 0.98, y: 0.95, anchor: .center)
)
.padding(.bottom, 2)
.opacity(hoveringXDRSelector || !dimNonEssentialUI ? 1 : 0.15)
.onHover { hovering in
withAnimation(.fastTransition) {
hoveringXDRSelector = hovering
}
}
}

@ViewBuilder var sdrXdrSelector: some View {
let color = Color.bg.warm.opacity(colorScheme == .dark ? 0.8 : 0.4)
HStack(spacing: 2) {
Expand Down Expand Up @@ -524,7 +594,13 @@ struct DisplayRowView: View {
sliders
adaptiveState
volumeSlider
if xdrSelectorShown { sdrXdrSelector }
if xdrSelectorShown {
if newXDRMode, display.isBuiltin, display.supportsFullRangeXDR {
newSdrXdrSelector
} else {
sdrXdrSelector
}
}
appPresetAdaptivePaused
} else {
lockedPresetView
Expand Down
Loading

0 comments on commit c1f4461

Please sign in to comment.