[PR #1921] Fix wrong maximized window offset on non primary monitors #24722

Open
opened 2026-01-31 09:04:58 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/1921

State: closed
Merged: Yes


Summary of the Pull Request

Fixes the calculation of the margins when the non client island window is maximized on non primary monitors

References

#1055

PR Checklist

  • Closes Colortool can find scheme, but can not load it (#1055)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

The overhang of a maximized window is currently calculated with this:

auto offset = 0;
if (rcMaximum.left == 0)
{
    offset = windowPos->x;
}
else if (rcMaximum.top == 0)
{
    offset = windowPos->y;
}

This always works on the primary monitor but on a non primary monitor, it isn't always the case that left or top can be 0. Examples are when you offset a monitor. In those cases, offset will be 0 and the window will be cut off.

Instead I've changed the calculation to calculate the width of the windows frame which is how much it would overhang. Admittedly, the old calculation could be kept and take into consideration the current monitor.

Also I see a lot of work on the non client window so maybe we won't even need to do this later?

Validation Steps Performed

Manually tested on primary and non primary monitors and the same offset is given: 8 pixels on all sides at 100% scaling. Also tested with different dpi and the margins are the same as using the old method.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/1921 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Fixes the calculation of the margins when the non client island window is maximized on non primary monitors ## References #1055 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1055 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments The overhang of a maximized window is currently calculated with this: ```cpp auto offset = 0; if (rcMaximum.left == 0) { offset = windowPos->x; } else if (rcMaximum.top == 0) { offset = windowPos->y; } ``` This always works on the primary monitor but on a non primary monitor, it isn't always the case that `left` or `top` can be 0. Examples are when you offset a monitor. In those cases, `offset` will be 0 and the window will be cut off. Instead I've changed the calculation to calculate the width of the windows frame which is how much it would overhang. Admittedly, the old calculation could be kept and take into consideration the current monitor. Also I see a lot of work on the non client window so maybe we won't even need to do this later? ## Validation Steps Performed Manually tested on primary and non primary monitors and the same offset is given: 8 pixels on all sides at 100% scaling. Also tested with different dpi and the margins are the same as using the old method.
claunia added the pull-request label 2026-01-31 09:04:58 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24722