diff --git a/src/backend.rs b/src/backend.rs index 1d94d9d..ccf9d42 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -28,13 +28,46 @@ use smithay::{ }; use crate::{ - state::{Backend, State, SurfaceDmabufFeedback}, + state::{State, SurfaceDmabufFeedback}, window::WindowElement, }; +use self::{udev::Udev, winit::Winit}; + pub mod udev; pub mod winit; +pub enum Backend { + /// The compositor is running in a Winit window + Winit(Winit), + /// The compositor is running in a tty + Udev(Udev), +} + +impl Backend { + pub fn seat_name(&self) -> String { + match self { + Backend::Winit(winit) => winit.seat_name(), + Backend::Udev(udev) => udev.seat_name(), + } + } + + pub fn early_import(&mut self, surface: &WlSurface) { + match self { + Backend::Winit(winit) => winit.early_import(surface), + Backend::Udev(udev) => udev.early_import(surface), + } + } + + /// Returns `true` if the backend is [`Winit`]. + /// + /// [`Winit`]: Backend::Winit + #[must_use] + pub fn is_winit(&self) -> bool { + matches!(self, Self::Winit(..)) + } +} + /// A trait defining common methods for each available backend: winit and tty-udev pub trait BackendData: 'static { fn seat_name(&self) -> String; diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 6da7636..98ec821 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -88,13 +88,14 @@ use smithay_drm_extras::{ }; use crate::{ + backend::Backend, config::{ api::msg::{Args, OutgoingMsg}, ConnectorSavedState, }, output::OutputName, render::{pointer::PointerElement, take_presentation_feedback, CustomRenderElements}, - state::{Backend, CalloopData, State, SurfaceDmabufFeedback, WithState}, + state::{CalloopData, State, SurfaceDmabufFeedback, WithState}, window::WindowElement, }; diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 5cfc48b..3d5e3b8 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -35,11 +35,11 @@ use smithay::{ use crate::{ render::{pointer::PointerElement, take_presentation_feedback}, - state::{Backend, CalloopData, State, WithState}, + state::{CalloopData, State, WithState}, window::WindowElement, }; -use super::BackendData; +use super::{Backend, BackendData}; pub struct Winit { pub backend: WinitGraphicsBackend, diff --git a/src/input.rs b/src/input.rs index 4529ed6..5634cae 100644 --- a/src/input.rs +++ b/src/input.rs @@ -3,9 +3,10 @@ use std::collections::HashMap; use crate::{ + backend::Backend, config::api::msg::{CallbackId, Modifier, ModifierMask, MouseEdge, OutgoingMsg}, focus::FocusTarget, - state::{Backend, WithState}, + state::WithState, window::WindowElement, }; use smithay::{ diff --git a/src/state.rs b/src/state.rs index 9c6191a..95b9b26 100644 --- a/src/state.rs +++ b/src/state.rs @@ -5,7 +5,7 @@ mod api_handlers; use std::{cell::RefCell, os::fd::AsRawFd, sync::Arc, time::Duration}; use crate::{ - backend::{udev::Udev, winit::Winit, BackendData}, + backend::Backend, config::{ api::{msg::Msg, ApiState}, Config, @@ -48,37 +48,6 @@ use smithay::{ use crate::input::InputState; -pub enum Backend { - /// The compositor is running in a Winit window - Winit(Winit), - /// The compositor is running in a tty - Udev(Udev), -} - -impl Backend { - pub fn seat_name(&self) -> String { - match self { - Backend::Winit(winit) => winit.seat_name(), - Backend::Udev(udev) => udev.seat_name(), - } - } - - pub fn early_import(&mut self, surface: &WlSurface) { - match self { - Backend::Winit(winit) => winit.early_import(surface), - Backend::Udev(udev) => udev.early_import(surface), - } - } - - /// Returns `true` if the backend is [`Winit`]. - /// - /// [`Winit`]: Backend::Winit - #[must_use] - pub fn is_winit(&self) -> bool { - matches!(self, Self::Winit(..)) - } -} - /// The main state of the application. pub struct State { /// Which backend is currently running