diff --git a/app/window.go b/app/window.go index 3c0e1702..4af06280 100644 --- a/app/window.go +++ b/app/window.go @@ -44,7 +44,7 @@ type Window struct { nextFrame time.Time delayedDraw *time.Timer - queue Queue + queue queue callbacks callbacks } @@ -53,9 +53,9 @@ type callbacks struct { w *Window } -// Queue is an event.Queue implementation that distributes system events +// queue is an event.Queue implementation that distributes system events // to the input handlers declared in the most recent frame. -type Queue struct { +type queue struct { q router.Router } @@ -107,16 +107,6 @@ func (w *Window) Events() <-chan event.Event { return w.out } -// Queue returns the Window's event queue. The queue contains the events -// received since the last frame. -// -// Note: the Queue may only be used after receiving a FrameEvent and before the -// next event is received, or the FrameEvent.Frame method is called, whichever -// comes first. -func (w *Window) Queue() *Queue { - return &w.queue -} - // update updates the Window. Paint operations updates the // window contents, input operations declare input handlers, // and so on. The supplied operations list completely replaces @@ -274,6 +264,7 @@ func (w *Window) run(opts *window.Options) { frameStart := time.Now() w.hasNextFrame = false e2.Frame = w.update + e2.Queue = &w.queue w.out <- e2.FrameEvent if w.loop != nil { if e2.Sync { @@ -353,7 +344,7 @@ func (w *Window) run(opts *window.Options) { } } -func (q *Queue) Events(k event.Key) []event.Event { +func (q *queue) Events(k event.Key) []event.Event { return q.q.Events(k) } diff --git a/io/system/system.go b/io/system/system.go index fe672653..52cf45fe 100644 --- a/io/system/system.go +++ b/io/system/system.go @@ -8,11 +8,12 @@ import ( "image" "time" + "gioui.org/io/event" "gioui.org/op" "gioui.org/unit" ) -// A FrameEvent asks for a new frame in the form of a list of +// A FrameEvent requests a new frame in the form of a list of // operations. type FrameEvent struct { Config Config @@ -20,9 +21,11 @@ type FrameEvent struct { Size image.Point // Insets is the insets to apply. Insets Insets - // Frame replaces the window's frame with the new - // frame. + // Frame is the callback to supply the list of + // operations to complete the FrameEvent. Frame func(frame *op.Ops) + // Queue supplies the events for event handlers. + Queue event.Queue } // Config defines the essential properties of