Repository navigation
🐞 Shrink a window before moving it to a smaller frame - #1190
Open
jvanderen1 wants to merge 1 commit into
Open
jvanderen1 wants to merge 1 commit into
jvanderen1 wants to merge 1 commit into
Conversation
A same-screen snap moved the window at its old width first, so the frame hung off the display. Finder and TextEdit then shrink. iTerm2 keeps that frame, and AppKit latches it as the minimum size. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
|
@mrkai77 Hello! I was wondering if you could take a look at this? It should help improve resizing for all apps. |
This branch has not been deployed
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.
Description
Snapping a window to a smaller frame on the same screen moved it first and resized it second. A window that is still at its old width, slid onto a third, hangs off the display. Finder and TextEdit accept the following shrink. iTerm2 does not.
On macOS 27.0.1, dragging iTerm2 onto a third left the window wider than the screen. Horizontal shrinking then stopped, while growing still worked, so the window could only ratchet larger. Resize-smoothly was already on, so this was not iTerm2's character-grid snap. Finder and TextEdit showed the same grow-then-shrink, then landed on the third.
WindowEngine.resizeWindowpassedsizeFirst: trueonly when the window changed screens.Window.setFrameotherwise sets the origin, then the size. If the frame missed, the retry calledsetFrameagain with that default and moved first a second time. That off-screen frame is what AppKit latches. iTerm2 commit368018c30logs the symptom: a healthy terminal window hasminSizeandcontentMinSizeof{0, 0}, and AppKit clamps later resizes to the window's own frame beforewindowWillResize:toSize:. Shrinking is refused. Growing still works.setFramealready knows how to size first: set the size, then the origin, then the size again. This change passessizeFirstwhen the target is narrower or shorter than the window's current size, including on the retry, and still passes it when the window changes screens. A same-screen grow stays position-first, so the window expands from the edge it was aimed at. The animated shrink path already callssetSizebeforesetPosition, so it is unchanged.Stash placement and restoring a dragged window's initial size use the same check when they apply a smaller frame.
This stops Loop from creating the bad frame. It does not clear a minimum size that AppKit has already latched on an iTerm2 window.
How has this been tested?
macOS 27.0.1 (26A434). Window-resize animation off.
WindowEngineSizeFirstTests: a narrower or shorter target sizes first, a same-screen grow stays position-first, and a screen change still sizes first.Screenshots (if appropriate)
Checklist:
Please describe to which degree, if any, an LLM was used in creating this pull request.
Cursor traced the resize order from the report above and drafted the change. I reviewed the diff and verified the same-screen third snaps locally.
Made with Cursor