-
-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Aggregate focus events for sequence of commands
- Loading branch information
1 parent
0a7c6ec
commit 2accc42
Showing
27 changed files
with
113 additions
and
83 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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
struct FullscreenCommand: Command { | ||
func runWithoutLayout() { | ||
func runWithoutLayout(state: inout FocusState) { | ||
check(Thread.current.isMainThread) | ||
guard let window = focusedWindowOrEffectivelyFocused else { return } | ||
guard let window = state.window else { return } | ||
window.isFullscreen = !window.isFullscreen | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
struct WorkspaceBackAndForthCommand: Command { | ||
func runWithoutLayout() { | ||
func runWithoutLayout(state: inout FocusState) { | ||
check(Thread.current.isMainThread) | ||
guard let previousFocusedWorkspaceName else { return } | ||
WorkspaceCommand(workspaceName: previousFocusedWorkspaceName).runWithoutLayout() | ||
WorkspaceCommand(workspaceName: previousFocusedWorkspaceName).runWithoutLayout(state: &state) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,36 +1,19 @@ | ||
struct WorkspaceCommand : Command { | ||
let workspaceName: String | ||
|
||
func runWithoutLayout() { | ||
func runWithoutLayout(state: inout FocusState) { | ||
check(Thread.current.isMainThread) | ||
let workspace = Workspace.get(byName: workspaceName) | ||
// todo drop anyLeafWindowRecursive. It must not be necessary | ||
if let window = workspace.mostRecentWindow ?? workspace.anyLeafWindowRecursive { // switch to not empty workspace | ||
if !workspace.isVisible { // Only do it for invisible workspaces to avoid flickering when switch to already visible workspace | ||
// Make sure that stack of windows is correct from macOS perspective (important for closing windows) | ||
// Alternative: focus mru window in destroyedObs (con: flickering when windows are closed, because | ||
// focusedWindow is source of truth for workspaces) | ||
workspace.focusMruReversedRecursive() // todo try to reduce flickering | ||
} | ||
focusedWorkspaceSourceOfTruth = .macOs | ||
window.focus() | ||
state = .windowIsFocused(window) | ||
} else { // switch to empty workspace | ||
check(workspace.isEffectivelyEmpty) | ||
focusedWorkspaceSourceOfTruth = .ownModel | ||
state = .emptyWorkspaceIsFocused(workspaceName) | ||
} | ||
check(workspace.monitor.setActiveWorkspace(workspace)) | ||
focusedWorkspaceName = workspace.name | ||
} | ||
} | ||
|
||
private extension TreeNode { | ||
// todo Switch between workspaces can happen via cmd+tab. Maybe this functionality must be moved to refresh | ||
func focusMruReversedRecursive() { | ||
if let window = self as? Window { | ||
window.focus() | ||
} | ||
for child in mostRecentChildren.reversed() { | ||
child.focusMruReversedRecursive() | ||
} | ||
} | ||
} |
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
Oops, something went wrong.