5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 06:20:48 +08:00

Try to focus window when Show() is called. (#1212)

* Try to focus window when Show() is called.

* Ensure Focus is regained by Webview2 when tabbing

* Run restore code on main thread
This commit is contained in:
Lea Anthony 2022-03-15 20:16:38 +11:00 committed by GitHub
parent 60c6dce07d
commit a278c9e164
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -181,7 +181,7 @@ func (f *Frontend) WindowUnfullscreen() {
func (f *Frontend) WindowShow() { func (f *Frontend) WindowShow() {
runtime.LockOSThread() runtime.LockOSThread()
f.mainWindow.Show() f.ShowWindow()
} }
func (f *Frontend) WindowHide() { func (f *Frontend) WindowHide() {
@ -518,20 +518,31 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
} else { } else {
f.mainWindow.Show() f.mainWindow.Show()
} }
f.ShowWindow()
case options.Minimised: case options.Minimised:
f.mainWindow.Minimise() f.mainWindow.Minimise()
case options.Fullscreen: case options.Fullscreen:
f.mainWindow.Fullscreen() f.mainWindow.Fullscreen()
f.mainWindow.Show() f.ShowWindow()
default: default:
if f.frontendOptions.Fullscreen { if f.frontendOptions.Fullscreen {
f.mainWindow.Fullscreen() f.mainWindow.Fullscreen()
} }
f.mainWindow.Show() f.ShowWindow()
} }
} }
func (f *Frontend) ShowWindow() {
f.mainWindow.Invoke(func() {
f.mainWindow.Restore()
w32.SetForegroundWindow(f.mainWindow.Handle())
w32.SetFocus(f.mainWindow.Handle())
})
}
func (f *Frontend) onFocus(arg *winc.Event) { func (f *Frontend) onFocus(arg *winc.Event) {
f.chromium.Focus() f.chromium.Focus()
} }