diff --git a/ui/app/app.go b/ui/app/app.go index 1f2ac07d..a9f7bbde 100644 --- a/ui/app/app.go +++ b/ui/app/app.go @@ -13,10 +13,6 @@ import ( "gioui.org/ui" ) -type Event interface { - ImplementsEvent() -} - // DrawEvent is sent when a Window's Draw // method must be called. type DrawEvent struct { diff --git a/ui/app/window.go b/ui/app/window.go index a7465733..115ca7f2 100644 --- a/ui/app/window.go +++ b/ui/app/window.go @@ -27,8 +27,8 @@ type Window struct { drawStart time.Time gpu *gpu.GPU - out chan Event - in chan Event + out chan input.Event + in chan input.Event ack chan struct{} invalidates chan struct{} frames chan *ui.Ops @@ -66,7 +66,7 @@ var _ interface { } = (*window)(nil) // Pre-allocate the ack event to avoid garbage. -var ackEvent Event +var ackEvent input.Event // NewWindow creates a new window for a set of window // options. The options are hints; the platform is free to @@ -86,8 +86,8 @@ func NewWindow(opts *WindowOptions) *Window { } w := &Window{ - in: make(chan Event), - out: make(chan Event), + in: make(chan input.Event), + out: make(chan input.Event), ack: make(chan struct{}), invalidates: make(chan struct{}, 1), frames: make(chan *ui.Ops), @@ -96,7 +96,7 @@ func NewWindow(opts *WindowOptions) *Window { return w } -func (w *Window) Events() <-chan Event { +func (w *Window) Events() <-chan input.Event { return w.out } @@ -178,7 +178,7 @@ func (w *Window) setDriver(d *window) { w.event(driverEvent{d}) } -func (w *Window) event(e Event) { +func (w *Window) event(e input.Event) { w.in <- e <-w.ack } @@ -289,18 +289,18 @@ func (w *Window) run(opts *WindowOptions) { case *CommandEvent: w.out <- e w.waitAck() - case input.Event: - if w.queue.q.Add(e2) { - w.setNextFrame(time.Time{}) - w.updateAnimation() - } - w.out <- e case driverEvent: w.driver = e2.driver case DestroyEvent: w.out <- e2 w.ack <- struct{}{} return + case input.Event: + if w.queue.q.Add(e2) { + w.setNextFrame(time.Time{}) + w.updateAnimation() + } + w.out <- e } w.ack <- struct{}{} } diff --git a/ui/input/input.go b/ui/input/input.go index 3a4c4b4e..d1bd6b3f 100644 --- a/ui/input/input.go +++ b/ui/input/input.go @@ -14,7 +14,7 @@ type Queue interface { // For a handler h, the key is typically &h. type Key interface{} -// Event is the marker interface for input events. +// Event is the marker interface for events. type Event interface { - ImplementsInputEvent() + ImplementsEvent() } diff --git a/ui/key/key.go b/ui/key/key.go index 40259af1..5c009a26 100644 --- a/ui/key/key.go +++ b/ui/key/key.go @@ -80,9 +80,6 @@ func (h HideInputOp) Add(o *ui.Ops) { o.Write(data) } -func (EditEvent) ImplementsEvent() {} -func (ChordEvent) ImplementsEvent() {} -func (FocusEvent) ImplementsEvent() {} -func (EditEvent) ImplementsInputEvent() {} -func (ChordEvent) ImplementsInputEvent() {} -func (FocusEvent) ImplementsInputEvent() {} +func (EditEvent) ImplementsEvent() {} +func (ChordEvent) ImplementsEvent() {} +func (FocusEvent) ImplementsEvent() {} diff --git a/ui/pointer/pointer.go b/ui/pointer/pointer.go index 92b43ab6..922a9588 100644 --- a/ui/pointer/pointer.go +++ b/ui/pointer/pointer.go @@ -182,5 +182,4 @@ func (s Source) String() string { } } -func (Event) ImplementsEvent() {} -func (Event) ImplementsInputEvent() {} +func (Event) ImplementsEvent() {} diff --git a/ui/system/system.go b/ui/system/system.go index 3ca5485c..51c22766 100644 --- a/ui/system/system.go +++ b/ui/system/system.go @@ -38,4 +38,4 @@ func (p *ProfileOp) Decode(d []byte, refs []interface{}) { } } -func (p ProfileEvent) ImplementsInputEvent() {} +func (p ProfileEvent) ImplementsEvent() {}