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
2 changes: 1 addition & 1 deletion Loop/Preview Window/LuminarePreviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct LuminarePreviewView: View {
.offset(x: actionRect.minX, y: actionRect.minY)
.scaleEffect(CGSize(width: scale, height: scale))
.onAppear {
actionRect = action.getFrame(window: nil, bounds: .init(origin: .zero, size: geo.size))
actionRect = action.getFrame(window: nil, bounds: .init(origin: .zero, size: geo.size), isPreview: true)

withAnimation(
.interpolatingSpring(
Expand Down
3 changes: 2 additions & 1 deletion Loop/Preview Window/PreviewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ class PreviewController {
let targetWindowFrame = action.getFrame(
window: window,
bounds: screen.safeScreenFrame,
screen: screen
screen: screen,
isPreview: true
)
.flipY(maxY: NSScreen.screens[0].frame.maxY)

Expand Down
23 changes: 20 additions & 3 deletions Loop/Window Management/WindowAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct WindowAction: Codable, Identifiable, Hashable, Equatable, Defaults.Serial
return result.normalized()
}

func getFrame(window: Window?, bounds: CGRect, disablePadding: Bool = false, screen: NSScreen? = nil) -> CGRect {
func getFrame(window: Window?, bounds: CGRect, disablePadding: Bool = false, screen: NSScreen? = nil, isPreview: Bool = false) -> CGRect {
guard direction != .cycle, direction != .noAction else {
return NSRect(origin: bounds.center, size: .zero)
}
Expand All @@ -151,7 +151,7 @@ struct WindowAction: Codable, Identifiable, Hashable, Equatable, Defaults.Serial
LoopManager.sidesToAdjust = nil
}

result = calculateTargetFrame(direction, window, bounds)
result = calculateTargetFrame(direction, window, bounds, isPreview)

if !disablePadding {
// If window can't be resized, center it within the already-resized frame.
Expand All @@ -178,17 +178,28 @@ struct WindowAction: Codable, Identifiable, Hashable, Equatable, Defaults.Serial
// MARK: - Window Frame Calculations

private extension WindowAction {
func calculateTargetFrame(_ direction: WindowDirection, _ window: Window?, _ bounds: CGRect) -> CGRect {
func calculateTargetFrame(_ direction: WindowDirection, _ window: Window?, _ bounds: CGRect, _ isPreview: Bool) -> CGRect {
var result: CGRect = .zero

if direction.frameMultiplyValues != nil {
result = applyFrameMultiplyValues(bounds)

} else if direction.willAdjustSize {
// Return final frame of preview
if Defaults[.previewVisibility], !isPreview {
return LoopManager.lastTargetFrame
}

let frameToResizeFrom = LoopManager.lastTargetFrame

result = calculateSizeAdjustment(frameToResizeFrom, bounds)

} else if direction.willShrink || direction.willGrow {
// Return final frame of preview
if Defaults[.previewVisibility], !isPreview {
return LoopManager.lastTargetFrame
}

// This allows for control over each side
let frameToResizeFrom = LoopManager.lastTargetFrame

Expand All @@ -207,7 +218,13 @@ private extension WindowAction {
result = calculateSizeAdjustment(frameToResizeFrom, bounds)

} else if direction.willMove {
// Return final frame of preview
if Defaults[.previewVisibility], !isPreview {
return LoopManager.lastTargetFrame
}

let frameToResizeFrom = LoopManager.lastTargetFrame

result = calculatePositionAdjustment(frameToResizeFrom)

} else if direction == .custom {
Expand Down