forked from nikitabobko/AeroSpace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
6/n Use special "fullscreen windows" container for macOS native fulls…
…creen windows nikitabobko#18 Motivation: More typesafe and accurate tree structure
- Loading branch information
1 parent
8a8b482
commit 7b10b89
Showing
17 changed files
with
136 additions
and
65 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
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
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
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
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
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
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
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
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,41 @@ | ||
func normalizeLayoutReason() { | ||
for workspace in Workspace.all { | ||
let windows: [Window] = workspace.allLeafWindowsRecursive | ||
_normalizeLayoutReason(workspace: workspace, windows: windows) | ||
} | ||
_normalizeLayoutReason(workspace: Workspace.focused, windows: macosInvisibleWindowsContainer.children.filterIsInstance(of: Window.self)) | ||
} | ||
|
||
func _normalizeLayoutReason(workspace: Workspace, windows: [Window]) { | ||
for window in windows { | ||
let isMacosFullscreen = window.isMacosFullscreen | ||
let isMacosInvisible = !isMacosFullscreen && (window.isMacosMinimized || window.macAppUnsafe.nsApp.isHidden) | ||
switch window.layoutReason { | ||
case .standard: | ||
if isMacosFullscreen { | ||
window.layoutReason = .macos(prevParentKind: window.parent.kind) | ||
window.unbindFromParent() | ||
window.bind(to: workspace.macOsNativeFullscreenWindowsContainer, adaptiveWeight: 1, index: INDEX_BIND_LAST) | ||
} else if isMacosInvisible { | ||
window.layoutReason = .macos(prevParentKind: window.parent.kind) | ||
window.unbindFromParent() | ||
window.bind(to: macosInvisibleWindowsContainer, adaptiveWeight: 1, index: INDEX_BIND_LAST) | ||
} | ||
case .macos(let prevParentKind): | ||
if !isMacosFullscreen && !isMacosInvisible { | ||
window.layoutReason = .standard | ||
window.unbindFromParent() | ||
switch prevParentKind { | ||
case .workspace: | ||
window.bindAsFloatingWindow(to: workspace) | ||
case .tilingContainer: | ||
let data = getBindingDataForNewTilingWindow(workspace) | ||
window.bind(to: data.parent, adaptiveWeight: data.adaptiveWeight, index: data.index) | ||
case .macosInvisibleWindowsContainer, .macosFullscreenWindowsContainer: // wtf case, should never be possible. But If encounter it, let's just re-layout window | ||
let data = getBindingDataForNewWindow(window.asMacWindow().axWindow, workspace, window.macAppUnsafe) | ||
window.bind(to: data.parent, adaptiveWeight: data.adaptiveWeight, index: data.index) | ||
} | ||
} | ||
} | ||
} | ||
} |
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
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,8 @@ | ||
import Common | ||
|
||
/// The container for macOS fullscreen windows | ||
class MacosFullscreenWindowsContainer: TreeNode, NonLeafTreeNodeObject { | ||
init(parent: Workspace) { | ||
super.init(parent: parent, adaptiveWeight: 1, index: INDEX_BIND_LAST) | ||
} | ||
} |
Oops, something went wrong.