Let a repeated Maximize restore the window's previous size and position (opt-in) - #1837
Merged
rxhanson merged 1 commit intoSep 7, 2026
Merged
Conversation
Owner
|
Thanks for taking this one on. Would you mind keeping all of the Maximize logic within the |
Executing Maximize or Almost Maximize on a window that is already in that state does nothing, so getting the window back takes the Restore shortcut, which also undoes every other Rectangle action since the user last placed the window. Behind the new repeatedMaximizeRestoresPrevious default, the same action executed again on a window Rectangle has just maximized (or almost maximized) moves it back to the frame it had right before, so the shortcut toggles between the two. The frame to come back to is recorded in WindowHistory.preMaximizeRects whenever one of the two calculations runs. The repeat is recognized from the window history the way the title bar double-click restore does: the last action on the window is the same action and the window has not been moved since, so a window maximized by other means is maximized as usual, and so is a window whose last action was the other one of the two (Maximize and Almost Maximize keep switching between each other). The restore is reported as .restore, so it is applied without gaps and the next execution of the action maximizes the window again, calculated from scratch. With the repeated-command setting on "Cycle through displays" the restore takes precedence over the display cycling for those two actions. The default is off; with it off nothing changes. - Add RepeatedMaximizeRestore.swift with the decision logic - Consult it from the Maximize and Almost Maximize calculations, and in the display-cycling check - Add RepeatedMaximizeRestoreTests (13 cases) - Document the default in TerminalCommands.md - Expose it as a "Repeated Maximize restores the previous size and position" checkbox, unchecked by default, at the bottom of the Extras popover in the General settings tab (title and tooltip registered in Main.xcstrings)
X-Wei
force-pushed
the
repeated-maximize-restores-previous
branch
from
September 6, 2026 14:04
6f6789b to
c5f979b
Compare
Contributor
Author
|
Done — all of the logic lives in the calculations now, and
Tests went from 7 to 13 cases and the full suite is green. Also rebased onto current main. |
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
Adds an opt-in mode in which running Maximize (or Almost Maximize) again on a window Rectangle has just maximized moves it back to the size and position it had right before, so the shortcut toggles between maximized and the previous frame — the way toggling maximize works on KDE.
Today repeating Maximize on an already-maximized window does nothing, and getting the window back means the Restore shortcut, which also undoes every other Rectangle action since you last placed the window. This keeps Maximize and Restore as they are and only adds "press again to go back", behind a single default.
Off by default (
repeatedMaximizeRestoresPrevious); nothing changes unless it is enabled.Related: discussion #894 (requested there; you implemented it in Rectangle Pro). This is the narrow free-Rectangle version — no new shortcut, one self-contained type, one default. Same shape as #1824.
Behavior when enabled
How it works
WindowHistory.preMaximizeRectswhenever Maximize / Almost Maximize runs.TitleBarManager): the window's last action is the same action and it has not moved since. No new geometry or heuristics.RepeatedMaximizeRestore, consulted inWindowManager.execute(and in the display-cycling shortcut path).Docs / Tests
TerminalCommands.md, and exposed as a checkbox at the bottom of the General → Extras popover (same place as Let half actions preserve the window's size on the other axis (opt-in) #1824; title and tooltip registered inMain.xcstrings).RepeatedMaximizeRestoreTests); the full suite is green.I'm happy to drop the checkbox and keep it Terminal-only if you'd prefer, like some of the other hidden defaults.