forked from joejulian/gio
io/input: discard pointer reset event if filter doesn't match
New handlers receive reset events the first time Source.Event is called. However, in case the filter doesn't match a reset event it shouldn't be reported. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -19,6 +19,16 @@ import (
|
||||
"gioui.org/op/clip"
|
||||
)
|
||||
|
||||
func TestFilterReset(t *testing.T) {
|
||||
r := new(Router)
|
||||
if _, ok := r.Event(pointer.Filter{}); ok {
|
||||
t.Fatal("empty filter matched reset event")
|
||||
}
|
||||
if _, ok := r.Event(pointer.Filter{Kinds: pointer.Cancel}); ok {
|
||||
t.Fatal("second call to Event matched reset event")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPointerNilTarget(t *testing.T) {
|
||||
r := new(Router)
|
||||
r.Event(pointer.Filter{Kinds: pointer.Press})
|
||||
|
||||
+1
-1
@@ -255,7 +255,7 @@ func (q *Router) Event(filters ...event.Filter) (event.Event, bool) {
|
||||
break
|
||||
}
|
||||
h := q.stateFor(f.Target)
|
||||
if reset, ok := h.pointer.ResetEvent(); ok {
|
||||
if reset, ok := h.pointer.ResetEvent(); ok && h.filter.pointer.Matches(reset) {
|
||||
return reset, true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user