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

Lots of work is duplicated when NonClientIslandWindow is resized and the drag bar size changes #1897

Closed
zadjii-msft opened this issue Jul 9, 2019 · 3 comments · Fixed by #3394
Assignees
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@zadjii-msft
Copy link
Member

This is work that's following on from work that's being done for #1625.

I'm pulling the code for updating the drag region out of NonClientIslandWindow::OnSize into its own method. Unfortunately, both these methods need to do the following block of work:

        const auto windowRect = GetWindowRect();
        const auto width = windowRect.right - windowRect.left;
        const auto height = windowRect.bottom - windowRect.top;

        const auto scale = GetCurrentDpiScale();
        const auto dpi = ::GetDpiForWindow(_window.get());

        const auto dragY = ::GetSystemMetricsForDpi(SM_CYDRAG, dpi);
        const auto dragX = ::GetSystemMetricsForDpi(SM_CXDRAG, dpi);

        // If we're maximized, we don't want to use the frame as our margins,
        // instead we want to use the margins from the maximization. If we included
        // the left&right sides of the frame in this calculation while maximized,
        // you' have a few pixels of the window border on the sides while maximized,
        // which most apps do not have.
        const auto bordersWidth = _isMaximized ?
                                      (_maximizedMargins.cxLeftWidth + _maximizedMargins.cxRightWidth) :
                                      (dragX * 2);
        const auto bordersHeight = _isMaximized ?
                                       (_maximizedMargins.cyBottomHeight + _maximizedMargins.cyTopHeight) :
                                       (dragY * 2);

        const auto windowsWidth = width - bordersWidth;
        const auto windowsHeight = height - bordersHeight;
        const auto xPos = _isMaximized ? _maximizedMargins.cxLeftWidth : dragX;
        const auto yPos = _isMaximized ? _maximizedMargins.cyTopHeight : dragY;

        const auto dragBarRect = GetDragAreaRect();
        const auto nonClientHeight = dragBarRect.bottom - dragBarRect.top;

Doing this twice is clearly ridiculous, and more likely than not, wrong.

I'm thinking that on the resize, we could probably just cache some of these values. I think this will also important for dealing with maximizing, cause I think know the maximize borders are wrong on non-primary displays.

@zadjii-msft zadjii-msft added Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. Issue-Task It's a feature request, but it doesn't really need a major design. labels Jul 9, 2019
@zadjii-msft zadjii-msft added this to the Terminal v0.3 - Preview 2 milestone Jul 9, 2019
@ghost ghost added the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jul 9, 2019
@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jul 11, 2019
@Insomniak47
Copy link

Just wanted to pop in and confirm that your intuition re: Maximizing on non-primary windows is correct:
I've got a portrait mode 1920*1080 monitor and when I maximize on it I lose the first character of my terminal prompt line

Instead of
C:\Users\Insomniak
it's
:\Users\Insomniak

Local user mitigation is just to not maximize or do a half screen maximize and then just drag it out.

I think that this is what you were mentioning but if that isn't the case let me know and I'll file a separate issue.

@DHowett-MSFT
Copy link
Contributor

That one is known and fixed in the dev build 😄

@ghost ghost added the In-PR This issue has a related PR label Nov 2, 2019
@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Nov 4, 2019
DHowett-MSFT pushed a commit that referenced this issue Nov 4, 2019
We take the standard window frame except that we remove the top part
(see `NonClientIslandWindow::_OnNcCalcSize`), then we put little 1 pixel
wide top border back in the client area using
`DwmExtendFrameIntoClientArea` and then we put the XAML island and the
drag bar on top.

Most of this PR is comments to explain how the code works and also
removing complex code that was needed to handle the weird cases when the
borders were custom.

I've also refactored a little bit the `NonClientIslandWindow` class.

* Fix DwmExtendFrameIntoClientArea values
* Fix WM_NCHITTEST handling
* Position the XAML island window correctly
* Fix weird colors in drag bar and hide old title bar buttons
* Fix the window's position when maximized
* Add support for dark theme on the frame
* DRY shared code between conhost and new terminal
* Fix drag bar and remove dead code
* Remove dead code and use cached DPI
* Refactor code
* Remove impossible TODO
* Use system metrics instead of hardcoding resize border height
* Use theme from app settings instead of system theme. Improve comments. Remove unused DWM frame on maximize.
* Fix initial position DPI handling bug and apply review changes
* Fix thick borders with DPI > 96

Closes #3064.
Closes #1307.
Closes #3136.
Closes #1897.
Closes #3222.
Closes #1859.
@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 Nov 4, 2019
@ghost
Copy link

ghost commented Nov 26, 2019

🎉This issue was addressed in #3394, which has now been successfully released as Windows Terminal Preview v0.7.3291.0.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. 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.

3 participants