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

Initial window height calculation regression #3472

Closed
mcpiroman opened this issue Nov 7, 2019 · 5 comments
Closed

Initial window height calculation regression #3472

mcpiroman opened this issue Nov 7, 2019 · 5 comments
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@mcpiroman
Copy link
Contributor

Initial window height is off by titlebar height. This got regressed by #3394 in:

RECT islandFrame = {};
bool succeeded = AdjustWindowRectExForDpi(&islandFrame, WS_OVERLAPPEDWINDOW, false, 0, dpix);
// If we failed to get the correct window size for whatever reason, log
// the error and go on. We'll use whatever the control proposed as the
// size of our window, which will be at least close.
LOG_LAST_ERROR_IF(!succeeded);
if (_useNonClientArea)
{
islandFrame.top = -NonClientIslandWindow::topBorderVisibleHeight;
}
adjustedWidth = -islandFrame.left + islandWidth + islandFrame.right;
adjustedHeight = -islandFrame.top + islandHeight + islandFrame.bottom;

That also blocks #3181 which relys on this size calculation.

Steps to reproduce

  1. Set fontSize to 50
  2. Set initialRows to 2
  3. Launch terminal

Expected behavior

2 rows should fit in the window

Actual behavior

About 1.5 of a row fits.

cc @greg904.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Nov 7, 2019
@beviu
Copy link
Contributor

beviu commented Nov 7, 2019

Are you sure it's a regression? I just tried with 6f36f8b (before the PR was merged) and the size is also incorrect.

Before the PR, it was calling GetFrameMargins to calculate the size which looks like it includes the title bar's height because it calls GetDragAreaRect and adds the height to the result BUT during my debugging I found that during the initialization, the drag bar is not set yet so GetDragAreaRect returns 0 so GetFrameMargins doesn't include the title bar.

BTW here is a TODO for this (it was supposed say "the height of the title bar" for the second option instead of "tab bar" but I thought I had removed this comment so I didn't fix the comment):

// TODO MSFT:21150597 - If the global setting "Always show tab bar" is
// set or if "Show tabs in title bar" is set, then we'll need to add
// the height of the tab bar here.
return TermControl::GetProposedDimensions(settings, dpi);
}

I didn't fix this bug because it was too hard and (I'm pretty sure, see above) the bug was already there before the PR.

Sorry for breaking your PR :(

Maybe adding static_cast<LONG>(_dragBar or _titlebar.ActualHeight() * GetCurrentDpiScale()) to the height will work? (but as I said above it will probably not work for the initial size calculation because _dragBar is not initialized)

@zadjii-msft
Copy link
Member

For the record, I don't believe this regressed. I thought it was always broken 😝

@zadjii-msft zadjii-msft added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. labels Nov 7, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Nov 7, 2019
@zadjii-msft
Copy link
Member

Also, I think this one is probably a /dupe of #2061

@ghost
Copy link

ghost commented Nov 7, 2019

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost closed this as completed Nov 7, 2019
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Nov 7, 2019
@mcpiroman
Copy link
Contributor Author

Ah ok then, sorry for my accusement. My PR stopped working after I merged with this one because of removed GetDragArea, but I didn't realized it wasn't working with initial sizing before. As to solving this problem, #3182 might help.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

3 participants