1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-19 02:37:51 +03:00

fix(wayland): register frame callback then commit (fixes #3468) (#3485)

fix(wayland): register frame callback then commit (fixes #3468)

Co-authored-by: Wez Furlong <wez@wezfurlong.org>
This commit is contained in:
Ron Waldon-Howe 2023-04-11 02:10:38 +10:00 committed by GitHub
parent e241ea58be
commit 0eeca6c2c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -801,27 +801,26 @@ impl WaylandWindowInner {
}
self.invalidated = false;
self.events.dispatch(WindowEvent::NeedRepaint);
if self.gl_state.is_some() {
// Ask the compositor to wake us up when it is time to paint
// the next frame.
// We don't do this when we're using WebGPU because we don't
// always get a timely wakeup. We configure wgpu to use a
// vsync-equivalent PresentMode so we should already be
// respecting the maximum frame rate, making it less critical
// to rely on Wayland's frame scheduling.
// <https://github.com/wez/wezterm/issues/3126>
let window_id = self.window_id;
let callback = self.surface.frame();
callback.quick_assign(move |_source, _event, _data| {
WaylandConnection::with_window_inner(window_id, |inner| {
inner.next_frame_is_ready();
Ok(())
});
// Ask the compositor to wake us up when its time to paint the next frame,
// note that this only happens _after_ the next commit
let window_id = self.window_id;
let callback = self.surface.frame();
callback.quick_assign(move |_source, _event, _data| {
WaylandConnection::with_window_inner(window_id, |inner| {
inner.next_frame_is_ready();
Ok(())
});
self.frame_callback.replace(callback);
}
});
self.frame_callback.replace(callback);
// The repaint has the side of effect of committing the surface,
// which is necessary for the frame callback to get triggered.
// Ordering the repaint after requesting the callback ensures that
// we will get woken at the appropriate time.
// <https://github.com/wez/wezterm/issues/3468>
// <https://github.com/wez/wezterm/issues/3126>
self.events.dispatch(WindowEvent::NeedRepaint);
Ok(())
}