app: [macOS] pace display link

On macOS the display link that drives redraws runs on a separate thread, and
must switch to the main thread to invalidate its view. This change makes sure
the display link can never call invalidate faster than we can draw.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-01-07 18:16:40 +01:00
parent 11aec807b2
commit 11f39582b8
+7 -3
View File
@@ -558,10 +558,14 @@ func newOSWindow() (*window, error) {
view: view,
scale: scale,
}
done := make(chan struct{})
setNeedsDisplay := func() {
C.setNeedsDisplay(w.view)
done <- struct{}{}
}
dl, err := NewDisplayLink(func() {
w.runOnMain(func() {
C.setNeedsDisplay(w.view)
})
w.runOnMain(setNeedsDisplay)
<-done
})
w.displayLink = dl
if err != nil {