io/router: deliver enter/leave events to transfer participants

When a drag and drop gesture is ongoing, let the potential target
handlers receive enter/leave events so that they can react to them (e.g.
highlight themselves when the dragged item is over them).

Fixes #321.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
Pierre Curto
2021-12-10 10:44:26 +01:00
committed by Elias Naur
parent c8ca36b1e6
commit 929e4dc120
2 changed files with 51 additions and 2 deletions
+13 -2
View File
@@ -674,9 +674,20 @@ func (q *pointerQueue) deliverEnterLeaveEvents(p *pointerInfo, events *handlerEv
} else {
hits = q.opHit(e.Position)
if p.pressed {
// Filter out non-participating handlers.
// Filter out non-participating handlers,
// except potential transfer targets when a transfer has been initiated.
var transferSource *pointerHandler
if p.dataSource != nil {
transferSource = q.handlers[p.dataSource]
}
for i := len(hits) - 1; i >= 0; i-- {
if _, found := searchTag(p.handlers, hits[i]); !found {
tag := hits[i]
if transferSource != nil {
if _, ok := firstMimeMatch(transferSource, q.handlers[tag]); ok {
continue
}
}
if _, found := searchTag(p.handlers, tag); !found {
hits = append(hits[:i], hits[i+1:]...)
}
}