io/router: fix negative areas

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit is contained in:
Egon Elbre
2021-02-24 17:41:28 +02:00
committed by Elias Naur
parent cfb6f477de
commit e66979a8c0
2 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -409,7 +409,7 @@ func searchTag(tags []event.Tag, tag event.Tag) (int, bool) {
}
func opDecodeFloat32(d []byte) float32 {
return float32(binary.LittleEndian.Uint32(d))
return float32(int32(binary.LittleEndian.Uint32(d)))
}
func (op *areaOp) Decode(d []byte) {
+22
View File
@@ -57,6 +57,28 @@ func TestPointerDrag(t *testing.T) {
assertEventSequence(t, r.Events(handler), pointer.Cancel, pointer.Enter, pointer.Press, pointer.Leave, pointer.Drag)
}
func TestPointerDragNegative(t *testing.T) {
handler := new(int)
var ops op.Ops
addPointerHandler(&ops, handler, image.Rect(-100, -100, 0, 0))
var r Router
r.Frame(&ops)
r.Queue(
// Press.
pointer.Event{
Type: pointer.Press,
Position: f32.Pt(-50, -50),
},
// Move outside the area.
pointer.Event{
Type: pointer.Move,
Position: f32.Pt(-150, -150),
},
)
assertEventSequence(t, r.Events(handler), pointer.Cancel, pointer.Enter, pointer.Press, pointer.Leave, pointer.Drag)
}
func TestPointerMove(t *testing.T) {
handler1 := new(int)
handler2 := new(int)