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 <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-01-13 14:59:03 +01:00
parent 72c48a3c18
commit d951d07c93
+12 -11
View File
@@ -235,29 +235,30 @@ func (w *Window) processFrame(d driver, frameStart time.Time) {
delete(w.semantic.ids, k) delete(w.semantic.ids, k)
} }
w.semantic.uptodate = false w.semantic.uptodate = false
switch w.queue.q.TextInputState() { q := &w.queue.q
switch q.TextInputState() {
case router.TextInputOpen: case router.TextInputOpen:
d.ShowTextInput(true) d.ShowTextInput(true)
case router.TextInputClose: case router.TextInputClose:
d.ShowTextInput(false) d.ShowTextInput(false)
} }
if hint, ok := w.queue.q.TextInputHint(); ok { if hint, ok := q.TextInputHint(); ok {
d.SetInputHint(hint) d.SetInputHint(hint)
} }
if txt, ok := w.queue.q.WriteClipboard(); ok { if txt, ok := q.WriteClipboard(); ok {
w.WriteClipboard(txt) d.WriteClipboard(txt)
} }
if w.queue.q.ReadClipboard() { if q.ReadClipboard() {
w.ReadClipboard() d.ReadClipboard()
} }
if w.queue.q.Profiling() && w.gpu != nil { if q.Profiling() && w.gpu != nil {
frameDur := time.Since(frameStart) frameDur := time.Since(frameStart)
frameDur = frameDur.Truncate(100 * time.Microsecond) frameDur = frameDur.Truncate(100 * time.Microsecond)
q := 100 * time.Microsecond quantum := 100 * time.Microsecond
timings := fmt.Sprintf("tot:%7s %s", frameDur.Round(q), w.gpu.Profile()) timings := fmt.Sprintf("tot:%7s %s", frameDur.Round(quantum), w.gpu.Profile())
w.queue.q.Queue(profile.Event{Timings: timings}) q.Queue(profile.Event{Timings: timings})
} }
if t, ok := w.queue.q.WakeupTime(); ok { if t, ok := q.WakeupTime(); ok {
w.setNextFrame(t) w.setNextFrame(t)
} }
w.updateAnimation(d) w.updateAnimation(d)