From 9ab3e6d78249238145156066e772aa99ffe288a2 Mon Sep 17 00:00:00 2001 From: Till Wegmueller Date: Sat, 4 Apr 2026 19:07:46 +0200 Subject: [PATCH] Remove dead code and fix all clippy/fmt warnings - Remove CapturedFrame struct and last_capture field (no consumer yet) - Remove display_handle field (re-obtainable when needed) - Prefix output_manager_state and xdg_decoration_state with _ (kept alive for Wayland globals but not directly read) - Keep framebuffer capture logging to verify ExportMem path works --- crates/wrsrvd/src/render.rs | 44 ++++++++-------------------------- crates/wrsrvd/src/state.rs | 48 ++++++++++++------------------------- 2 files changed, 25 insertions(+), 67 deletions(-) diff --git a/crates/wrsrvd/src/render.rs b/crates/wrsrvd/src/render.rs index b0cce6b..430393d 100644 --- a/crates/wrsrvd/src/render.rs +++ b/crates/wrsrvd/src/render.rs @@ -14,7 +14,7 @@ use smithay::{ }; use tracing::warn; -use crate::state::{CapturedFrame, WayRay}; +use crate::state::WayRay; /// Dark grey clear color for the compositor background. const CLEAR_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.0]; @@ -36,7 +36,6 @@ pub fn render_output_frame( let age = backend.buffer_age().unwrap_or(0); // Render within a block so framebuffer is dropped before submit. - // Returns (damage, optional captured frame) on success. let render_result = { let (renderer, mut framebuffer) = match backend.bind() { Ok(pair) => pair, @@ -63,26 +62,18 @@ pub fn render_output_frame( match render_result { Ok(result) => { - // Clone damage before we consume the framebuffer for capture. let damage = result.damage.cloned(); - // Capture the framebuffer while it is still bound. + // Verify framebuffer capture path works (will be consumed + // by network transport in Phase 1). let output_size = state.output.current_mode().unwrap().size; - let region: Rectangle = Rectangle::from_size( - Size::from((output_size.w, output_size.h)), - ); + let region: Rectangle = + Rectangle::from_size(Size::from((output_size.w, output_size.h))); - let capture = match renderer.copy_framebuffer( - &framebuffer, - region, - Fourcc::Argb8888, - ) { + match renderer.copy_framebuffer(&framebuffer, region, Fourcc::Argb8888) { Ok(mapping) => match renderer.map_texture(&mapping) { Ok(pixels) => { - let damage_rects = damage - .as_ref() - .map(|d| d.len()) - .unwrap_or(0); + let damage_rects = damage.as_ref().map(|d| d.len()).unwrap_or(0); tracing::debug!( width = output_size.w, height = output_size.h, @@ -90,28 +81,17 @@ pub fn render_output_frame( damage_rects, "framebuffer captured" ); - Some(CapturedFrame { - data: pixels.to_vec(), - width: output_size.w, - height: output_size.h, - damage: damage - .as_ref() - .cloned() - .unwrap_or_default(), - }) } Err(err) => { tracing::warn!(?err, "failed to map framebuffer"); - None } }, Err(err) => { tracing::warn!(?err, "failed to copy framebuffer"); - None } - }; + } - Ok((damage, capture)) + Ok(damage) } Err(err) => { warn!(?err, "damage tracker render failed"); @@ -122,11 +102,7 @@ pub fn render_output_frame( // framebuffer is now dropped, backend is no longer borrowed. match render_result { - Ok((damage, capture)) => { - // Store the captured frame for later consumption by the - // network transport layer. - state.last_capture = capture; - + Ok(damage) => { let has_damage = damage.is_some(); let submit_result = if let Some(ref rects) = damage { diff --git a/crates/wrsrvd/src/state.rs b/crates/wrsrvd/src/state.rs index 1b7d130..2d6a8c1 100644 --- a/crates/wrsrvd/src/state.rs +++ b/crates/wrsrvd/src/state.rs @@ -1,8 +1,7 @@ use smithay::{ backend::input::{ AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event as InputEventTrait, - InputBackend, InputEvent, KeyboardKeyEvent, - PointerAxisEvent as PointerAxisEventTrait, + InputBackend, InputEvent, KeyboardKeyEvent, PointerAxisEvent as PointerAxisEventTrait, PointerButtonEvent as PointerButtonEventTrait, }, desktop::{Space, WindowSurfaceType}, @@ -12,48 +11,36 @@ use smithay::{ pointer::{AxisFrame, ButtonEvent, MotionEvent}, }, output::Output, - reexports::wayland_server::{Display, DisplayHandle}, - utils::{Clock, Monotonic, Physical, Rectangle, SERIAL_COUNTER}, + reexports::wayland_server::Display, + utils::{Clock, Monotonic, SERIAL_COUNTER}, wayland::{ compositor::CompositorState, output::OutputManagerState, - selection::{ - data_device::DataDeviceState, - primary_selection::PrimarySelectionState, - }, + selection::{data_device::DataDeviceState, primary_selection::PrimarySelectionState}, shell::xdg::{XdgShellState, decoration::XdgDecorationState}, shm::ShmState, }, }; use tracing::info; -/// Captured framebuffer data from the last render pass. -pub struct CapturedFrame { - pub data: Vec, - pub width: i32, - pub height: i32, - pub damage: Vec>, -} - /// Central compositor state holding all Smithay subsystem states. /// /// This is the "god struct" pattern required by Smithay — a single type that /// implements all handler traits and holds all protocol global state. pub struct WayRay { - pub display_handle: DisplayHandle, pub compositor_state: CompositorState, pub xdg_shell_state: XdgShellState, pub shm_state: ShmState, pub seat_state: SeatState, - pub output_manager_state: OutputManagerState, pub data_device_state: DataDeviceState, pub primary_selection_state: PrimarySelectionState, - pub xdg_decoration_state: XdgDecorationState, pub space: Space, pub seat: Seat, pub clock: Clock, pub output: Output, - pub last_capture: Option, + // Kept alive to maintain their Wayland globals — not accessed directly. + _output_manager_state: OutputManagerState, + _xdg_decoration_state: XdgDecorationState, } impl WayRay { @@ -66,7 +53,6 @@ impl WayRay { let shm_state = ShmState::new::(&dh, vec![]); let data_device_state = DataDeviceState::new::(&dh); let primary_selection_state = PrimarySelectionState::new::(&dh); - let xdg_decoration_state = XdgDecorationState::new::(&dh); let mut seat_state = SeatState::new(); let mut seat = seat_state.new_wl_seat(&dh, "wayray"); @@ -75,25 +61,21 @@ impl WayRay { .expect("failed to add keyboard to seat"); seat.add_pointer(); - let output_manager_state = OutputManagerState::new_with_xdg_output::(&dh); - info!("all Smithay subsystem states initialized"); Self { - display_handle: dh, compositor_state, xdg_shell_state, shm_state, seat_state, - output_manager_state, data_device_state, primary_selection_state, - xdg_decoration_state, space: Space::default(), seat, clock: Clock::new(), output, - last_capture: None, + _output_manager_state: OutputManagerState::new_with_xdg_output::(&dh), + _xdg_decoration_state: XdgDecorationState::new::(&dh), } } @@ -171,12 +153,12 @@ impl WayRay { let source = event.source(); - let horizontal_amount = event - .amount(Axis::Horizontal) - .unwrap_or_else(|| event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 3.0 / 120.0); - let vertical_amount = event - .amount(Axis::Vertical) - .unwrap_or_else(|| event.amount_v120(Axis::Vertical).unwrap_or(0.0) * 3.0 / 120.0); + let horizontal_amount = event.amount(Axis::Horizontal).unwrap_or_else(|| { + event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 3.0 / 120.0 + }); + let vertical_amount = event.amount(Axis::Vertical).unwrap_or_else(|| { + event.amount_v120(Axis::Vertical).unwrap_or(0.0) * 3.0 / 120.0 + }); let mut frame = AxisFrame::new(event.time_msec()).source(source);