Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import ParcelCore
struct LayoutNoticePolicy { private var held: Bool private var tidyWindows: [WorkspaceKey: [WindowID: AppID]] = [:]
init(held: Bool) { self.held = held }
mutating func hold() { held = true tidyWindows.removeAll() }
mutating func commit(_ state: State) { held = false tidyWindows = state.workspaces.mapValues { workspace in Dictionary( uniqueKeysWithValues: workspace.order.compactMap { id in state.windows[id].map { (id, $0.app) } }) } }
mutating func resume() { held = false tidyWindows.removeAll() }
func allows(_ report: Report) -> Bool { !held }
mutating func allows(_ announcement: Announcement, state: State) -> Bool { guard !held else { return false } switch announcement { case .layoutChanged, .ratioChanged, .floatingChanged, .stackChanged, .windowCapChanged, .sizesReset, .undone: // An explicit edit ends the quiet baseline; focus and late minimum learning do not. tidyWindows.removeAll() case .windowsStacked(let window, _): guard let key = state.workspace(containing: window), let baseline = tidyWindows[key], let stack = state.workspaces[key]?.tree?.stacks.first(where: { $0.windows.contains(window) }) else { return true } return !stack.windows.allSatisfy { id in baseline[id] != nil && baseline[id] == state.windows[id]?.app } default: break } return true }}