Fix: incorrect window size restore after exiting full screen (#351) #19439
+58
−0
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 of the Pull Request
This pull request fixes an issue where exiting full-screen mode incorrectly restores the console window to the wrong size. Previously, the window reverted to its outer dimensions, which included the title bar and borders, instead of maintaining the correct viewport dimensions. This caused the visible console area to shrink and display scrollbars unnecessarily.
References and Relevant Issues
#351 — Exiting from Full Screen mode incorrectly restores window size
Detailed Description of the Pull Request / Additional comments
The problem occurred because the window size restoration logic relied on the full outer window bounds rather than the inner console area.
This PR modifies the behavior so that:
The window correctly restores the client (viewport) size instead of the outer size when exiting full screen.
The console buffer and viewport remain properly synchronized, avoiding the cascading shrink issue that previously occurred when toggling full screen multiple times.
The update ensures that scrollbars appear only when the buffer exceeds the viewport dimensions, not because of incorrect window sizing.
This change was verified using the mode 80, 25 command, followed by multiple Alt+Enter toggles to enter and exit full-screen mode, ensuring consistent window restoration to 80×25.
Validation Steps Performed
1.) Start cmd.exe
2.) Run mode 80, 25
3.) Enter full-screen mode using Alt + Enter and exit full-screen mode
4.) Verify in Properties and ensure in Layout that the window size remains 80 x 25 (the original dimensions)
5.) Repeat multiple times to confirm that the viewport size is the same and no scrollbars appear
PR Checklist