mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 23:55:39 +00:00
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:
@@ -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 {
|
||||
|
||||
+13
-13
@@ -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{}{}
|
||||
}
|
||||
|
||||
+2
-2
@@ -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()
|
||||
}
|
||||
|
||||
+3
-6
@@ -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() {}
|
||||
|
||||
@@ -182,5 +182,4 @@ func (s Source) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
func (Event) ImplementsEvent() {}
|
||||
func (Event) ImplementsInputEvent() {}
|
||||
func (Event) ImplementsEvent() {}
|
||||
|
||||
+1
-1
@@ -38,4 +38,4 @@ func (p *ProfileOp) Decode(d []byte, refs []interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p ProfileEvent) ImplementsInputEvent() {}
|
||||
func (p ProfileEvent) ImplementsEvent() {}
|
||||
|
||||
Reference in New Issue
Block a user