io/router: ensure root pointer area in deferred calls

Fixes: https://todo.sr.ht/~eliasnaur/gio/372
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-03-07 12:08:08 +01:00
parent b82427d412
commit 68544111c1
2 changed files with 17 additions and 1 deletions
+5 -1
View File
@@ -141,6 +141,11 @@ const (
func (c *pointerCollector) resetState() { func (c *pointerCollector) resetState() {
c.state = collectState{} c.state = collectState{}
c.nodeStack = c.nodeStack[:0]
// Pop every node except the root.
if len(c.q.hitTree) > 0 {
c.state.nodePlusOne = 0 + 1
}
} }
func (c *pointerCollector) setTrans(t f32.Affine2D) { func (c *pointerCollector) setTrans(t f32.Affine2D) {
@@ -332,7 +337,6 @@ func (c *pointerCollector) offerOp(op transfer.OfferOp, events *handlerEvents) {
func (c *pointerCollector) reset() { func (c *pointerCollector) reset() {
c.q.reset() c.q.reset()
c.resetState() c.resetState()
c.nodeStack = c.nodeStack[:0]
c.ensureRoot() c.ensureRoot()
} }
+12
View File
@@ -1097,6 +1097,18 @@ func TestTransfer(t *testing.T) {
}) })
} }
func TestDeferredInputOp(t *testing.T) {
var ops op.Ops
var r Router
m := op.Record(&ops)
key.InputOp{Tag: new(int)}.Add(&ops)
call := m.Stop()
op.Defer(&ops, call)
r.Frame(&ops)
}
// offer satisfies io.ReadCloser for use in data transfers. // offer satisfies io.ReadCloser for use in data transfers.
type offer struct { type offer struct {
data string data string