diff --git a/src/main.rs b/src/main.rs index 39d2efd..9733ce1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,7 +170,7 @@ fn main() -> Result<()> { hmd::frame(sk); #[cfg(feature = "wayland")] - wayland.frame(sk); + wayland.frame_event(sk); destroy_queue::clear(); if let Some(mouse_pointer) = &mouse_pointer { @@ -206,6 +206,8 @@ fn main() -> Result<()> { std::thread::sleep(sleep_duration); // to give clients a chance to even update anything before drawing }); } + #[cfg(feature = "wayland")] + wayland.update(sk); drawable::draw(sk); audio::update(); #[cfg(feature = "wayland")] diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index b8c0e3a..3df4da7 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -155,16 +155,22 @@ impl Wayland { } #[instrument(level = "debug", name = "Wayland frame", skip(self, sk))] - pub fn frame(&mut self, sk: &StereoKitDraw) { + pub fn update(&mut self, sk: &StereoKitDraw) { for core_surface in CORE_SURFACES.get_valid_contents() { - let state = self.state.lock(); - let output = state.output.clone(); - core_surface.process(sk, &mut self.renderer, output, &self.log); + core_surface.process(sk, &mut self.renderer, &self.log); } self.display.lock().flush_clients().unwrap(); } + pub fn frame_event(&self, sk: &StereoKitDraw) { + let state = self.state.lock(); + + for core_surface in CORE_SURFACES.get_valid_contents() { + core_surface.frame(sk, state.output.clone()); + } + } + pub fn make_context_current(&self) { unsafe { self.renderer.egl_context().make_current().unwrap(); diff --git a/src/wayland/surface.rs b/src/wayland/surface.rs index 0c93b80..6bc4891 100644 --- a/src/wayland/surface.rs +++ b/src/wayland/surface.rs @@ -103,13 +103,7 @@ impl CoreSurface { }) } - pub fn process( - &self, - sk: &StereoKitDraw, - renderer: &mut Gles2Renderer, - output: Output, - log: &Logger, - ) { + pub fn process(&self, sk: &StereoKitDraw, renderer: &mut Gles2Renderer, log: &Logger) { let Some(wl_surface) = self.wl_surface() else { return }; let sk_tex = self.sk_tex.get_or_init(|| { @@ -183,6 +177,10 @@ impl CoreSurface { *mapped_data = Some(new_mapped_data); }); self.apply_surface_materials(); + } + + pub fn frame(&self, sk: &StereoKitDraw, output: Output) { + let Some(wl_surface) = self.wl_surface() else { return }; send_frames_surface_tree( &wl_surface,