Skip to content

Commit

Permalink
app: use empty frame when FrameEvent.Frame isn't called
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Naur <[email protected]>
  • Loading branch information
eliasnaur committed Jun 27, 2024
1 parent 4e2d418 commit 3d36537
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions app/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3d36537

Please sign in to comment.