diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-11-13 14:51:20 +0100 |
---|---|---|
committer | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-11-13 14:51:20 +0100 |
commit | 5b8dc40d1a02203d65755d795a831ec7565bad99 (patch) | |
tree | e5ccc661cbc9b2a3f547b7782e60e810cf8ac588 | |
parent | *Event: Add Once method (diff) | |
download | wireguard-windows-5b8dc40d1a02203d65755d795a831ec7565bad99.tar.xz wireguard-windows-5b8dc40d1a02203d65755d795a831ec7565bad99.zip |
Attempt to focus a widget after layout to avoid glitches
-rw-r--r-- | form.go | 2 | ||||
-rw-r--r-- | layout.go | 12 |
2 files changed, 12 insertions, 2 deletions
@@ -356,8 +356,6 @@ func (fb *FormBase) Run() int { defer invalidateDescendentBorders() } - fb.clientComposite.focusFirstCandidateDescendant() - fb.started = true fb.startingPublisher.Publish() @@ -292,6 +292,8 @@ func applyLayoutResults(results []LayoutResult, stopwatch *stopwatch) error { defer stopwatch.Stop(subject) } + var form Form + for _, result := range results { if len(result.items) == 0 { continue @@ -318,6 +320,16 @@ func applyLayoutResults(results []LayoutResult, stopwatch *stopwatch) error { continue } + if form == nil { + if form = window.Form(); form != nil { + defer func() { + if focusedWindow := windowFromHandle(win.GetFocus()); focusedWindow == nil || focusedWindow == form || focusedWindow.Form() != form { + form.AsFormBase().clientComposite.focusFirstCandidateDescendant() + } + }() + } + } + widget := window.(Widget) oldBounds := widget.BoundsPixels() |