On Wayland, use frame callbacks to throttle RedrawRequested

Throttle RedrawRequested events by the frame callbacks, so the users
could render at the display refresh rate.
This commit is contained in:
Kirill Chibisov 2023-06-22 09:12:47 +04:00
parent 38f28d5836
commit 7a58fe58ce
6 changed files with 151 additions and 85 deletions

View file

@ -321,7 +321,15 @@ impl CompositorHandler for WinitState {
self.scale_factor_changed(surface, scale_factor as f64, true)
}
fn frame(&mut self, _: &Connection, _: &QueueHandle<Self>, _: &WlSurface, _: u32) {}
fn frame(&mut self, _: &Connection, _: &QueueHandle<Self>, surface: &WlSurface, _: u32) {
let window_id = super::make_wid(surface);
let window = match self.windows.get_mut().get(&window_id) {
Some(window) => window,
None => return,
};
window.lock().unwrap().frame_callback_received();
}
}
impl ProvidesRegistryState for WinitState {