Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong maximized window offset on non primary monitors #1921

Merged

Conversation

dsafa
Copy link
Contributor

@dsafa dsafa commented Jul 11, 2019

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

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.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems reasonable to me. I was poking around at this just recently, but hadn't identified that this was the real issue here. Good work on the find!

Even with my other nonclient changes, I think this will still work as the right fix.

@zadjii-msft
Copy link
Member

@dsafa (also make sure to runformat before submitting code, so that it's formatted correctly)

@dsafa
Copy link
Contributor Author

dsafa commented Jul 11, 2019

Whoops, thanks for the reminder. I've read up on the tools now and ran runformat.

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DHowett-MSFT
Copy link
Contributor

@msftbot merge this in 2 hours

@ghost
Copy link

ghost commented Jul 11, 2019

Hello @DHowett-MSFT!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I won't merge this pull request until after the UTC date Thu, 11 Jul 2019 18:58:59 GMT, which is in 2 hours

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jul 11, 2019
Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful. Thank you.

@DHowett-MSFT DHowett-MSFT merged commit 7b8cf10 into microsoft:master Jul 11, 2019
mcpiroman pushed a commit to mcpiroman/terminal that referenced this pull request Jul 23, 2019
…1921)

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.
@ghost
Copy link

ghost commented Aug 3, 2019

🎉Windows Terminal Preview v0.3.2142.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Left side of text is cut off when maximizing windows terminal on non-primary monitor
4 participants