summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-11-13 14:51:20 +0100
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-11-13 14:51:20 +0100
commit5b8dc40d1a02203d65755d795a831ec7565bad99 (patch)
treee5ccc661cbc9b2a3f547b7782e60e810cf8ac588
parent*Event: Add Once method (diff)
downloadwireguard-windows-5b8dc40d1a02203d65755d795a831ec7565bad99.tar.xz
wireguard-windows-5b8dc40d1a02203d65755d795a831ec7565bad99.zip
Attempt to focus a widget after layout to avoid glitches
-rw-r--r--form.go2
-rw-r--r--layout.go12
2 files changed, 12 insertions, 2 deletions
diff --git a/form.go b/form.go
index 29f06ed5..c04e1634 100644
--- a/form.go
+++ b/form.go
@@ -356,8 +356,6 @@ func (fb *FormBase) Run() int {
defer invalidateDescendentBorders()
}
- fb.clientComposite.focusFirstCandidateDescendant()
-
fb.started = true
fb.startingPublisher.Publish()
diff --git a/layout.go b/layout.go
index 2eb332ad..0b34d567 100644
--- a/layout.go
+++ b/layout.go
@@ -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()