This commit is contained in:
creamy-corn 2026-03-01 21:44:06 +08:00 committed by GitHub
commit aabdb1a8ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -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
}

View file

@ -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(),