From 3d36537ad6d65d5f3fd1b8ccccb188e9feb126ee 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 81193cb0..ba8d8eac 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)) @@ -567,6 +569,10 @@ func (w *Window) nextEvent() (event.Event, bool) { w.mayInvalidate = (w.mayInvalidate || mayInvalidate) && w.driver != nil }() 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 @@ -583,6 +589,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