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

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

Closed
ScriptKat opened this issue Oct 25, 2020 · 4 comments · Fixed by #8039
Closed

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

ScriptKat opened this issue Oct 25, 2020 · 4 comments · Fixed by #8039
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.

Comments

@ScriptKat
Copy link
Contributor

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.

@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 Oct 25, 2020
@DHowett
Copy link
Member

DHowett commented 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!

ScriptKat added a commit to Scr1ptcat/terminal that referenced this issue Oct 25, 2020
… on the height margin from dpiScale.DpiScaleX to dpiScale.DpiScaleY in Microsoft.Terminal.Wpf.TerminalControl.CalculateMargins().
@ghost ghost added the In-PR This issue has a related PR label Oct 25, 2020
@ScriptKat
Copy link
Contributor Author

ScriptKat commented 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?

@ghost ghost closed this as completed in #8039 Oct 26, 2020
ghost pushed a commit that referenced this issue Oct 26, 2020
This PR resolves an issue I observed in
Microsoft.Terminal.Wpf.TerminalControl.CalculateMargins(). Specifically,
on line 194 in the project. In this example, the line: `height =
controlSize.Height - (this.TerminalRendererSize.Height /
dpiScale.DpiScaleX);` is associating the height margin with
dpiScale.DpiScaleX instead of dpiScale.DpiScaleY. This PR changes the
association to DpiScaleY.

Closes #8038
@ghost ghost added Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Oct 26, 2020
DHowett pushed a commit that referenced this issue Oct 28, 2020
This PR resolves an issue I observed in
Microsoft.Terminal.Wpf.TerminalControl.CalculateMargins(). Specifically,
on line 194 in the project. In this example, the line: `height =
controlSize.Height - (this.TerminalRendererSize.Height /
dpiScale.DpiScaleX);` is associating the height margin with
dpiScale.DpiScaleX instead of dpiScale.DpiScaleY. This PR changes the
association to DpiScaleY.

Closes #8038

(cherry picked from commit c095a67)
@ghost
Copy link

ghost commented Nov 11, 2020

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

Handy links:

@ghost
Copy link

ghost commented Nov 11, 2020

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

Handy links:

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants