<h1 dir="auto">Environment</h1>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Windows build number: 18363.418
Windows Terminal version: 0.5.2762.0"><pre lang="none" class="notranslate"><code class="notranslate">Windows build number: 18363.418
Windows Terminal version: 0.5.2762.0
</code></pre></div>
<p dir="auto">If a profile is defined with an invalid commandline, or if the shell specified has been uninstalled by the user, trying to open a tab with that profile will not show any warning about the failure to launch the shell process.</p>
<p dir="auto">If the profile is defined with "closeOnExit":false, the tab will wait forever for the shell to get connected instead of showing an error message. If the profile is defined with "closeOnExit":true, the tab will immediately close with no explanation.</p>
<h1 dir="auto">Steps to reproduce</h1>
<p dir="auto">Create a profile with a non-existing shell such as the following:<br>
{<br>
// A non-existing shell<br>
"guid": "{0225F6B6-EC1C-4746-8384-A83DB214D13A}",<br>
"closeOnExit": false,<br>
"name": "dummy",<br>
"commandline": "dummyshell.exe",<br>
"hidden": false<br>
},</p>
<h1 dir="auto">Expected behavior</h1>
<p dir="auto">If the commandline cannot be launched, an error should notify the user that the process couldn't be created, so they know they have to look at the command line more closely.</p>
<h1 dir="auto">Actual behavior</h1>
<p dir="auto">Instead of some error message, Windows Terminal keeps the tab open and cursor waiting with no hint that something went wrong launching the shell, or simply silently closes the tab if "closeOnExit":true.</p>
<p dir="auto">This is work that's following on from work that's being done for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="460696043" data-permission-text="Title is private" data-url="https://github.com/microsoft/terminal/issues/1625" data-hovercard-type="issue" data-hovercard-url="/microsoft/terminal/issues/1625/hovercard" href="https://github.com/microsoft/terminal/issues/1625">#1625</a>.</p>
<p dir="auto">I'm pulling the code for updating the drag region out of <code class="notranslate">NonClientIslandWindow::OnSize</code> into its own method. Unfortunately, both these methods need to do the following block of work:</p>
<div class="highlight highlight-source-c++ notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
        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&amp;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;"><pre class="notranslate">        <span class="pl-k">const</span> <span class="pl-k">auto</span> windowRect = GetWindowRect();
        <span class="pl-k">const</span> <span class="pl-k">auto</span> width = windowRect.right - windowRect.left;
        <span class="pl-k">const</span> <span class="pl-k">auto</span> height = windowRect.bottom - windowRect.top;

        <span class="pl-k">const</span> <span class="pl-k">auto</span> scale = GetCurrentDpiScale();
        <span class="pl-k">const</span> <span class="pl-k">auto</span> dpi = ::GetDpiForWindow(_window.get());

        <span class="pl-k">const</span> <span class="pl-k">auto</span> dragY = ::GetSystemMetricsForDpi(SM_CYDRAG, dpi);
        <span class="pl-k">const</span> <span class="pl-k">auto</span> dragX = ::GetSystemMetricsForDpi(SM_CXDRAG, dpi);

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

        <span class="pl-k">const</span> <span class="pl-k">auto</span> windowsWidth = width - bordersWidth;
        <span class="pl-k">const</span> <span class="pl-k">auto</span> windowsHeight = height - bordersHeight;
        <span class="pl-k">const</span> <span class="pl-k">auto</span> xPos = _isMaximized ? _maximizedMargins.cxLeftWidth : dragX;
        <span class="pl-k">const</span> <span class="pl-k">auto</span> yPos = _isMaximized ? _maximizedMargins.cyTopHeight : dragY;

        <span class="pl-k">const</span> <span class="pl-k">auto</span> dragBarRect = GetDragAreaRect();
        <span class="pl-k">const</span> <span class="pl-k">auto</span> nonClientHeight = dragBarRect.bottom - dragBarRect.top;</pre></div>
<p dir="auto">Doing this twice is clearly ridiculous, and more likely than not, <em>wrong</em>.</p>
<p dir="auto">I'm thinking that on the resize, we could <em>probably</em> just cache some of these values. I think this will also important for dealing with maximizing, cause I <del>think</del> know the maximize borders are wrong on non-primary displays.</p>