mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 08:55:35 +00:00
io/router: deduplicate pointer handlers
When the same handler is added several times and that handler sets pointer.Grabbed, it gets lost. Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
+11
-1
@@ -214,7 +214,7 @@ func (q *pointerQueue) opHit(handlers *[]event.Tag, pos f32.Point) {
|
||||
}
|
||||
if n.tag != nil {
|
||||
if _, exists := q.handlers[n.tag]; exists {
|
||||
*handlers = append(*handlers, n.tag)
|
||||
*handlers = addHandler(*handlers, n.tag)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -473,6 +473,16 @@ func searchTag(tags []event.Tag, tag event.Tag) (int, bool) {
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// addHandler adds tag to the slice if not present.
|
||||
func addHandler(tags []event.Tag, tag event.Tag) []event.Tag {
|
||||
for _, t := range tags {
|
||||
if t == tag {
|
||||
return tags
|
||||
}
|
||||
}
|
||||
return append(tags, tag)
|
||||
}
|
||||
|
||||
func opDecodeFloat32(d []byte) float32 {
|
||||
return float32(int32(binary.LittleEndian.Uint32(d)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user