Window scaling issue moving between monitors of different scaling #15487

Closed
opened 2026-01-31 04:39:58 +00:00 by claunia · 4 comments
Owner

Originally created by @lukem on GitHub (Oct 8, 2021).

Windows Terminal version (or Windows build number)

1.11.2731.0

Other Software

tcsh (inside WSL2, Fedora 34)

Steps to reproduce

System with two monitors of different scaling. In my case:

  • Laptop with 15" screen, 1920x1080 resolution, 125% scaling
  • 34" monitor, 3440x1440 resolution, 100% scaling. Set as main display.

Resize example 1:

  • Start Terminal, set to 80x24, on 34" main display (100% scaling)
  • Move window to 15" display (125%) scaling
  • Observe that the terminal now reports 82x25
  • Move window back to 34" display (100% scaling)
  • Terminal now reports 80x24 (original layout on this display)

Resize example 2:

  • At a larger window of 112x44 @ 100%, the window increases to 114x46 @ 125%
  • If the window is resized to 112x44 @ 125%, then when moving back it shrinks to 110x42 @ 100%.

(This issue is similar to bug #10515, except that seems to be when the window is minimized and resumed, rather than moving between different scaling).

Expected Behavior

The window should stay the same number of rows & columns when moving between monitors, even with different scaling.

Actual Behavior

Output of running "echo" then "stty" at different times when the window is on the different monitors with different scaling:

Starting on 3440x1440 34" at 100% scaling - window is 80x24

lukem@andromeda 13> stty -a | head -1
speed 38400 baud; rows 24; columns 80; line = 0;

Now on 1920x1080 15" laptop at 125% scaling - window increased to 82x25

lukem@andromeda 15> stty -a | head -1
speed 38400 baud; rows 25; columns 82; line = 0;

Back on 34" 100% - back to 80x24

lukem@andromeda 17> stty -a | head -1
speed 38400 baud; rows 24; columns 80; line = 0;
Originally created by @lukem on GitHub (Oct 8, 2021). ### Windows Terminal version (or Windows build number) 1.11.2731.0 ### Other Software tcsh (inside WSL2, Fedora 34) ### Steps to reproduce System with two monitors of different scaling. In my case: - Laptop with 15" screen, 1920x1080 resolution, 125% scaling - 34" monitor, 3440x1440 resolution, 100% scaling. Set as main display. Resize example 1: - Start Terminal, set to 80x24, on 34" main display (100% scaling) - Move window to 15" display (125%) scaling - Observe that the terminal now reports 82x25 - Move window back to 34" display (100% scaling) - Terminal now reports 80x24 (original layout on this display) Resize example 2: - At a larger window of 112x44 @ 100%, the window increases to 114x46 @ 125% - If the window is resized to 112x44 @ 125%, then when moving back it shrinks to 110x42 @ 100%. (This issue is similar to bug #10515, except that seems to be when the window is minimized and resumed, rather than moving between different scaling). ### Expected Behavior The window should stay the same number of rows & columns when moving between monitors, even with different scaling. ### Actual Behavior Output of running "echo" then "stty" at different times when the window is on the different monitors with different scaling: **Starting on 3440x1440 34" at 100% scaling - window is 80x24** ``` lukem@andromeda 13> stty -a | head -1 speed 38400 baud; rows 24; columns 80; line = 0; ``` **Now on 1920x1080 15" laptop at 125% scaling - window increased to 82x25** ``` lukem@andromeda 15> stty -a | head -1 speed 38400 baud; rows 25; columns 82; line = 0; ``` **Back on 34" 100% - back to 80x24** ``` lukem@andromeda 17> stty -a | head -1 speed 38400 baud; rows 24; columns 80; line = 0; ```
Author
Owner

@DHowett commented on GitHub (Oct 8, 2021):

Implementor's Notes

This is because fonts do not scale linearly with dpi, and Windows calculates a new scaled size for us on its own (so: we don't factor in the new DPI and tell Windows how big we should be.). The window ends up scaled roughly linearly, but more or fewer characters fit in that space.

conhost tries really hard to fix this by listening to WM_GETDPISCALEDSIZE¹ and doing a bunch of recalculation math (as well as re-measuring the font with the new proposed DPI). This has been error prone, but may help us solve the issue in Terminal.

479ef264b2/src/interactivity/win32/windowproc.cpp (L176-L219)

This works well enough for conhost because it has no UI, no padding, no custom non-client area, and absolutely no panes (!). An implementation for Terminal will need to be quite a few times more complicated.

¹ Trivia: I think the win32k folks implemented WM_GETDPISCALEDSIZE just for us!

@DHowett commented on GitHub (Oct 8, 2021): ## Implementor's Notes This is because fonts do not scale linearly with dpi, and Windows calculates a new scaled size for us on its own (so: we don't factor in the new DPI and tell Windows how big we _should_ be.). The window ends up scaled roughly linearly, but more or fewer characters fit in that space. conhost tries really hard to fix this by listening to `WM_GETDPISCALEDSIZE`¹ and doing a bunch of recalculation math (as well as re-measuring the font with the new proposed DPI). This has been error prone, but may help us solve the issue in Terminal. https://github.com/microsoft/terminal/blob/479ef264b2d9e284db1fc8457f3897d1b19ac32e/src/interactivity/win32/windowproc.cpp#L176-L219 This works well enough for conhost because it has no UI, no padding, no custom non-client area, and *absolutely* no panes (!). An implementation for Terminal will need to be quite a few times more complicated. ¹ Trivia: I think the win32k folks implemented `WM_GETDPISCALEDSIZE` just for us!
Author
Owner

@zadjii-msft commented on GitHub (Oct 15, 2021):

Yep, Dustin's got this right. I abandoned trying to get this to work right for the Terminal because I didn't think it would be generally possible. I suppose we can leave this open as an FYI, but I think we'd need someone more intimate with the way User32 and XAML re-layout for DPI changes to try and do an appropriate fix here.

@zadjii-msft commented on GitHub (Oct 15, 2021): Yep, Dustin's got this right. I abandoned trying to get this to work right for the Terminal because I didn't think it would be generally possible. I suppose we can leave this open as an FYI, but I think we'd need someone more intimate with the way User32 and XAML re-layout for DPI changes to try and do an appropriate fix here.
Author
Owner

@zadjii-msft commented on GitHub (Nov 1, 2021):

Hey, looking through the backlog, I found a dupe for this

/dup #6210

@zadjii-msft commented on GitHub (Nov 1, 2021): Hey, looking through the backlog, I found a dupe for this /dup #6210
Author
Owner

@ghost commented on GitHub (Nov 1, 2021):

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 1, 2021): 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!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#15487