-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
5/n Reorganize FrozenTreeNode and closedWindowsCache
- Loading branch information
1 parent
15ec7d0
commit 82ec7be
Showing
3 changed files
with
56 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import AppKit | ||
import Common | ||
|
||
enum FrozenTreeNode { | ||
case container(FrozenContainer) | ||
case window(FrozenWindow) | ||
} | ||
|
||
struct FrozenContainer { | ||
let children: [FrozenTreeNode] | ||
let layout: Layout | ||
let orientation: Orientation | ||
let weight: CGFloat | ||
|
||
init(_ container: TilingContainer) { | ||
children = container.children.map { | ||
switch $0.nodeCases { | ||
case .window(let w): .window(FrozenWindow(w)) | ||
case .tilingContainer(let c): .container(FrozenContainer(c)) | ||
case .workspace, | ||
.macosMinimizedWindowsContainer, | ||
.macosHiddenAppsWindowsContainer, | ||
.macosFullscreenWindowsContainer, | ||
.macosPopupWindowsContainer: | ||
illegalChildParentRelation(child: $0, parent: container) | ||
} | ||
} | ||
layout = container.layout | ||
orientation = container.orientation | ||
weight = getWeightOrNil(container) ?? 1 | ||
} | ||
} | ||
|
||
struct FrozenWindow { | ||
let id: UInt32 | ||
let weight: CGFloat | ||
|
||
init(_ window: Window) { | ||
id = window.windowId | ||
weight = getWeightOrNil(window) ?? 1 | ||
} | ||
} | ||
|
||
private func getWeightOrNil(_ node: TreeNode) -> CGFloat? { | ||
((node.parent as? TilingContainer)?.orientation).map { node.getWeight($0) } | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters