From d951d07c93cbb6b2f7362f6e3046cdc57d74c992 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 13 Jan 2022 14:59:03 +0100 Subject: [PATCH] app: don't call Window.driverDefer for direct callbacks The internal calls to ReadClipboard and WriteClipboard happen during a callback from the event loop. This change avoids the roundtrip through driverDefer. Signed-off-by: Elias Naur --- app/window.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/app/window.go b/app/window.go index b20fbfa6..164a12ee 100644 --- a/app/window.go +++ b/app/window.go @@ -235,29 +235,30 @@ func (w *Window) processFrame(d driver, frameStart time.Time) { delete(w.semantic.ids, k) } w.semantic.uptodate = false - switch w.queue.q.TextInputState() { + q := &w.queue.q + switch q.TextInputState() { case router.TextInputOpen: d.ShowTextInput(true) case router.TextInputClose: d.ShowTextInput(false) } - if hint, ok := w.queue.q.TextInputHint(); ok { + if hint, ok := q.TextInputHint(); ok { d.SetInputHint(hint) } - if txt, ok := w.queue.q.WriteClipboard(); ok { - w.WriteClipboard(txt) + if txt, ok := q.WriteClipboard(); ok { + d.WriteClipboard(txt) } - if w.queue.q.ReadClipboard() { - w.ReadClipboard() + if q.ReadClipboard() { + d.ReadClipboard() } - if w.queue.q.Profiling() && w.gpu != nil { + if q.Profiling() && w.gpu != nil { frameDur := time.Since(frameStart) frameDur = frameDur.Truncate(100 * time.Microsecond) - q := 100 * time.Microsecond - timings := fmt.Sprintf("tot:%7s %s", frameDur.Round(q), w.gpu.Profile()) - w.queue.q.Queue(profile.Event{Timings: timings}) + quantum := 100 * time.Microsecond + timings := fmt.Sprintf("tot:%7s %s", frameDur.Round(quantum), w.gpu.Profile()) + q.Queue(profile.Event{Timings: timings}) } - if t, ok := w.queue.q.WakeupTime(); ok { + if t, ok := q.WakeupTime(); ok { w.setNextFrame(t) } w.updateAnimation(d)