Skip to content

Add an option to snap before reaching outer screen edges - #1901

Merged
rxhanson merged 3 commits into
rxhanson:mainfrom
kiteretsu903:fix/review-early-edge-snap
Oct 14, 2026
Merged

rxhanson merged 3 commits into
rxhanson:mainfrom
kiteretsu903:fix/review-early-edge-snap

Conversation

@kiteretsu903

@kiteretsu903 kiteretsu903 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Adds the off-by-default “Snap before reaching screen edges” option. When enabled, an outer edge can activate its snap target within a configurable distance of the edge (20 points by default), so the pointer does not have to reach the physical boundary.

Corner targets retain their existing detection. Shared edges between displays retain their existing trigger margin so that moving a window between displays does not gain an early snap zone. This is checked along the shared portion of an edge, including displays with different sizes or offsets. On exposed outer edges, a positive early-snap distance overrides the configured snapEdgeMargin values, including larger margins.

The change is confined to SnapEdgeDetection and its setting. It does not change the resulting window size, placement, animation, or Layout Helper behavior. The toggle writes 20 when enabled and 0 when disabled. The stored value is a double, so users can choose a custom distance with defaults write com.knollsoft.Rectangle snapBeforeReachingEdges -float 30 and restart Rectangle. Opening settings or importing configuration preserves custom distances. With the option disabled, the original edge margins apply.

Validation

The full branch XCTest suite passed (578 tests, including existing tests), covering fractional distances, override precedence, shared-boundary decisions, toggle behavior, and custom-distance preservation during settings synchronization and configuration import. A physical multi-display drag pass, including crossing partially shared edges and corner behavior, remains pending.

This replaces the corresponding part of #1892.

@kiteretsu903
kiteretsu903 force-pushed the fix/review-early-edge-snap branch 2 times, most recently from 06c9dd1 to 6269df1 Compare October 10, 2026 02:51
@rxhanson

Copy link
Copy Markdown
Owner

A couple of improvements:

  • Replace the Bool default with a double, and that will be the earlyDistance. We can still keep the toggle instead of a numerical input, and when it gets toggled it will set the default 0 or 20 if disabled or enabled, respectively. This way people can adjust this value using a defaults command if desired.
  • It would be odd logic to apply this on top of the existing snapEdgeMargin defaults. I think it should override the snapEdgeMargin defaults if both are set.

@kiteretsu903

Copy link
Copy Markdown
Contributor Author

A couple of improvements:

  • Replace the Bool default with a double, and that will be the earlyDistance. We can still keep the toggle instead of a numerical input, and when it gets toggled it will set the default 0 or 20 if disabled or enabled, respectively. This way people can adjust this value using a defaults command if desired.
  • It would be odd logic to apply this on top of the existing snapEdgeMargin defaults. I think it should override the snapEdgeMargin defaults if both are set.

Yep! Both make sense to me. Will apply the fixes

@kiteretsu903
kiteretsu903 force-pushed the fix/review-early-edge-snap branch from 6269df1 to f38a130 Compare October 13, 2026 01:35
@rxhanson
rxhanson merged commit 7bda164 into rxhanson:main Oct 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants