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

Correct for the size of the tabs when calculating our initial window size #4825

Merged
2 commits merged into from
Mar 11, 2020

Conversation

zadjii-msft
Copy link
Member

Summary of the Pull Request

This fixes our calculation for the initial size of the window. WE weren't accounting for the height of the tabs, so the initialRows was consistently wrong.

PR Checklist

Detailed Description of the Pull Request / Additional comments

For the tabs below the titlebar case, there's 6px (unscaled) of space that I cannot account for. I seriously have no idea where it's coming from. When we end up creating the first TermControl after startup, there's an inexplicable 6*scale difference between the height of the tabContent and the SwapChainPanel's size.

Validation Steps Performed

Checked all six of the following cases:

  • 1.0 DPI scaling, Tabs in Titlebar
  • 1.25 DPI scaling, Tabs in Titlebar
  • 1.0 DPI scaling, Tabs NOT in Titlebar, always show tabs
  • 1.0 DPI scaling, Tabs NOT in Titlebar, DON'T always show tabs
  • 1.25 DPI scaling, Tabs NOT in Titlebar, always show tabs
  • 1.25 DPI scaling, Tabs NOT in Titlebar, DON'T always show tabs

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.

Straightforward enough to me. :shipit:

Comment on lines +401 to +404
// For whatever reason, there's about 6px of unaccounted-for space
// in the application. I couldn't tell you where these 6px are
// coming from, but they need to be included in this math.
proposedSize.Y += (tabControl.DesiredSize().Height + 6) * scale;
Copy link
Member

Choose a reason for hiding this comment

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

I mean I don't like it, but I trust you rooted around forever to try to find it and we'll just correct it later should something change.

@miniksa miniksa added AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off labels Mar 6, 2020
@ghost
Copy link

ghost commented Mar 6, 2020

Hello @miniksa!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

Do note that I've been instructed to only help merge pull requests of this repository that have been opened for at least 8 hours, a condition that will be fulfilled in about 7 hours 45 minutes. No worries though, I will be back when the time is right! 😉

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost requested review from carlos-zamora, DHowett-MSFT and leonMSFT March 6, 2020 18:04
@@ -417,6 +417,8 @@ SIZE NonClientIslandWindow::GetTotalNonClientExclusiveSize(UINT dpi) const noexc

islandFrame.top = -topBorderVisibleHeight;

// If we have a titlebar, this is being called after we've initialized, and
// we can just ask that titlebar how big it wants to be.
const auto titleBarHeight = _titlebar ? static_cast<LONG>(_titlebar.ActualHeight()) : 0;
Copy link
Contributor

@beviu beviu Mar 6, 2020

Choose a reason for hiding this comment

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

Isn't it adding the title bar twice now: Here and in AppLogic::GetLaunchDimensions? But this works because it's not initialized yet so it adds 0.

BTW the name/description of this method is confusing. It should be something like "get size of everything in the window rect except the content of a tab" I think. Because it's not really the non client area (it includes the fake title bar which is inside the client area).

In fact it seems that because of this confusion there is a bug (not introduced by this PR) where with "showTabsInTitlebar": false, the resize doesn't snap correctly vertically. I just made a bug report for this in #4827.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for filing that! You're right, that method name is definitely confusing. IIRC, in the PR that introduced it there was some back and forth on the naming but we couldn't come up with a better name. With this PR, it should be a little easier to at least solve that bug (#4827).

@zadjii-msft zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. labels Mar 6, 2020
@ghost ghost merged commit 0e33d86 into master Mar 11, 2020
@ghost ghost deleted the dev/migrie/b/2061-initial-size branch March 11, 2020 20:29
@DHowett-MSFT
Copy link
Contributor

Er did we ever figure out if greg904 was right? Probably we should have blocked this

@zadjii-msft
Copy link
Member Author

Oh sorry, never replied to that - no, we're shockingly not. Hence the comment there. In startup, _titlebar is nullptr, so we don't add anything for it there.

abhijeetviswam pushed a commit to abhijeetviswam/terminal that referenced this pull request Mar 12, 2020
…size (microsoft#4825)

## Summary of the Pull Request

This fixes our calculation for the initial size of the window. WE weren't accounting for the height of the tabs, so the `initialRows` was consistently wrong.

## PR Checklist
* [x] Closes microsoft#2061
* [x] I work here
* [ ] Tests added/passed
* [n/a] Requires documentation to be updated

## Detailed Description of the Pull Request / Additional comments

For the tabs below the titlebar case, there's 6px (unscaled) of space that I cannot account for. I seriously have no idea where it's coming from. When we end up creating the first `TermControl` after startup, there's an inexplicable `6*scale` difference between the height of the `tabContent` and the `SwapChainPanel`'s size.

## Validation Steps Performed

Checked all six of the following cases:
* 1.0 DPI scaling, Tabs in Titlebar
* 1.25 DPI scaling, Tabs in Titlebar
* 1.0 DPI scaling, Tabs NOT in Titlebar, always show tabs
* 1.0 DPI scaling, Tabs NOT in Titlebar, DON'T always show tabs
* 1.25 DPI scaling, Tabs NOT in Titlebar, always show tabs
* 1.25 DPI scaling, Tabs NOT in Titlebar, DON'T always show tabs
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal is starting up at a size that's different from initialRows/initialCols
5 participants