Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI

/// Handles execution of `WindowAction`s on windows within the user's workspace
enum WindowEngine {
static var currentTask: Task<(), any Error>?
/// Resize a Window
/// - Parameters:
/// - window: Window to be resized
Expand All @@ -23,13 +24,16 @@ enum WindowEngine {
on screen: NSScreen,
completion: @escaping () -> () = {}
) {
Task.detached(priority: .userInitiated) {
currentTask?.cancel()
currentTask = Task.detached(priority: .userInitiated) {
await resize(
window,
to: action,
on: screen
)

try Task.checkCancellation()

completion()
}
}
Expand Down Expand Up @@ -222,10 +226,12 @@ enum WindowEngine {
try await window.setFrameAnimated(targetFrame, bounds: bounds)
} else {
window.setFrame(targetFrame, sizeFirst: willChangeScreens)
try Task.checkCancellation()
}

if !animate, !window.frame.approximatelyEqual(to: targetFrame) {
window.setFrame(targetFrame)
try Task.checkCancellation()
}

handleSizeConstrainedWindow(window: window, bounds: bounds)
Expand Down
1 change: 1 addition & 0 deletions Loop/Window Management/Window/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ final class Window {

try await withCheckedThrowingContinuation { (continuation: CheckedContinuation<(), Error>) in
Task {
try Task.checkCancellation()
let animation = WindowTransformAnimation(
rect,
window: self,
Expand Down