Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3073,6 +3073,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
co_return;
}

if (const auto hwnd = reinterpret_cast<HWND>(OwningHwnd()))
{
SetForegroundWindow(hwnd);
Copy link
Copy Markdown
Member

@lhecker lhecker Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind also adding this here?

void Window::_HandleDrop(const WPARAM wParam) const
{
const auto drop = reinterpret_cast<HDROP>(wParam);
Clipboard::Instance().PasteDrop(drop);
DragFinish(drop);
}

Something like this:

if (const auto hwnd = GetWindowHandle())
{
    SetForegroundWindow(hwnd);
}

This way, even the old conhost (the classic console window) would get this improvement. You can test conhost by setting Conhost\Host.EXE as your startup project.

...I'm not sure if it'll work though, given that it relies on WM_DROPFILES and not OLE.

Thank you for working on this!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added! Looks like it was just as easy as calling SetForegroundWindow again.

}

const auto weak = get_weak();

if (e.DataView().Contains(StandardDataFormats::ApplicationLink()))
Expand Down
5 changes: 5 additions & 0 deletions src/interactivity/win32/windowproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,11 @@ LRESULT Window::_HandleGetDpiScaledSize(UINT dpiNew, _Inout_ SIZE* pSizeNew) con
// - <none>
void Window::_HandleDrop(const WPARAM wParam) const
{
if (const auto hwnd = GetWindowHandle())
{
SetForegroundWindow(hwnd);
}

const auto drop = reinterpret_cast<HDROP>(wParam);
Clipboard::Instance().PasteDrop(drop);
DragFinish(drop);
Expand Down
Loading