use std::ffi::OsString; use smithay::{ desktop::{Space, Window}, input::{pointer::CursorImageStatus, SeatState}, reexports::{ calloop::{LoopHandle, LoopSignal}, wayland_server::{ backend::{ClientData, ClientId, DisconnectReason}, protocol::wl_surface::WlSurface, Display, }, }, utils::{Clock, Logical, Monotonic, Point}, wayland::{ compositor::{CompositorClientState, CompositorState}, data_device::DataDeviceState, fractional_scale::FractionalScaleManagerState, output::OutputManagerState, seat::WaylandFocus, shell::xdg::XdgShellState, shm::ShmState, viewporter::ViewporterState, }, }; use crate::backend::{winit::WinitData, Backend}; pub struct State { pub backend_data: B, pub loop_signal: LoopSignal, pub loop_handle: LoopHandle<'static, CalloopData>, pub clock: Clock, pub compositor_state: CompositorState, pub data_device_state: DataDeviceState, pub seat_state: SeatState, pub shm_state: ShmState, pub space: Space, pub cursor_status: CursorImageStatus, pub pointer_location: Point, pub output_manager_state: OutputManagerState, pub xdg_shell_state: XdgShellState, pub viewporter_state: ViewporterState, pub fractional_scale_manager_state: FractionalScaleManagerState, pub move_mode: bool, pub socket_name: OsString, } impl State { /// Returns the [Window] associated with a given [WlSurface]. pub fn window_for_surface(&self, surface: &WlSurface) -> Option { self.space .elements() .find(|window| window.wl_surface().map(|s| s == *surface).unwrap_or(false)) .cloned() } } pub struct CalloopData { pub display: Display>, pub state: State, } #[derive(Default)] pub struct ClientState { pub compositor_state: CompositorClientState, } impl ClientData for ClientState { fn initialized(&self, _client_id: ClientId) {} fn disconnected(&self, _client_id: ClientId, _reason: DisconnectReason) {} // fn debug(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {} }