From 47a530fd5cb4f466b52684e560234b7f0803d104 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 14 Jul 2021 22:01:42 -0400 Subject: [PATCH] Fixes LED ordering. Still work to do on capturing the proper window title. --- .../Documents/MachineDocument.swift | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index 12af69c58..40e2f79ca 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -153,9 +153,10 @@ class MachineDocument: func windowDidUpdate(_ notification: Notification) { if self.windowControllers.count > 0, let window = self.windowControllers[0].window, window.isVisible { // Grab the regular window title, if it's not already stored. - if self.unadornedWindowTitle.count == 0 { + if self.unadornedWindowTitle == "" { self.unadornedWindowTitle = window.title } + updateWindowTitle() // If an interaction mode is not yet in effect, pick the proper one and display the relevant thing. if self.interactionMode == .notStarted { @@ -743,20 +744,21 @@ class MachineDocument: private func updateActivityViewVisibility() { // If any LEDs are now visible, make sure the activity view is showing. // Otherwise, hide it. - let litLEDs = self.leds.filter { $0.value.isLit } - let window = self.windowControllers.first!.window! - if litLEDs.isEmpty || !window.styleMask.contains(.fullScreen) { - activityFader.animateOut(delay: window.styleMask.contains(.fullScreen) ? 0.2 : 0.0) - } else { - activityFader.animateIn() - } + if let window = self.windowControllers.first?.window { + let litLEDs = self.leds.filter { $0.value.isLit } + if litLEDs.isEmpty || !window.styleMask.contains(.fullScreen) { + activityFader.animateOut(delay: window.styleMask.contains(.fullScreen) ? 0.2 : 0.0) + } else { + activityFader.animateIn() + } - // Manipulate the window title. - windowLEDSuffix = "" - for led in self.leds { - windowLEDSuffix += " " + (led.value.isLit ? "■" : "□") + // Manipulate the window title. + windowLEDSuffix = "" + for ledName in machine.leds { + windowLEDSuffix += " " + (leds[ledName]!.isLit ? "■" : "□") + } + updateWindowTitle() } - updateWindowTitle() } // MARK: - In-window panels (i.e. options, volume).