Skip to content

Commit

Permalink
Maintain frames on space changes when not changing screens (#1372)
Browse files Browse the repository at this point in the history
* Only adjust frame when changing screens on space changes

* Remove unnecessary focus
  • Loading branch information
ianyh authored Apr 1, 2023
1 parent 19e93ab commit 7d38596
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
10 changes: 6 additions & 4 deletions Amethyst/Managers/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,12 @@ extension WindowManager: WindowTransitionTarget {
}
markScreen(screen, forReflowWithChange: .remove(window: window))
window.move(toSpace: targetSpace.id)
// necessary to set frame here as window is expected to be at origin relative to targe screen when moved, can be improved.
let newFrame = targetScreen.frameWithoutDockOrMenu()
DispatchQueue.main.sync {
window.setFrame(newFrame, withThreshold: CGSize(width: 25, height: 25))
if targetScreen.screenID() != screen.screenID() {
// necessary to set frame here as window is expected to be at origin relative to targe screen when moved, can be improved.
let newFrame = targetScreen.frameWithoutDockOrMenu()
DispatchQueue.main.sync {
window.setFrame(newFrame, withThreshold: CGSize(width: 25, height: 25))
}
}
markScreen(targetScreen, forReflowWithChange: .add(window: window))
if UserConfiguration.shared.followWindowsThrownBetweenSpaces() {
Expand Down
8 changes: 1 addition & 7 deletions Amethyst/Model/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,6 @@ extension AXWindow: WindowType {
}

func move(toSpace spaceID: CGSSpaceID) {
let ids = [cgID()]

CGSMoveWindowsToManagedSpace(CGSMainConnectionID(), ids as CFArray, spaceID)

if UserConfiguration.shared.followWindowsThrownBetweenSpaces() {
focus()
}
CGSMoveWindowsToManagedSpace(CGSMainConnectionID(), [cgID()] as CFArray, spaceID)
}
}

0 comments on commit 7d38596

Please sign in to comment.