mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-28 23:54:32 +00:00
Update stuff for lock screen widget width
This commit is contained in:
parent
e32c863442
commit
ab6877e59c
7 changed files with 200 additions and 17 deletions
|
|
@ -10,6 +10,7 @@ import AppKit
|
|||
import SkyLightWindow
|
||||
import Defaults
|
||||
import QuartzCore
|
||||
import Combine
|
||||
|
||||
@MainActor
|
||||
final class LockScreenPanelAnimator: ObservableObject {
|
||||
|
|
@ -32,10 +33,12 @@ class LockScreenPanelManager {
|
|||
private var hideTask: Task<Void, Never>?
|
||||
private var screenChangeObserver: NSObjectProtocol?
|
||||
private var workspaceObservers: [NSObjectProtocol] = []
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private init() {
|
||||
print("[\(timestamp())] LockScreenPanelManager: initialized")
|
||||
registerScreenChangeObservers()
|
||||
observeDefaultChanges()
|
||||
}
|
||||
|
||||
private func timestamp() -> String {
|
||||
|
|
@ -118,8 +121,9 @@ class LockScreenPanelManager {
|
|||
panelAnimator.isPresented = false
|
||||
LockScreenTimerWidgetManager.shared.notifyMusicPanelFrameChanged(animated: false)
|
||||
|
||||
let hosting = NSHostingView(rootView: LockScreenMusicPanel(animator: panelAnimator))
|
||||
hosting.frame = NSRect(origin: .zero, size: targetFrame.size)
|
||||
let hosting = NSHostingView(rootView: LockScreenMusicPanel(animator: panelAnimator))
|
||||
hosting.frame = NSRect(origin: .zero, size: targetFrame.size)
|
||||
hosting.autoresizingMask = [.width, .height]
|
||||
window.contentView = hosting
|
||||
|
||||
// Ensure the underlying window content is clipped to rounded corners
|
||||
|
|
@ -235,6 +239,15 @@ class LockScreenPanelManager {
|
|||
print("[\(timestamp())] LockScreenPanelManager: realigned window due to \(reason)")
|
||||
}
|
||||
|
||||
private func observeDefaultChanges() {
|
||||
Defaults.publisher(.lockScreenMusicPanelWidth)
|
||||
.receive(on: RunLoop.main)
|
||||
.sink { [weak self] _ in
|
||||
self?.applyOffsetAdjustment(animated: true)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
private func collapsedFrame(for screenFrame: NSRect) -> NSRect {
|
||||
let collapsedSize = LockScreenMusicPanel.collapsedSize
|
||||
let originX = screenFrame.midX - (collapsedSize.width / 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue