diff --git a/crates/wrsrvd/Cargo.toml b/crates/wrsrvd/Cargo.toml index f31388d..fa7594a 100644 --- a/crates/wrsrvd/Cargo.toml +++ b/crates/wrsrvd/Cargo.toml @@ -4,6 +4,11 @@ edition.workspace = true version.workspace = true license.workspace = true +[features] +# Enable the Winit development backend (requires display server). +# Build with: cargo build -p wrsrvd --features winit +winit = ["smithay/renderer_gl", "smithay/backend_winit"] + [dependencies] wayray-protocol.workspace = true tracing.workspace = true @@ -11,16 +16,14 @@ tracing-subscriber.workspace = true miette.workspace = true thiserror.workspace = true serde.workspace = true - -smithay = { version = "0.7", default-features = false, features = [ - "wayland_frontend", - "desktop", - "renderer_gl", - "renderer_pixman", - "backend_winit", -] } ctrlc = "3" quinn.workspace = true rustls.workspace = true rcgen.workspace = true tokio.workspace = true + +smithay = { version = "0.7", default-features = false, features = [ + "wayland_frontend", + "desktop", + "renderer_pixman", +] } diff --git a/crates/wrsrvd/src/backend/headless.rs b/crates/wrsrvd/src/backend/headless.rs index 2428acd..18a3b9c 100644 --- a/crates/wrsrvd/src/backend/headless.rs +++ b/crates/wrsrvd/src/backend/headless.rs @@ -268,24 +268,6 @@ fn render_headless_frame(data: &mut CalloopData) { std::slice::from_raw_parts(ptr, frame_bytes) }; - // Debug: check if the framebuffer contains anything besides the clear color. - if element_count > 0 { - // Clear color [0.1, 0.1, 0.1, 1.0] ≈ [25, 25, 25, 255] in u8 - // Count unique non-bg BGRA values in first 1000 pixels - let unique: std::collections::HashSet<[u8; 4]> = pixels - .chunks_exact(4) - .take(1000) - .map(|p| [p[0], p[1], p[2], p[3]]) - .collect(); - tracing::info!( - unique_colors = unique.len(), - first_pixel = ?&pixels[..4.min(pixels.len())], - stride, - total_bytes = pixels.len(), - "framebuffer content check" - ); - } - // Send frame over network if a client is connected. if data.client_connected { send_frame_to_network(data, pixels, &damage, output_size.w, output_size.h, stride); diff --git a/crates/wrsrvd/src/backend/mod.rs b/crates/wrsrvd/src/backend/mod.rs index cc833c7..c0de40c 100644 --- a/crates/wrsrvd/src/backend/mod.rs +++ b/crates/wrsrvd/src/backend/mod.rs @@ -1,2 +1,4 @@ pub mod headless; + +#[cfg(feature = "winit")] pub mod winit; diff --git a/crates/wrsrvd/src/main.rs b/crates/wrsrvd/src/main.rs index 63ac49f..660c61f 100644 --- a/crates/wrsrvd/src/main.rs +++ b/crates/wrsrvd/src/main.rs @@ -75,10 +75,18 @@ fn main() -> Result<()> { ); if use_winit { - let result = backend::winit::run(display, state, output); - net_handle.shutdown(); - result - } else { - backend::headless::run(display, state, output, net_handle) + #[cfg(feature = "winit")] + { + let result = backend::winit::run(display, state, output); + net_handle.shutdown(); + return result; + } + #[cfg(not(feature = "winit"))] + { + eprintln!("Winit backend not compiled. Build with: cargo build --features winit"); + std::process::exit(1); + } } + + backend::headless::run(display, state, output, net_handle) } diff --git a/crates/wrsrvd/src/state.rs b/crates/wrsrvd/src/state.rs index 58171ab..fbb9052 100644 --- a/crates/wrsrvd/src/state.rs +++ b/crates/wrsrvd/src/state.rs @@ -1,9 +1,10 @@ +#[cfg(feature = "winit")] +use smithay::backend::input::{ + AbsolutePositionEvent, Event as InputEventTrait, InputBackend, InputEvent, KeyboardKeyEvent, + PointerAxisEvent as PointerAxisEventTrait, PointerButtonEvent as PointerButtonEventTrait, +}; use smithay::{ - backend::input::{ - AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event as InputEventTrait, - InputBackend, InputEvent, KeyboardKeyEvent, PointerAxisEvent as PointerAxisEventTrait, - PointerButtonEvent as PointerButtonEventTrait, - }, + backend::input::{Axis, AxisSource, ButtonState}, desktop::{Space, WindowSurfaceType}, input::{ Seat, SeatState, @@ -82,6 +83,8 @@ impl WayRay { /// Process an input event from the backend and forward it to the appropriate /// Smithay seat device (keyboard or pointer). + /// Only used by the Winit backend for local input processing. + #[cfg(feature = "winit")] pub fn process_input_event(&mut self, event: InputEvent) { match event { InputEvent::Keyboard { event } => {