io/input: [API] execute commands immediately

Change the semantics of commands to execute immediately. In cases where
execution of a command introduces a inconsistency, freeze event routing
and defer the command as well as queued events to the next frame.

Rename Source.Queue to Source.Execute to better fit the new command
semantics.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-20 16:25:05 -06:00
parent 67b58a6006
commit fc208248b7
11 changed files with 190 additions and 142 deletions
+2 -3
View File
@@ -51,17 +51,16 @@ func TestDraggable(t *testing.T) {
},
)
ofr := &offer{data: "hello"}
drag.Offer(gtx, "file", ofr)
drag.Update(gtx)
r.Events(drag, transfer.TargetFilter{Type: drag.Type})
drag.Offer(gtx, "file", ofr)
r.Frame(gtx.Ops)
evs := r.Events(drag, transfer.TargetFilter{Type: drag.Type})
if len(evs) != 2 {
t.Fatalf("expected 2 event, got %d", len(evs))
t.Fatalf("expected 3 event, got %d", len(evs))
}
ev := evs[0].(transfer.DataEvent)
ev.Open = nil
if got, want := ev.Type, "file"; got != want {
t.Errorf("expected %v; got %v", got, want)
}