~eliasnaur

Trackers

~eliasnaur/gio

Last active 5 days ago

#550 Overhaul of event routing 18 hours ago

Comment by ~eliasnaur on ~eliasnaur/gio

~jeffwilliams: thanks, fixed in ab776c65.

#550 Overhaul of event routing 20 hours ago

on ~eliasnaur/gio

~eliasnaur: Thanks, I think the last method in the newsletter should work. I found one more minor documentation bug. The documentation for io/clipboard.ReadCmd reads "ReadCmd requests the text of the clipboard, delivered to the handler through an op/transfer.DataEvent", but I think it should instead be io/transfer.DataEvent if I am not mistaken.

#550 Overhaul of event routing a day ago

Comment by ~eliasnaur on ~eliasnaur/gio

Yes, you need to fill out the pointer.Filter.Target field to receive events:

pointer.Filter{Target: l, Kinds: pointer.Press | pointer.Drag | pointer.Release | pointer.Cancel},

Before my fix, nil targets would work by accident.

#550 Overhaul of event routing a day ago

on ~eliasnaur/gio

~eliasnaur

go get gioui.org@7392d2ff

Unable to receive any pointer events.

https://go.dev/play/p/GweMCrv5A9x

#550 Overhaul of event routing a day ago

Comment by ~eliasnaur on ~eliasnaur/gio

~jeffwilliams: updated documentation, thanks. ~whereswaldon covers the options for refactoring channel-based events loops in his latest newsletter[0]. ~beikege: another great find, thanks (the issue was the unexpected nil pointer.Filter.Target). Fixed and added test.

Latest version: go get gioui.org@7392d2ff

[0] https://gioui.org/news/2023-11#api-change-window-event-iteration

#550 Overhaul of event routing 2 days ago

Comment by ~eliasnaur on ~eliasnaur/gio

What do you think of the names introduced? In particular, Source.Event? If it's all good, I shall rename app.Window.NextEvent to match.

#550 Overhaul of event routing 3 days ago

Comment by ~eliasnaur on ~eliasnaur/gio

~beikege: another good catch, thank you. ~egonelbre: thanks, fixed.

go get gioui.org@86fe42a4372c215b should fix both issues.

#550 Overhaul of event routing 3 days ago

on ~eliasnaur/gio

~eliasnaur, the use of Optional works fine. thanks. Giocanvas and its clients are now converted. Overall the new API seems at bit cleaner and more straightforward.

New: https://gist.github.com/ajstarks/ef633da557c4f90429990d66f0f6c7c6

Old: https://gist.github.com/ajstarks/9224ad09306ecb240c6618bf32da45e6

Diff:

2c2
< func kbpointer(q event.Queue, cfg config) {
---
> func kbpointer(q input.Source, cfg config) {
6,9c6,18
< 	for _, ev := range q.Events(pressed) {
< 		// keyboard events
< 		if k, ok := ev.(key.Event); ok {
< 			switch k.State {
---
> 	for {
> 		e, ok := q.Event(
> 			key.Filter{Optional: key.ModCtrl},
> 			pointer.Filter{Kinds: pointer.Press | pointer.Move | pointer.Release},
> 		)
> 		if !ok {
> 			break
> 		}
> 		switch e := e.(type) {
> 
> 		case key.Event: // keyboard events
> 
> 			switch e.State {
11c20
< 				switch k.Name {
---
> 				switch e.Name {
31c40
< 					switch k.Modifiers {
---
> 					switch e.Modifiers {
38c47
< 					switch k.Modifiers {
---
> 					switch e.Modifiers {
45c54
< 					switch k.Modifiers {
---
> 					switch e.Modifiers {
52c61
< 					switch k.Modifiers {
---
> 					switch e.Modifiers {
62,65c71,74
< 		}
< 		// pointer events
< 		if p, ok := ev.(pointer.Event); ok {
< 			switch p.Kind {
---
> 
> 		case pointer.Event: // pointer events
> 
> 			switch e.Kind {
67c76
< 				mouseX, mouseY = pctcoord(p.Position.X, p.Position.Y, width, height)
---
> 				mouseX, mouseY = pctcoord(e.Position.X, e.Position.Y, width, height)
69c78
< 				switch p.Buttons {
---
> 				switch e.Buttons {
71c80
< 					bx, by = pctcoord(p.Position.X, p.Position.Y, width, height)
---
> 					bx, by = pctcoord(e.Position.X, e.Position.Y, width, height)
73c82
< 					ex, ey = pctcoord(p.Position.X, p.Position.Y, width, height)
---
> 					ex, ey = pctcoord(e.Position.X, e.Position.Y, width, height)
77d85
< 				pressed = true
96c104
< 		case system.DestroyEvent:
---
> 		case app.DestroyEvent:
100,103c108,109
< 		case system.FrameEvent:
< 			canvas := giocanvas.NewCanvas(float32(e.Size.X), float32(e.Size.Y), system.FrameEvent{})
< 			key.InputOp{Tag: pressed}.Add(canvas.Context.Ops)
< 			pointer.InputOp{Tag: pressed, Grab: false, Kinds: pointer.Press | pointer.Move}.Add(canvas.Context.Ops)
---
> 		case app.FrameEvent:
> 			canvas := giocanvas.NewCanvas(float32(e.Size.X), float32(e.Size.Y), app.FrameEvent{})
143c149
< 			kbpointer(e.Queue, cfg)
---
> 			kbpointer(e.Source, cfg)

also in giocanvas abs.go, changed

op.InvalidateOp{}.Add(ops)

to

c.Context.Execute(op.InvalidateCmd{})

#550 Overhaul of event routing 3 days ago

Comment by ~eliasnaur on ~eliasnaur/gio

~ajstarks: use the Optional field of key.Filter instead of Required.

#550 Overhaul of event routing 4 days ago

on ~eliasnaur/gio

~eliasnaur

https://go.dev/play/p/HFJWhntO9Ua

go get gioui.org@cf3e0c744246b4ae

Android Scrolling the list causes infinite frame refreshes.

Use adb logcat to view logs.


go get gioui.org@45277db

Works perfectly, thank you.