Skip to content

Commit ec1d023

Browse files
MyronKochclaude
andcommitted
Fix false positive overlap detection for half/third actions
Origin-only matching caused false positives when a larger window (e.g. maximized) shared the same origin as the target position. Now requires that the other window fits within the candidate's dimensions - origins must match AND the other window must be the same size or smaller. This prevents a maximized window from triggering the offset on a left-half placement, while still detecting a quarter behind an eighth at the same grid position. Fixes #1762 post-merge bug reported by maintainer. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 038b168 commit ec1d023

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Rectangle/WindowManager.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,11 @@ class WindowManager {
228228
let candidateAX = candidate.screenFlipped
229229
let hasOverlap = otherWindows.contains { element in
230230
let otherFrame = element.frame
231-
return abs(otherFrame.origin.x - candidateAX.origin.x) < tolerance
231+
let originsMatch = abs(otherFrame.origin.x - candidateAX.origin.x) < tolerance
232232
&& abs(otherFrame.origin.y - candidateAX.origin.y) < tolerance
233+
let otherFitsInCandidate = otherFrame.width <= candidateAX.width + tolerance
234+
&& otherFrame.height <= candidateAX.height + tolerance
235+
return originsMatch && otherFitsInCandidate
233236
}
234237

235238
guard hasOverlap else { break }

0 commit comments

Comments
 (0)