ui/app: drop Event

input.Event is enough if we stretch "input" to mean both input
devices and other events such as profiling events and system
commands.

The pointer and key packages are separate already, so I don't
expanding the meaning is unreasonable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-08-01 15:27:14 +02:00
parent 69bba3aa4b
commit cb312c8d32
6 changed files with 20 additions and 28 deletions
-4
View File
@@ -13,10 +13,6 @@ import (
"gioui.org/ui" "gioui.org/ui"
) )
type Event interface {
ImplementsEvent()
}
// DrawEvent is sent when a Window's Draw // DrawEvent is sent when a Window's Draw
// method must be called. // method must be called.
type DrawEvent struct { type DrawEvent struct {
+13 -13
View File
@@ -27,8 +27,8 @@ type Window struct {
drawStart time.Time drawStart time.Time
gpu *gpu.GPU gpu *gpu.GPU
out chan Event out chan input.Event
in chan Event in chan input.Event
ack chan struct{} ack chan struct{}
invalidates chan struct{} invalidates chan struct{}
frames chan *ui.Ops frames chan *ui.Ops
@@ -66,7 +66,7 @@ var _ interface {
} = (*window)(nil) } = (*window)(nil)
// Pre-allocate the ack event to avoid garbage. // 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 // NewWindow creates a new window for a set of window
// options. The options are hints; the platform is free to // options. The options are hints; the platform is free to
@@ -86,8 +86,8 @@ func NewWindow(opts *WindowOptions) *Window {
} }
w := &Window{ w := &Window{
in: make(chan Event), in: make(chan input.Event),
out: make(chan Event), out: make(chan input.Event),
ack: make(chan struct{}), ack: make(chan struct{}),
invalidates: make(chan struct{}, 1), invalidates: make(chan struct{}, 1),
frames: make(chan *ui.Ops), frames: make(chan *ui.Ops),
@@ -96,7 +96,7 @@ func NewWindow(opts *WindowOptions) *Window {
return w return w
} }
func (w *Window) Events() <-chan Event { func (w *Window) Events() <-chan input.Event {
return w.out return w.out
} }
@@ -178,7 +178,7 @@ func (w *Window) setDriver(d *window) {
w.event(driverEvent{d}) w.event(driverEvent{d})
} }
func (w *Window) event(e Event) { func (w *Window) event(e input.Event) {
w.in <- e w.in <- e
<-w.ack <-w.ack
} }
@@ -289,18 +289,18 @@ func (w *Window) run(opts *WindowOptions) {
case *CommandEvent: case *CommandEvent:
w.out <- e w.out <- e
w.waitAck() w.waitAck()
case input.Event:
if w.queue.q.Add(e2) {
w.setNextFrame(time.Time{})
w.updateAnimation()
}
w.out <- e
case driverEvent: case driverEvent:
w.driver = e2.driver w.driver = e2.driver
case DestroyEvent: case DestroyEvent:
w.out <- e2 w.out <- e2
w.ack <- struct{}{} w.ack <- struct{}{}
return return
case input.Event:
if w.queue.q.Add(e2) {
w.setNextFrame(time.Time{})
w.updateAnimation()
}
w.out <- e
} }
w.ack <- struct{}{} w.ack <- struct{}{}
} }
+2 -2
View File
@@ -14,7 +14,7 @@ type Queue interface {
// For a handler h, the key is typically &h. // For a handler h, the key is typically &h.
type Key interface{} type Key interface{}
// Event is the marker interface for input events. // Event is the marker interface for events.
type Event interface { type Event interface {
ImplementsInputEvent() ImplementsEvent()
} }
+3 -6
View File
@@ -80,9 +80,6 @@ func (h HideInputOp) Add(o *ui.Ops) {
o.Write(data) o.Write(data)
} }
func (EditEvent) ImplementsEvent() {} func (EditEvent) ImplementsEvent() {}
func (ChordEvent) ImplementsEvent() {} func (ChordEvent) ImplementsEvent() {}
func (FocusEvent) ImplementsEvent() {} func (FocusEvent) ImplementsEvent() {}
func (EditEvent) ImplementsInputEvent() {}
func (ChordEvent) ImplementsInputEvent() {}
func (FocusEvent) ImplementsInputEvent() {}
+1 -2
View File
@@ -182,5 +182,4 @@ func (s Source) String() string {
} }
} }
func (Event) ImplementsEvent() {} func (Event) ImplementsEvent() {}
func (Event) ImplementsInputEvent() {}
+1 -1
View File
@@ -38,4 +38,4 @@ func (p *ProfileOp) Decode(d []byte, refs []interface{}) {
} }
} }
func (p ProfileEvent) ImplementsInputEvent() {} func (p ProfileEvent) ImplementsEvent() {}