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/Core/LoopManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ extension LoopManager {

let adjustedBounds = PaddingConfiguration
.getConfiguredPadding(for: currentScreen)
.applyToBounds(currentScreen.cgSafeScreenFrame)
.applyToBounds(currentScreen.cgSafeScreenFrame, screen: currentScreen)

let proportionalSize = CGRect(
x: (currentFrame.minX - adjustedBounds.minX) / adjustedBounds.width,
Expand Down
6 changes: 6 additions & 0 deletions Loop/Extensions/Defaults+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ extension Defaults.Keys {
/// Reset with `defaults delete com.MrKai77.Loop paddingMinimumScreenSize`
static let paddingMinimumScreenSize = Key<CGFloat>("paddingMinimumScreenSize", default: 0, iCloud: true)

/// Ignore the notch height when calculating top padding, so the effective
/// distance from the screen top matches non-notch displays.
/// Adjust with `defaults write com.MrKai77.Loop ignoreNotch -bool true`
/// Reset with `defaults delete com.MrKai77.Loop ignoreNotch`
static let ignoreNotch = Key<Bool>("ignoreNotch", default: false, iCloud: true)

/// Snap threshold for window snapping, defined in points.
/// Adjust with `defaults write com.MrKai77.Loop snapThreshold -float x`
/// Reset with `defaults delete com.MrKai77.Loop snapThreshold`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@ struct PaddingConfiguration: Codable, Defaults.Serializable, Hashable {
}

func applyToBounds(
_ bounds: CGRect
_ bounds: CGRect,
screen: NSScreen? = nil
) -> CGRect {
bounds
let notchOffset: CGFloat = if Defaults[.ignoreNotch], let screen {
screen.menubarHeight
} else {
0
}
let effectiveTopPadding = max(0, totalTopPadding - notchOffset)

return bounds
.padding(.leading, left)
.padding(.trailing, right)
.padding(.bottom, bottom)
.padding(.top, totalTopPadding)
.padding(.top, effectiveTopPadding)
}

/// Applies padding to a frame that was calculated using non-padded bounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ final class ResizeContext {
self.screen = screen
self.bounds = bounds
self.padding = padding
self.paddedBounds = padding.applyToBounds(bounds)
self.paddedBounds = padding.applyToBounds(bounds, screen: screen)
self.action = action
self.parentAction = parentAction
self.initialMousePosition = initialMousePosition
Expand All @@ -65,7 +65,7 @@ final class ResizeContext {
self.screen = screen
bounds = screen?.cgSafeScreenFrame ?? .zero
padding = PaddingConfiguration.getConfiguredPadding(for: screen)
paddedBounds = padding.applyToBounds(bounds)
paddedBounds = padding.applyToBounds(bounds, screen: screen)
needsRecompute = true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,9 @@ extension WindowFrameResolver {
.filter { !$0.intersects(currentFrame) } // Ensure it doesn't intersect with the current window
.map { $0.intersection(screenFrame) } // Crop it to the screen frame

// Computes the closest window obstacle in each of the four cardinal directions
// (left, right, top, bottom) relative to the current window, and returns the boundaries
// formed by these obstacles, constrained to the screen frame.
/// Computes the closest window obstacle in each of the four cardinal directions
/// (left, right, top, bottom) relative to the current window, and returns the boundaries
/// formed by these obstacles, constrained to the screen frame.
func computeBoundaries() -> (minX: CGFloat, minY: CGFloat, maxX: CGFloat, maxY: CGFloat) {
var minX = screenFrame.minX
var minY = screenFrame.minY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ enum WindowRecords {
let windowFrame = window.frame
let adjustedBounds = PaddingConfiguration
.getConfiguredPadding(for: screen)
.applyToBounds(screen.cgSafeScreenFrame)
.applyToBounds(screen.cgSafeScreenFrame, screen: screen)

let proportionalSize = CGRect(
x: (windowFrame.minX - adjustedBounds.minX) / adjustedBounds.width,
Expand Down