From 3f11c95b1a448625cccf132148af7c7c73363434 Mon Sep 17 00:00:00 2001 From: Yurii Chukhlib Date: Fri, 7 Aug 2026 23:43:01 +0200 Subject: [PATCH] Allow smaller to shrink the height of a vertically maximized window Extends the .smallerHeight curtain exemption (b97a353, #1645) to the combined .smaller command so a vertically-maximized window shrinks in both width and height instead of only width. Adds testSmallerShrinksHeightOfFullHeightWindow and updates three existing ChangeSizeCalculationTests expectations that encoded the pre-#1737 height-pinned behavior. --- .../ChangeSizeCalculation.swift | 2 +- RectangleTests/RectangleTests.swift | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Rectangle/WindowCalculation/ChangeSizeCalculation.swift b/Rectangle/WindowCalculation/ChangeSizeCalculation.swift index 25d0b11a..2c00e58f 100644 --- a/Rectangle/WindowCalculation/ChangeSizeCalculation.swift +++ b/Rectangle/WindowCalculation/ChangeSizeCalculation.swift @@ -68,7 +68,7 @@ class ChangeSizeCalculation: WindowCalculation, ChangeWindowDimensionCalculation resizedWindowRect.size.height = resizedWindowRect.height + sizeOffset resizedWindowRect.origin.y = resizedWindowRect.minY - floor(sizeOffset / 2.0) - if curtainChangeSize, params.action != .smallerHeight { + if curtainChangeSize, ![.smaller, .smallerHeight].contains(params.action) { resizedWindowRect = againstTopAndBottomScreenEdges( originalWindowRect: window.rect, resizedWindowRect: resizedWindowRect, diff --git a/RectangleTests/RectangleTests.swift b/RectangleTests/RectangleTests.swift index e555b3c4..3f1b163f 100644 --- a/RectangleTests/RectangleTests.swift +++ b/RectangleTests/RectangleTests.swift @@ -319,7 +319,7 @@ class ChangeSizeCalculationTests: XCTestCase { func testExplicitZeroDisablesScreenFractionMinimum() { XCTAssertEqual(smallerResult(for: issueWindowRect), - CGRect(x: 1925, y: 0, width: 635, height: 1415)) + CGRect(x: 1925, y: 15, width: 635, height: 1385)) } func testDoubleDefaultDistinguishesAbsentFromExplicitZero() { @@ -380,7 +380,7 @@ class ChangeSizeCalculationTests: XCTestCase { let windowRect = CGRect(x: 1890, y: 0, width: 670, height: 1415) XCTAssertEqual(smallerResult(for: windowRect), - CGRect(x: 1920, y: 0, width: 640, height: 1415)) + CGRect(x: 1920, y: 15, width: 640, height: 1385)) } func testSmallerHonorsConfiguredScreenFractionMinimum() { @@ -389,11 +389,21 @@ class ChangeSizeCalculationTests: XCTestCase { XCTAssertEqual(smallerResult(for: issueWindowRect), issueWindowRect) } + func testSmallerShrinksHeightOfFullHeightWindow() { + // Regression for #1737: a vertically-maximized (Half / full-height) window must shrink in + // BOTH dimensions under the combined `.smaller` command, not only in width. Mirrors the + // `.smallerHeight` exception added in b97a353 (fixes #1645), extended to `.smaller`. + let fullHeightHalf = CGRect(x: 0, y: 0, width: 1280, height: 1415) + + XCTAssertEqual(smallerResult(for: fullHeightHalf), + CGRect(x: 0, y: 15, width: 1250, height: 1385)) + } + func testSmallConfiguredScreenFractionAllowsIssueRegressionStep() { Defaults.minimumWindowWidth.value = 0.01 XCTAssertEqual(smallerResult(for: issueWindowRect), - CGRect(x: 1925, y: 0, width: 635, height: 1415)) + CGRect(x: 1925, y: 15, width: 635, height: 1385)) } func testExplicitZeroStillRejectsNonpositiveSize() {