Terminal receives focus on drag n drop (#20003)

### Summary
Updates terminal to gain foreground focus when a user drags and drops a
file into the terminal.

### Changes
Updates the `DragDropHandler` to call `SetForegroundWindow`.

### Validation
* Built and deployed locally
* Manually verified terminal gains focus when dragging and dropping

Closes #19934

(cherry picked from commit a1a43a4ff5)
Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgpBND8
Service-Version: 1.25
This commit is contained in:
Ethan Balakumar
2026-03-27 16:48:01 -05:00
committed by Dustin L. Howett
parent 82d5e0cad3
commit 0252c78997
2 changed files with 10 additions and 0 deletions

View File

@@ -3088,6 +3088,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
co_return;
}
if (const auto hwnd = reinterpret_cast<HWND>(OwningHwnd()))
{
SetForegroundWindow(hwnd);
}
const auto weak = get_weak();
if (e.DataView().Contains(StandardDataFormats::ApplicationLink()))

View File

@@ -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);