Skip to content
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
83 changes: 42 additions & 41 deletions Loop/Window Management/WindowAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,48 +75,49 @@ struct WindowAction: Codable, Identifiable, Hashable, Equatable, Defaults.Serial
result.size.width = bounds.width * frameMultiplyValues.width
result.size.height = bounds.height * frameMultiplyValues.height
} else {
if direction == .custom, let screenFrame = NSScreen.screenWithMouse?.frame {
switch measureSystem {
case .percentage:
result.size.width = bounds.width * ((width ?? 0) / 100.0)
result.size.height = bounds.height * ((height ?? 0) / 100.0)
case .pixels:
result.size.width += (width ?? 0) / screenFrame.width
result.size.height += (height ?? 0) / screenFrame.height
case .none:
break
}
guard direction == .custom else { return result }

switch anchor {
case .topLeft:
break
case .top:
result.origin.x = screenFrame.midX - result.width / 2
case .topRight:
result.origin.x = screenFrame.maxX - result.width
case .right:
result.origin.x = screenFrame.maxX - result.width
result.origin.y = screenFrame.midY - result.height / 2
case .bottomRight:
result.origin.x = screenFrame.maxX - result.width
result.origin.y = screenFrame.maxY - result.height
case .bottom:
result.origin.x = screenFrame.midX - result.width / 2
result.origin.y = screenFrame.maxY - result.height
case .bottomLeft:
result.origin.y = screenFrame.maxY - result.height
case .left:
result.origin.y = screenFrame.midY - result.height / 2
case .center:
result.origin.x = screenFrame.midX - result.width / 2
result.origin.y = screenFrame.midY - result.height / 2
case .macOSCenter:
let yOffset = WindowEngine.getMacOSCenterYOffset(result.height, screenHeight: screenFrame.height)
result.origin.x = screenFrame.midX - result.width / 2
result.origin.y = (screenFrame.midY - result.height / 2) + yOffset
case .none:
break
}
switch measureSystem {
case .pixels:
guard let screenFrame = NSScreen.screenWithMouse?.frame else { return result }
result.size.width += (width ?? screenFrame.width) / screenFrame.width
result.size.height += (height ?? screenFrame.height) / screenFrame.height
case .percentage:
result.size.width = bounds.width * ((width ?? 0) / 100.0)
result.size.height = bounds.height * ((height ?? 0) / 100.0)
case .none:
break
}

switch anchor {
case .topLeft:
break
case .top:
result.origin.x = bounds.midX - result.width / 2
case .topRight:
result.origin.x = bounds.maxX - result.width
case .right:
result.origin.x = bounds.maxX - result.width
result.origin.y = bounds.midY - result.height / 2
case .bottomRight:
result.origin.x = bounds.maxX - result.width
result.origin.y = bounds.maxY - result.height
case .bottom:
result.origin.x = bounds.midX - result.width / 2
result.origin.y = bounds.maxY - result.height
case .bottomLeft:
result.origin.y = bounds.maxY - result.height
case .left:
result.origin.y = bounds.midY - result.height / 2
case .center:
result.origin.x = bounds.midX - result.width / 2
result.origin.y = bounds.midY - result.height / 2
case .macOSCenter:
let yOffset = WindowEngine.getMacOSCenterYOffset(result.height, screenHeight: bounds.height)
result.origin.x = bounds.midX - result.width / 2
result.origin.y = (bounds.midY - result.height / 2) + yOffset
case .none:
break
}
}
return result
Expand Down