Skip to content

Commit

Permalink
Bring back removeDuplicates() by republishing on every display refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
OCJvanDijk committed Apr 15, 2020
1 parent 8aa53a0 commit ea7679c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions Brightness Sync/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}
.switchToLatest()
.removeDuplicates()
.multicast(subject: PassthroughSubject())

// There is a quirk in CoreDisplay, that causes the builtin display to read a brightness value of 1.0 just after you closed the lid and enter clamshell mode.
Expand Down Expand Up @@ -239,12 +240,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let builtin = allDisplays.first { CGDisplayIsBuiltin($0) == 1 }
let targets = allDisplays.filter { lgDisplayIdentifiers.contains(DisplayIdentifier(vendorNumber: CGDisplayVendorNumber($0), modelNumber: CGDisplayModelNumber($0))) }

if builtin != sourceDisplayPublisher.value {
sourceDisplayPublisher.send(builtin)
}
if targets != targetDisplaysPublisher.value {
targetDisplaysPublisher.send(targets)
}
sourceDisplayPublisher.send(builtin)
targetDisplaysPublisher.send(targets)
}

static let maxDisplays: UInt32 = 8
Expand Down

0 comments on commit ea7679c

Please sign in to comment.