From 74ccc9c2c77c206fb94c293f8e31d1db806dff09 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 27 Jun 2024 15:45:05 +0200 Subject: [PATCH] app: use empty frame when FrameEvent.Frame isn't called Signed-off-by: Elias Naur --- app/window.go | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/window.go b/app/window.go index c6c68fed..f8aee3ea 100644 --- a/app/window.go +++ b/app/window.go @@ -108,11 +108,12 @@ type Window struct { } type eventSummary struct { - wakeup bool - cfg *ConfigEvent - view *ViewEvent - frame *frameEvent - destroy *DestroyEvent + wakeup bool + cfg *ConfigEvent + view *ViewEvent + frame *frameEvent + framePending bool + destroy *DestroyEvent } type callbacks struct { @@ -219,6 +220,7 @@ func (w *Window) frame(frame *op.Ops, viewport image.Point) error { } func (w *Window) processFrame(frame *op.Ops, ack chan<- struct{}) { + w.coalesced.framePending = false wrapper := &w.decorations.Ops off := op.Offset(w.lastFrame.off).Push(wrapper) ops.AddCall(&wrapper.Internal, &frame.Internal, ops.PC{}, ops.PCFor(&frame.Internal)) @@ -563,6 +565,10 @@ func (w *Window) nextEvent() (event.Event, bool) { s.wakeup = false }() switch { + case s.framePending: + // If the user didn't call FrameEvent.Event, process + // an empty frame. + w.processFrame(new(op.Ops), nil) case s.view != nil: e := *s.view s.view = nil @@ -579,6 +585,7 @@ func (w *Window) nextEvent() (event.Event, bool) { case s.frame != nil: e := *s.frame s.frame = nil + s.framePending = true return e.FrameEvent, true case s.wakeup: return wakeupEvent{}, true