Repository: microsoft/terminal
File: src/cascadia/WindowsTerminal/AppHost.cpp (C++)

Code before:
    const bool isLastWindow = _windowManager.GetNumberOfPeasants() == 1;
    _windowLogic.CloseWindow(pos, isLastWindow);
}

void AppHost::_PropertyChangedHandler(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                                      const winrt::Windows::UI::Xaml::Data::PropertyChangedEventArgs& e)
{
    if (e.PropertyName() == L"TitlebarBrush")
    {
        if (_useNonClientArea)
        {
            auto nonClientWindow{ static_cast<NonClientIslandWindow*>(_window.get()) };
            nonClientWindow->SetTitlebarBackground(_windowLogic.TitlebarBrush());
            _updateTheme();
        }
    }
}

winrt::TerminalApp::TerminalWindow AppHost::Logic()
{
    return _windowLogic;
}

// Method Description:
// - Raised from Page -> us -> manager -> monarch
// - Called when the user attemtpts to move a tab or pane to another window.
//   `args` will contain info about the structure of the content being moved,
//   and where it should go.
// - If the WindowPosition is filled in, then the user was dragging a tab out of
//   this window and dropping it in empty space, indicating it should create a
//   new window. In that case, we'll make some adjustments using that info and
//   our own window info, so that the new window will be created in the right
//   place and with the same size.
void AppHost::_handleMoveContent(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                                 winrt::TerminalApp::RequestMoveContentArgs args)
{
    if (args.WindowPosition() && _window)
    {
        // The WindowPosition is in DIPs. We need to convert it to pixels.
        const til::point dragPositionInDips{ til::math::rounding, args.WindowPosition().Value() };
        const auto scale = _window->GetCurrentDpiScale();

        til::point dragPositionInPixels{
            til::math::rounding,
            dragPositionInDips.x * scale,
            dragPositionInDips.y * scale,
        };

        // Fortunately, the window position is already in pixels.
        til::rect windowBoundsInPixels{ _window->GetWindowRect() };
        til::size windowSize{ windowBoundsInPixels.size() };

Review comment (suggestion):
```suggestion
// - Called when the user attempts to move a tab or pane to another window.
```

Code after:
        if (_useNonClientArea)
        {
            auto nonClientWindow{ static_cast<NonClientIslandWindow*>(_window.get()) };
            nonClientWindow->SetTitlebarBackground(_windowLogic.TitlebarBrush());
            _updateTheme();
        }
    }
}

winrt::TerminalApp::TerminalWindow AppHost::Logic()
{
    return _windowLogic;
}

// Method Description:
// - Raised from Page -> us -> manager -> monarch
// - Called when the user attempts to move a tab or pane to another window.
//   `args` will contain info about the structure of the content being moved,
//   and where it should go.
// - If the WindowPosition is filled in, then the user was dragging a tab out of
//   this window and dropping it in empty space, indicating it should create a
//   new window. In that case, we'll make some adjustments using that info and
//   our own window info, so that the new window will be created in the right
//   place and with the same size.
void AppHost::_handleMoveContent(const winrt::Windows::Foundation::IInspectable& /*sender*/,
                                 winrt::TerminalApp::RequestMoveContentArgs args)
{
    winrt::Windows::Foundation::Rect rect{};
    winrt::Windows::Foundation::IReference<winrt::Windows::Foundation::Rect> windowBoundsReference{ nullptr };

    if (args.WindowPosition() && _window)
    {
        // The WindowPosition is in DIPs. We need to convert it to pixels.
        const til::point dragPositionInDips{ til::math::rounding, args.WindowPosition().Value() };
        const auto scale = _window->GetCurrentDpiScale();

        til::point dragPositionInPixels{
            til::math::rounding,
            dragPositionInDips.x * scale,
            dragPositionInDips.y * scale,
        };

        // Fortunately, the window position is already in pixels.
        til::rect windowBoundsInPixels{ _window->GetWindowRect() };
        til::size windowSize{ windowBoundsInPixels.size() };

        const auto dpi = _window->GetCurrentDpi();
        const auto nonClientFrame = _window->GetNonClientFrame(dpi);

        // If this window is maximized, you don't _really_ want the new window
        // showing up at the same size (the size of a maximized window). You