~f4814n/frost

5651cdd4f4a7f83aa7e9343da80539bbb50d9815 — Fabian Geiselhart 11 months ago ba07a4a
MergeView: Seperate event passing from rendering loop
1 files changed, 22 insertions(+), 21 deletions(-)

M cmd/frost/merge_view.go
M cmd/frost/merge_view.go => cmd/frost/merge_view.go +22 -21
@@ 53,6 53,8 @@ func NewMergeView(cli *matrix.Client) *MergeView {

		log: logrus.WithField("component", "merge_view"),

		stop: make(chan struct{}),

		txL: make(chan Event, 100),
		txM: make(chan Event, 100),
		txR: make(chan Event, 100),


@@ 72,6 74,25 @@ func (o *MergeView) Start(rx, tx chan Event) {
	logStart(o.log)

	o.rx, o.tx = rx, tx

	go func() {
		for {
			select {
			case <-o.stop:
				return
			case e := <- o.rxL:
				o.receiveEvent(e)
			case e := <- o.rxM:
				o.receiveEvent(e)
			case e := <- o.rxR:
				o.receiveEvent(e)
			case e := <- o.rxO:
				o.receiveEvent(e)
			case e := <- o.rx:
				o.receiveEvent(e)
			}
		}
	}()
}

// focused returns the rightmost View


@@ 88,8 109,6 @@ func (o *MergeView) focused() View {
}

func (o *MergeView) Layout(gtx Gtx) Dims {
	o.update(gtx)

	leftsize := gtx.Px(unit.Dp(400))
	rightsize := gtx.Px(unit.Dp(400))



@@ 143,25 162,6 @@ func (o *MergeView) Layout(gtx Gtx) Dims {
	}
}

func (o *MergeView) update(gtx Gtx) {
	for {
		select {
		case e := <- o.rxL:
			o.receiveEvent(e)
		case e := <- o.rxM:
			o.receiveEvent(e)
		case e := <- o.rxR:
			o.receiveEvent(e)
		case e := <- o.rxO:
			o.receiveEvent(e)
		case e := <- o.rx:
			o.receiveEvent(e)
		default:
			return
		}
	}
}

func (o *MergeView) receiveEvent(event interface{}) {
	logEvent(o.log, event)



@@ 215,6 215,7 @@ func (o *MergeView) receiveEvent(event interface{}) {
}

func (o *MergeView) Stop() {
	close(o.stop)
}

type NoView struct{}