Anchor clamped windows to the snap edge instead of leaving a gap#1778
Merged
Conversation
Owner
|
Thanks! This is great. There's one thing that I'm thinking about on it - that perhaps it would be nice to provide the granularity of configuration up front for whether or not this should apply to halves. We could change |
Owner
|
I'll go ahead and merge this one in and adjust the moveFixedSizeToEdge with more granularity in a follow-on change. Thanks again! |
Contributor
Author
|
Great! And thank you for dealing with the moveFixedSizeToEdge adjusting later! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a window can't be resized to fill its snap zone, Rectangle leaves it at the zone's leading corner, producing a gap on the screen-edge side. The clearest repro is FaceTime snapped to a half (when in a vertical video call): it keeps a fixed video aspect ratio, so on a wide display it clamps its own width and ends up floating near screen-center instead of flush against the screen edge. This also happens with the System Settings window for example.
This makes a clamped window anchor to the snap zone's screen edge(s), and stay centered on any axis it can't fill. It's all behind the existing
moveFixedSizeToEdgedefault, which is off by default, so default behavior is unchanged.Why it happens today
isResizable()istrue), so it goes through the standard mover chain and never reachesFixedSizeWindowMover.StandardWindowMoversets the zone position, the app clamps the size, andBestEffortWindowMoveronly rescues windows that overflow off the screen — an under-filled window keeps its leading-corner position, leaving the gap.moveFixedSizeToEdgeedge-anchoring inFixedSizeWindowMoverwas gated onsharedEdges.isCorner, so it only fired for quarter snaps, never halves (a half shares three screen edges, soisCorneris false).Changes
ClampedWindowAligner— a pure, unit-tested helper that repositions a window per axis: if the zone touches exactly one screen edge on that axis, anchor to it; otherwise (spans the full axis, or floats inside) center. It subsumes the oldmatchSharedEdges/centerWindowRectand drops theisCornergate.FixedSizeWindowMovernow delegates to it, so half-snaps of fixed-size windows anchor correctly too. (Flag off →.noneshared edges → centers, exactly as before.)EdgeAlignmentWindowMoveradded to the standard chain to re-anchor resizable-but-clamped windows like FaceTime afterStandardWindowMoverruns.moveFixedSizeToEdgeflag inTerminalCommands.md.Edge detection and anchoring use the gap-applied rect, so existing gap settings are respected.
Test plan
ClampedWindowAligner(right half, left half, full-height half, top-right quarter, interior, exact-fit): 6/6 pass.defaults write com.knollsoft.Rectangle moveFixedSizeToEdge -bool true: