diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index 5df13ed98..28b97b239 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -951,6 +951,14 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC win32.ShowWindow(f.mainWindow.Handle()) } + // Ensure initial keyboard focus goes into the WebView so typing works without a click. + if !f.frontendOptions.StartHidden && f.frontendOptions.WindowStartState != options.Minimised { + if ctrl := f.chromium.GetController(); ctrl != nil { + _ = ctrl.MoveFocus(edge.COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC) + // _ = ctrl.MoveFocus(0) + } + } + f.mainWindow.hasBeenShown = true } diff --git a/v2/internal/frontend/desktop/windows/window.go b/v2/internal/frontend/desktop/windows/window.go index b04d61814..f745435bc 100644 --- a/v2/internal/frontend/desktop/windows/window.go +++ b/v2/internal/frontend/desktop/windows/window.go @@ -237,6 +237,14 @@ func (w *Window) WndProc(msg uint32, wparam, lparam uintptr) uintptr { //} } + if w.isActive && w.chromium != nil { + if ctrl := w.chromium.GetController(); ctrl != nil { + // Push keyboard focus into WebView2 when activated + _ = ctrl.MoveFocus(edge.COREWEBVIEW2_MOVE_FOCUS_REASON_PROGRAMMATIC) + // _ = ctrl.MoveFocus(0) // fallback if your bindings lack the constant + } + } + case 0x02E0: //w32.WM_DPICHANGED newWindowSize := (*w32.RECT)(unsafe.Pointer(lparam)) w32.SetWindowPos(w.Handle(),