A margin variable is being constrained by dpi scale X instead of dpi Scale Y #11171

Closed
opened 2026-01-31 02:40:31 +00:00 by claunia · 4 comments
Owner

Originally created by @ScriptKat on GitHub (Oct 25, 2020).

Environment

Major Minor Build Revision


10 0 19041 546

Steps to reproduce

I noticed an issue while reading through: Microsoft.Terminal.Wpf.TerminalControl.CalculateMargins(). Specifically, on line 194 in the project. In this example, it is the line - height = controlSize.Height - (this.TerminalRendererSize.Height / dpiScale.DpiScaleX); :

private Thickness CalculateMargins(Size controlSize = default)
{
var dpiScale = VisualTreeHelper.GetDpi(this);
double width = 0, height = 0;

        if (controlSize == default)
        {
            controlSize = new Size()
            {
                Width = this.terminalUserControl.ActualWidth,
                Height = this.terminalUserControl.ActualHeight,
            };
        }

        // During initialization, the terminal renderer size will be 0 and the terminal renderer
        // draws on all available space. Therefore no margins are needed until resized.
        if (this.TerminalRendererSize.Width != 0)
        {
            width = controlSize.Width - (this.TerminalRendererSize.Width / dpiScale.DpiScaleX);
        }

        if (this.TerminalRendererSize.Height != 0)
        {
            height = controlSize.Height - (this.TerminalRendererSize.Height / dpiScale.DpiScaleX);
        }

        width -= this.scrollbar.ActualWidth;

        // Prevent negative margin size.
        width = width < 0 ? 0 : width;
        height = height < 0 ? 0 : height;

        return new Thickness(0, 0, width, height);
    } 

Expected behavior

Shouldn't height be constrained by dpiScale.DpiScaleY and not dpiScale.DpiScaleX?

Actual behavior

Height appears to be associated with dpiScale.DpiScaleX instead of dpiScale.DpiScaleY.

I'm happy to help change the variable if others agree that this is an issue.

Originally created by @ScriptKat on GitHub (Oct 25, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment Major Minor Build Revision ----- ----- ----- -------- 10 0 19041 546 # Steps to reproduce I noticed an issue while reading through: Microsoft.Terminal.Wpf.TerminalControl.CalculateMargins(). Specifically, on line 194 in the project. In this example, it is the line - height = controlSize.Height - (this.TerminalRendererSize.Height / dpiScale.DpiScaleX); : private Thickness CalculateMargins(Size controlSize = default) { var dpiScale = VisualTreeHelper.GetDpi(this); double width = 0, height = 0; if (controlSize == default) { controlSize = new Size() { Width = this.terminalUserControl.ActualWidth, Height = this.terminalUserControl.ActualHeight, }; } // During initialization, the terminal renderer size will be 0 and the terminal renderer // draws on all available space. Therefore no margins are needed until resized. if (this.TerminalRendererSize.Width != 0) { width = controlSize.Width - (this.TerminalRendererSize.Width / dpiScale.DpiScaleX); } if (this.TerminalRendererSize.Height != 0) { height = controlSize.Height - (this.TerminalRendererSize.Height / dpiScale.DpiScaleX); } width -= this.scrollbar.ActualWidth; // Prevent negative margin size. width = width < 0 ? 0 : width; height = height < 0 ? 0 : height; return new Thickness(0, 0, width, height); } # Expected behavior Shouldn't height be constrained by dpiScale.DpiScaleY and not dpiScale.DpiScaleX? # Actual behavior Height appears to be associated with dpiScale.DpiScaleX instead of dpiScale.DpiScaleY. I'm happy to help change the variable if others agree that this is an issue.
claunia added the Needs-TriageResolution-Fix-CommittedNeeds-Tag-Fix labels 2026-01-31 02:40:31 +00:00
Author
Owner

@DHowett commented on GitHub (Oct 25, 2020):

Good catch! I’m not aware of any situations in which Windows will scale the display differently in each axis, but it would be good for us to get this right regardless. Feel free to submit a PR!

@DHowett commented on GitHub (Oct 25, 2020): Good catch! I’m not aware of any situations in which Windows will scale the display differently in each axis, but it would be good for us to get this right regardless. Feel free to submit a PR!
Author
Owner

@ScriptKat commented on GitHub (Oct 26, 2020):

@DHowett Thanks! I opened a PR, but noticed four of the automated checks failed.. i'm new to contributing to this repo, so am not sure why that may have happened? I submitted another very small PR of similar scope about 40 minutes later and everything passed, so am not sure what in this PR specifically caused some of the checks to fail.. or does the CICD system have issues intermittently?I notice looking through the logs that the checks were failing at the step to restore packages.. is there any way to re-trigger it if it fails outside of updating the PR?

@ScriptKat commented on GitHub (Oct 26, 2020): @DHowett Thanks! I opened a PR, but noticed four of the automated checks failed.. i'm new to contributing to this repo, so am not sure why that may have happened? I submitted another very small PR of similar scope about 40 minutes later and everything passed, so am not sure what in this PR specifically caused some of the checks to fail.. or does the CICD system have issues intermittently?I notice looking through the logs that the checks were failing at the step to restore packages.. is there any way to re-trigger it if it fails outside of updating the PR?
Author
Owner

@ghost commented on GitHub (Nov 11, 2020):

:tada:This issue was addressed in #8039, which has now been successfully released as Windows Terminal v1.4.3141.0.🎉

Handy links:

@ghost commented on GitHub (Nov 11, 2020): :tada:This issue was addressed in #8039, which has now been successfully released as `Windows Terminal v1.4.3141.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.4.3141.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Nov 11, 2020):

:tada:This issue was addressed in #8039, which has now been successfully released as Windows Terminal Preview v1.5.3142.0.🎉

Handy links:

@ghost commented on GitHub (Nov 11, 2020): :tada:This issue was addressed in #8039, which has now been successfully released as `Windows Terminal Preview v1.5.3142.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.5.3142.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11171