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

Code before:
        //  wants to draw either nothing or the whole top part of the frame.
        // Note #2: For some reason if you try to set the top margin to just the
        //  top border height (what we want to do), then there is a transparency
        //  bug when the window is inactive, so I've decided to add the whole top
        //  part of the frame instead and then we will hide everything that we
        //  don't need (that is, the whole thing but the little 1 pixel wide border
        //  at the top) in the WM_PAINT handler. This eliminates the transparency
        //  bug and it's what a lot of Win32 apps that customize the title bar do
        //  so it should work fine.
        //
        // Note #3 (circa late 2022): It seems like we can just set this to 0,
        //  and have it work. This is LOAD-BEARING. By having the titlebar a
        //  totally empty rect, DWM will know that we don't have the traditional
        //  titlebar, and will use NCHITTEST to determine where to place the
        //  Snap Flyout. The drag rect will handle that.
        //
        //  FURTHERMORE: If we leave the titlebar visible AT ALL, then a
        //  transparent titlebar (theme.tabRow.background:#ff00ff00 for example)
        //  will allow the DWM titlebar to be visible, which will look insane.
        //  EVEN MORE SO: Mica + "show accent color on title bars" will _always_
        //  show the accent-colored strip of the titlebar, even on top of the
        //  Mica.
        //
        //  So REALLY REALLY get rid of the titlebar entirely.

        margins.cyTopHeight = 0;
    }

    // Extend the frame into the client area. microsoft/terminal#2735 - Just log
    // the failure here, don't crash. If DWM crashes for any reason, calling
    // THROW_IF_FAILED() will cause us to take a trip upstate. Just log, and
    // we'll fix ourselves when DWM comes back.
    LOG_IF_FAILED(DwmExtendFrameIntoClientArea(_window.get(), &margins));
}

// Method Description:
// - Handle window messages from the message loop.
// Arguments:
// - message: A window message ID identifying the message.
// - wParam: The contents of this parameter depend on the value of the message parameter.
// - lParam: The contents of this parameter depend on the value of the message parameter.
// Return Value:
// - The return value is the result of the message processing and depends on the
//   message sent.
[[nodiscard]] LRESULT NonClientIslandWindow::MessageHandler(UINT const message,
                                                            WPARAM const wParam,
                                                            LPARAM const lParam) noexcept
{
    switch (message)
    {
    case WM_SETCURSOR:

Review comment (suggestion):
I **need** you to test this on Windows 10 before I am comfortable signing off on it. There was a very good reason we kept this -- look for an e-mail titled "Terminal window & transparent background". It's about `DwmExtend`, but... these things are very, very related!

Code after:
        //  wants to draw either nothing or the whole top part of the frame.
        // Note #2: For some reason if you try to set the top margin to just the
        //  top border height (what we want to do), then there is a transparency
        //  bug when the window is inactive, so I've decided to add the whole top
        //  part of the frame instead and then we will hide everything that we
        //  don't need (that is, the whole thing but the little 1 pixel wide border
        //  at the top) in the WM_PAINT handler. This eliminates the transparency
        //  bug and it's what a lot of Win32 apps that customize the title bar do
        //  so it should work fine.
        //
        // Notes #3 (circa late 2022): We want to make some changes here to
        // support Mica. This introduces some complications.
        // - If we leave the titlebar visible AT ALL, then a transparent
        //   titlebar (theme.tabRow.background:#ff00ff00 for example) will allow
        //   the DWM titlebar to be visible, underneath our content. EVEN MORE
        //   SO: Mica + "show accent color on title bars" will _always_ show the
        //   accent-colored strip of the titlebar, even on top of the Mica.
        // - It _seems_ like we can just set this to 0, and have it work. You'd
        //   be wrong. On Windows 10, setting this to 0 will cause the topmost
        //   pixel of our window to be just a little darker than the rest of the
        //   frame. So ONLY set this to 0 when the user has explicitly asked for
        //   Mica. Though it won't do anything on Windows 10, they should be
        //   able to opt back out of having that weird dark pixel.
        // - This is LOAD-BEARING. By having the titlebar a totally empty rect,
        //   DWM will know that we don't have the traditional titlebar, and will
        //   use NCHITTEST to determine where to place the Snap Flyout. The drag
        //   rect will handle that.

        margins.cyTopHeight = (_useMica || _titlebarOpacity < 1.0) ? 0 : -frame.top;
    }

    // Extend the frame into the client area. microsoft/terminal#2735 - Just log
    // the failure here, don't crash. If DWM crashes for any reason, calling
    // THROW_IF_FAILED() will cause us to take a trip upstate. Just log, and
    // we'll fix ourselves when DWM comes back.
    LOG_IF_FAILED(DwmExtendFrameIntoClientArea(_window.get(), &margins));
}

// Method Description:
// - Handle window messages from the message loop.
// Arguments:
// - message: A window message ID identifying the message.
// - wParam: The contents of this parameter depend on the value of the message parameter.
// - lParam: The contents of this parameter depend on the value of the message parameter.
// Return Value:
// - The return value is the result of the message processing and depends on the
//   message sent.
[[nodiscard]] LRESULT NonClientIslandWindow::MessageHandler(UINT const message,
                                                            WPARAM const wParam,
                                                            LPARAM const lParam) noexcept
{