mirror of
https://github.com/CloudNebulaProject/wayray.git
synced 2026-04-10 13:10:41 +00:00
Move handler trait impls and delegate macros from state.rs into
handlers/{compositor,xdg_shell,input,output}.rs. Flesh out
CompositorHandler::commit with on_commit_buffer_handler and
XdgShellHandler::new_toplevel with window mapping. Add DataDeviceHandler,
SelectionHandler, ClientDndGrabHandler, and ServerDndGrabHandler impls
with DataDeviceState in the WayRay struct. State.rs now contains only
the struct definition and constructor.
63 lines
2 KiB
Rust
63 lines
2 KiB
Rust
use smithay::{
|
|
desktop::Space,
|
|
input::{Seat, SeatState},
|
|
reexports::wayland_server::{Display, DisplayHandle},
|
|
utils::{Clock, Monotonic},
|
|
wayland::{
|
|
compositor::CompositorState,
|
|
output::OutputManagerState,
|
|
selection::data_device::DataDeviceState,
|
|
shell::xdg::XdgShellState,
|
|
shm::ShmState,
|
|
},
|
|
};
|
|
use tracing::info;
|
|
|
|
/// 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<Self>,
|
|
pub output_manager_state: OutputManagerState,
|
|
pub data_device_state: DataDeviceState,
|
|
pub space: Space<smithay::desktop::Window>,
|
|
pub seat: Seat<Self>,
|
|
pub clock: Clock<Monotonic>,
|
|
}
|
|
|
|
impl WayRay {
|
|
/// Create a new WayRay compositor state, initializing all Smithay subsystems.
|
|
pub fn new(display: &mut Display<Self>) -> Self {
|
|
let dh = display.handle();
|
|
|
|
let compositor_state = CompositorState::new::<Self>(&dh);
|
|
let xdg_shell_state = XdgShellState::new::<Self>(&dh);
|
|
let shm_state = ShmState::new::<Self>(&dh, vec![]);
|
|
let data_device_state = DataDeviceState::new::<Self>(&dh);
|
|
|
|
let mut seat_state = SeatState::new();
|
|
let seat = seat_state.new_wl_seat(&dh, "wayray");
|
|
|
|
let output_manager_state = OutputManagerState::new_with_xdg_output::<Self>(&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,
|
|
space: Space::default(),
|
|
seat,
|
|
clock: Clock::new(),
|
|
}
|
|
}
|
|
}
|