mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
io/router: always choose the topmost cursor among candidates
Fixes: https://todo.sr.ht/~eliasnaur/gio/373 Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -725,14 +725,18 @@ func (q *pointerQueue) deliverEnterLeaveEvents(p *pointerInfo, events *handlerEv
|
|||||||
}
|
}
|
||||||
// Deliver Enter events and update cursor.
|
// Deliver Enter events and update cursor.
|
||||||
q.cursor = pointer.CursorDefault
|
q.cursor = pointer.CursorDefault
|
||||||
|
cursorFound := false
|
||||||
for _, k := range hits {
|
for _, k := range hits {
|
||||||
h := q.handlers[k]
|
h := q.handlers[k]
|
||||||
|
if !cursorFound {
|
||||||
for i := len(q.cursors) - 1; i >= 0; i-- {
|
for i := len(q.cursors) - 1; i >= 0; i-- {
|
||||||
if c := q.cursors[i]; c.area == h.area {
|
if c := q.cursors[i]; c.area == h.area {
|
||||||
q.cursor = c.cursor
|
q.cursor = c.cursor
|
||||||
|
cursorFound = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if _, found := searchTag(p.entered, k); found {
|
if _, found := searchTag(p.entered, k); found {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1109,6 +1109,33 @@ func TestDeferredInputOp(t *testing.T) {
|
|||||||
r.Frame(&ops)
|
r.Frame(&ops)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPassCursor(t *testing.T) {
|
||||||
|
var ops op.Ops
|
||||||
|
var r Router
|
||||||
|
|
||||||
|
rect := clip.Rect(image.Rect(0, 0, 100, 100))
|
||||||
|
background := rect.Push(&ops)
|
||||||
|
pointer.InputOp{Tag: 1}.Add(&ops)
|
||||||
|
pointer.CursorDefault.Add(&ops)
|
||||||
|
background.Pop()
|
||||||
|
|
||||||
|
overlayPass := pointer.PassOp{}.Push(&ops)
|
||||||
|
overlay := rect.Push(&ops)
|
||||||
|
pointer.InputOp{Tag: 2}.Add(&ops)
|
||||||
|
want := pointer.CursorPointer
|
||||||
|
want.Add(&ops)
|
||||||
|
overlay.Pop()
|
||||||
|
overlayPass.Pop()
|
||||||
|
r.Frame(&ops)
|
||||||
|
r.Queue(pointer.Event{
|
||||||
|
Position: f32.Pt(10, 10),
|
||||||
|
Type: pointer.Move,
|
||||||
|
})
|
||||||
|
if got := r.Cursor(); want != got {
|
||||||
|
t.Errorf("got cursor %v, want %v", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user