mirror of
https://github.com/CloudNebulaProject/wayray.git
synced 2026-04-10 21:20:40 +00:00
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
This commit is contained in:
parent
5fee1a9b40
commit
9ab3e6d782
2 changed files with 25 additions and 67 deletions
|
|
@ -14,7 +14,7 @@ use smithay::{
|
||||||
};
|
};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
use crate::state::{CapturedFrame, WayRay};
|
use crate::state::WayRay;
|
||||||
|
|
||||||
/// Dark grey clear color for the compositor background.
|
/// Dark grey clear color for the compositor background.
|
||||||
const CLEAR_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.0];
|
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);
|
let age = backend.buffer_age().unwrap_or(0);
|
||||||
|
|
||||||
// Render within a block so framebuffer is dropped before submit.
|
// Render within a block so framebuffer is dropped before submit.
|
||||||
// Returns (damage, optional captured frame) on success.
|
|
||||||
let render_result = {
|
let render_result = {
|
||||||
let (renderer, mut framebuffer) = match backend.bind() {
|
let (renderer, mut framebuffer) = match backend.bind() {
|
||||||
Ok(pair) => pair,
|
Ok(pair) => pair,
|
||||||
|
|
@ -63,26 +62,18 @@ pub fn render_output_frame(
|
||||||
|
|
||||||
match render_result {
|
match render_result {
|
||||||
Ok(result) => {
|
Ok(result) => {
|
||||||
// Clone damage before we consume the framebuffer for capture.
|
|
||||||
let damage = result.damage.cloned();
|
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 output_size = state.output.current_mode().unwrap().size;
|
||||||
let region: Rectangle<i32, BufferCoord> = Rectangle::from_size(
|
let region: Rectangle<i32, BufferCoord> =
|
||||||
Size::from((output_size.w, output_size.h)),
|
Rectangle::from_size(Size::from((output_size.w, output_size.h)));
|
||||||
);
|
|
||||||
|
|
||||||
let capture = match renderer.copy_framebuffer(
|
match renderer.copy_framebuffer(&framebuffer, region, Fourcc::Argb8888) {
|
||||||
&framebuffer,
|
|
||||||
region,
|
|
||||||
Fourcc::Argb8888,
|
|
||||||
) {
|
|
||||||
Ok(mapping) => match renderer.map_texture(&mapping) {
|
Ok(mapping) => match renderer.map_texture(&mapping) {
|
||||||
Ok(pixels) => {
|
Ok(pixels) => {
|
||||||
let damage_rects = damage
|
let damage_rects = damage.as_ref().map(|d| d.len()).unwrap_or(0);
|
||||||
.as_ref()
|
|
||||||
.map(|d| d.len())
|
|
||||||
.unwrap_or(0);
|
|
||||||
tracing::debug!(
|
tracing::debug!(
|
||||||
width = output_size.w,
|
width = output_size.w,
|
||||||
height = output_size.h,
|
height = output_size.h,
|
||||||
|
|
@ -90,28 +81,17 @@ pub fn render_output_frame(
|
||||||
damage_rects,
|
damage_rects,
|
||||||
"framebuffer captured"
|
"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) => {
|
Err(err) => {
|
||||||
tracing::warn!(?err, "failed to map framebuffer");
|
tracing::warn!(?err, "failed to map framebuffer");
|
||||||
None
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
tracing::warn!(?err, "failed to copy framebuffer");
|
tracing::warn!(?err, "failed to copy framebuffer");
|
||||||
None
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok((damage, capture))
|
Ok(damage)
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!(?err, "damage tracker render failed");
|
warn!(?err, "damage tracker render failed");
|
||||||
|
|
@ -122,11 +102,7 @@ pub fn render_output_frame(
|
||||||
// framebuffer is now dropped, backend is no longer borrowed.
|
// framebuffer is now dropped, backend is no longer borrowed.
|
||||||
|
|
||||||
match render_result {
|
match render_result {
|
||||||
Ok((damage, capture)) => {
|
Ok(damage) => {
|
||||||
// Store the captured frame for later consumption by the
|
|
||||||
// network transport layer.
|
|
||||||
state.last_capture = capture;
|
|
||||||
|
|
||||||
let has_damage = damage.is_some();
|
let has_damage = damage.is_some();
|
||||||
|
|
||||||
let submit_result = if let Some(ref rects) = damage {
|
let submit_result = if let Some(ref rects) = damage {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::input::{
|
backend::input::{
|
||||||
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event as InputEventTrait,
|
AbsolutePositionEvent, Axis, AxisSource, ButtonState, Event as InputEventTrait,
|
||||||
InputBackend, InputEvent, KeyboardKeyEvent,
|
InputBackend, InputEvent, KeyboardKeyEvent, PointerAxisEvent as PointerAxisEventTrait,
|
||||||
PointerAxisEvent as PointerAxisEventTrait,
|
|
||||||
PointerButtonEvent as PointerButtonEventTrait,
|
PointerButtonEvent as PointerButtonEventTrait,
|
||||||
},
|
},
|
||||||
desktop::{Space, WindowSurfaceType},
|
desktop::{Space, WindowSurfaceType},
|
||||||
|
|
@ -12,48 +11,36 @@ use smithay::{
|
||||||
pointer::{AxisFrame, ButtonEvent, MotionEvent},
|
pointer::{AxisFrame, ButtonEvent, MotionEvent},
|
||||||
},
|
},
|
||||||
output::Output,
|
output::Output,
|
||||||
reexports::wayland_server::{Display, DisplayHandle},
|
reexports::wayland_server::Display,
|
||||||
utils::{Clock, Monotonic, Physical, Rectangle, SERIAL_COUNTER},
|
utils::{Clock, Monotonic, SERIAL_COUNTER},
|
||||||
wayland::{
|
wayland::{
|
||||||
compositor::CompositorState,
|
compositor::CompositorState,
|
||||||
output::OutputManagerState,
|
output::OutputManagerState,
|
||||||
selection::{
|
selection::{data_device::DataDeviceState, primary_selection::PrimarySelectionState},
|
||||||
data_device::DataDeviceState,
|
|
||||||
primary_selection::PrimarySelectionState,
|
|
||||||
},
|
|
||||||
shell::xdg::{XdgShellState, decoration::XdgDecorationState},
|
shell::xdg::{XdgShellState, decoration::XdgDecorationState},
|
||||||
shm::ShmState,
|
shm::ShmState,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use tracing::info;
|
use tracing::info;
|
||||||
|
|
||||||
/// Captured framebuffer data from the last render pass.
|
|
||||||
pub struct CapturedFrame {
|
|
||||||
pub data: Vec<u8>,
|
|
||||||
pub width: i32,
|
|
||||||
pub height: i32,
|
|
||||||
pub damage: Vec<Rectangle<i32, Physical>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Central compositor state holding all Smithay subsystem states.
|
/// Central compositor state holding all Smithay subsystem states.
|
||||||
///
|
///
|
||||||
/// This is the "god struct" pattern required by Smithay — a single type that
|
/// This is the "god struct" pattern required by Smithay — a single type that
|
||||||
/// implements all handler traits and holds all protocol global state.
|
/// implements all handler traits and holds all protocol global state.
|
||||||
pub struct WayRay {
|
pub struct WayRay {
|
||||||
pub display_handle: DisplayHandle,
|
|
||||||
pub compositor_state: CompositorState,
|
pub compositor_state: CompositorState,
|
||||||
pub xdg_shell_state: XdgShellState,
|
pub xdg_shell_state: XdgShellState,
|
||||||
pub shm_state: ShmState,
|
pub shm_state: ShmState,
|
||||||
pub seat_state: SeatState<Self>,
|
pub seat_state: SeatState<Self>,
|
||||||
pub output_manager_state: OutputManagerState,
|
|
||||||
pub data_device_state: DataDeviceState,
|
pub data_device_state: DataDeviceState,
|
||||||
pub primary_selection_state: PrimarySelectionState,
|
pub primary_selection_state: PrimarySelectionState,
|
||||||
pub xdg_decoration_state: XdgDecorationState,
|
|
||||||
pub space: Space<smithay::desktop::Window>,
|
pub space: Space<smithay::desktop::Window>,
|
||||||
pub seat: Seat<Self>,
|
pub seat: Seat<Self>,
|
||||||
pub clock: Clock<Monotonic>,
|
pub clock: Clock<Monotonic>,
|
||||||
pub output: Output,
|
pub output: Output,
|
||||||
pub last_capture: Option<CapturedFrame>,
|
// Kept alive to maintain their Wayland globals — not accessed directly.
|
||||||
|
_output_manager_state: OutputManagerState,
|
||||||
|
_xdg_decoration_state: XdgDecorationState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WayRay {
|
impl WayRay {
|
||||||
|
|
@ -66,7 +53,6 @@ impl WayRay {
|
||||||
let shm_state = ShmState::new::<Self>(&dh, vec![]);
|
let shm_state = ShmState::new::<Self>(&dh, vec![]);
|
||||||
let data_device_state = DataDeviceState::new::<Self>(&dh);
|
let data_device_state = DataDeviceState::new::<Self>(&dh);
|
||||||
let primary_selection_state = PrimarySelectionState::new::<Self>(&dh);
|
let primary_selection_state = PrimarySelectionState::new::<Self>(&dh);
|
||||||
let xdg_decoration_state = XdgDecorationState::new::<Self>(&dh);
|
|
||||||
|
|
||||||
let mut seat_state = SeatState::new();
|
let mut seat_state = SeatState::new();
|
||||||
let mut seat = seat_state.new_wl_seat(&dh, "wayray");
|
let mut seat = seat_state.new_wl_seat(&dh, "wayray");
|
||||||
|
|
@ -75,25 +61,21 @@ impl WayRay {
|
||||||
.expect("failed to add keyboard to seat");
|
.expect("failed to add keyboard to seat");
|
||||||
seat.add_pointer();
|
seat.add_pointer();
|
||||||
|
|
||||||
let output_manager_state = OutputManagerState::new_with_xdg_output::<Self>(&dh);
|
|
||||||
|
|
||||||
info!("all Smithay subsystem states initialized");
|
info!("all Smithay subsystem states initialized");
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
display_handle: dh,
|
|
||||||
compositor_state,
|
compositor_state,
|
||||||
xdg_shell_state,
|
xdg_shell_state,
|
||||||
shm_state,
|
shm_state,
|
||||||
seat_state,
|
seat_state,
|
||||||
output_manager_state,
|
|
||||||
data_device_state,
|
data_device_state,
|
||||||
primary_selection_state,
|
primary_selection_state,
|
||||||
xdg_decoration_state,
|
|
||||||
space: Space::default(),
|
space: Space::default(),
|
||||||
seat,
|
seat,
|
||||||
clock: Clock::new(),
|
clock: Clock::new(),
|
||||||
output,
|
output,
|
||||||
last_capture: None,
|
_output_manager_state: OutputManagerState::new_with_xdg_output::<Self>(&dh),
|
||||||
|
_xdg_decoration_state: XdgDecorationState::new::<Self>(&dh),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -171,12 +153,12 @@ impl WayRay {
|
||||||
|
|
||||||
let source = event.source();
|
let source = event.source();
|
||||||
|
|
||||||
let horizontal_amount = event
|
let horizontal_amount = event.amount(Axis::Horizontal).unwrap_or_else(|| {
|
||||||
.amount(Axis::Horizontal)
|
event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 3.0 / 120.0
|
||||||
.unwrap_or_else(|| event.amount_v120(Axis::Horizontal).unwrap_or(0.0) * 3.0 / 120.0);
|
});
|
||||||
let vertical_amount = event
|
let vertical_amount = event.amount(Axis::Vertical).unwrap_or_else(|| {
|
||||||
.amount(Axis::Vertical)
|
event.amount_v120(Axis::Vertical).unwrap_or(0.0) * 3.0 / 120.0
|
||||||
.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);
|
let mut frame = AxisFrame::new(event.time_msec()).source(source);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue