Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 Fix window moving off-screen #567

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Loop/Window Management/WindowEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,17 @@ enum WindowEngine {
return
}

// If the window is being moved via shortcuts (move right, move left etc.), then the screenFrame will be zero.
// This is because the window *can* be moved off-screen in this case.
let screenFrame = action.direction.willMove ? .zero : screen.safeScreenFrame
let usePadding = Defaults[.enablePadding] && (Defaults[.paddingMinimumScreenSize] == 0 || screen.diagonalSize > Defaults[.paddingMinimumScreenSize])

let bounds = if Defaults[.enablePadding],
Defaults[.paddingMinimumScreenSize] == 0 || screen.diagonalSize > Defaults[.paddingMinimumScreenSize] {
Defaults[.padding].apply(on: screenFrame)
// If the window is being moved via shortcuts (move right, move left etc.), then the bounds will be zero.
// This is because the window *can* be moved off-screen in this case.
// Otherwise padding will be applied if needed.
let bounds = if action.direction.willMove {
CGRect.zero
} else if usePadding {
Defaults[.padding].apply(on: screen.safeScreenFrame)
} else {
screenFrame
screen.safeScreenFrame
}

window.setFrame(
Expand Down
Loading