Initial window height calculation regression #4854

Closed
opened 2026-01-30 23:58:13 +00:00 by claunia · 5 comments
Owner

Originally created by @mcpiroman on GitHub (Nov 7, 2019).

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

357e835f5d/src/cascadia/WindowsTerminal/AppHost.cpp (L197-L210)

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.

Originally created by @mcpiroman on GitHub (Nov 7, 2019). Initial window height is off by titlebar height. This got regressed by #3394 in: https://github.com/microsoft/terminal/blob/357e835f5d37492812e33eac1dd995232c19de63/src/cascadia/WindowsTerminal/AppHost.cpp#L197-L210 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.
claunia added the Issue-BugResolution-DuplicateProduct-TerminalArea-UserInterface labels 2026-01-30 23:58:13 +00:00
Author
Owner

@beviu commented on GitHub (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):
357e835f5d/src/cascadia/TerminalApp/App.cpp (L337-L342)

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)

@beviu commented on GitHub (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): https://github.com/microsoft/terminal/blob/357e835f5d37492812e33eac1dd995232c19de63/src/cascadia/TerminalApp/App.cpp#L337-L342 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)
Author
Owner

@zadjii-msft commented on GitHub (Nov 7, 2019):

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

@zadjii-msft commented on GitHub (Nov 7, 2019): For the record, I don't _believe_ this regressed. I thought it was always broken 😝
Author
Owner

@zadjii-msft commented on GitHub (Nov 7, 2019):

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

@zadjii-msft commented on GitHub (Nov 7, 2019): Also, I think this one is probably a /dupe of #2061
Author
Owner

@ghost commented on GitHub (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 commented on GitHub (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!
Author
Owner

@mcpiroman commented on GitHub (Nov 8, 2019):

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.

@mcpiroman commented on GitHub (Nov 8, 2019): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#4854