mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
ui/app: use the delayed redraw timer directly in the Window run loop
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+9
-2
@@ -60,7 +60,7 @@ var _ interface {
|
|||||||
setTextInput(s key.TextInputState)
|
setTextInput(s key.TextInputState)
|
||||||
} = (*window)(nil)
|
} = (*window)(nil)
|
||||||
|
|
||||||
// Pre-allocate zero-sized ack event to avoid garbage.
|
// Pre-allocate the ack event to avoid garbage.
|
||||||
var ackEvent Event
|
var ackEvent Event
|
||||||
|
|
||||||
// NewWindow creates a new window for a set of window
|
// NewWindow creates a new window for a set of window
|
||||||
@@ -156,7 +156,7 @@ func (w *Window) updateAnimation() {
|
|||||||
if dt := time.Until(w.nextFrame); dt <= 0 {
|
if dt := time.Until(w.nextFrame); dt <= 0 {
|
||||||
animate = true
|
animate = true
|
||||||
} else {
|
} else {
|
||||||
w.delayedDraw = time.AfterFunc(dt, w.Redraw)
|
w.delayedDraw = time.NewTimer(dt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if animate != w.animating {
|
if animate != w.animating {
|
||||||
@@ -209,7 +209,14 @@ func (w *Window) run(opts *WindowOptions) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
|
var timer <-chan time.Time
|
||||||
|
if w.delayedDraw != nil {
|
||||||
|
timer = w.delayedDraw.C
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
|
case <-timer:
|
||||||
|
w.setNextFrame(time.Time{})
|
||||||
|
w.updateAnimation()
|
||||||
case <-w.redraws:
|
case <-w.redraws:
|
||||||
w.setNextFrame(time.Time{})
|
w.setNextFrame(time.Time{})
|
||||||
w.updateAnimation()
|
w.updateAnimation()
|
||||||
|
|||||||
Reference in New Issue
Block a user