mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 18:35:34 +00:00
app: move frame waiting code out of Window.run to a separate method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+16
-10
@@ -214,6 +214,21 @@ func (w *Window) destroyGPU() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// waitFrame waits for the client to either call FrameEvent.Frame
|
||||||
|
// or to continue event handling. It returns whether the client
|
||||||
|
// called Frame or not.
|
||||||
|
func (w *Window) waitFrame() (*op.Ops, bool) {
|
||||||
|
select {
|
||||||
|
case frame := <-w.frames:
|
||||||
|
// The client called FrameEvent.Frame.
|
||||||
|
return frame, true
|
||||||
|
case w.out <- ackEvent:
|
||||||
|
// The client ignored FrameEvent and continued processing
|
||||||
|
// events.
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (w *Window) run(opts *window.Options) {
|
func (w *Window) run(opts *window.Options) {
|
||||||
defer close(w.in)
|
defer close(w.in)
|
||||||
defer close(w.out)
|
defer close(w.out)
|
||||||
@@ -271,16 +286,7 @@ func (w *Window) run(opts *window.Options) {
|
|||||||
w.loop.Refresh()
|
w.loop.Refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var frame *op.Ops
|
frame, gotFrame := w.waitFrame()
|
||||||
// Wait for either a frame or an ack event to go
|
|
||||||
// through, which means that the client didn't give us
|
|
||||||
// a frame.
|
|
||||||
gotFrame := false
|
|
||||||
select {
|
|
||||||
case frame = <-w.frames:
|
|
||||||
gotFrame = true
|
|
||||||
case w.out <- ackEvent:
|
|
||||||
}
|
|
||||||
var err error
|
var err error
|
||||||
for {
|
for {
|
||||||
if w.loop != nil {
|
if w.loop != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user