diff --git a/src/backend.rs b/src/backend.rs deleted file mode 100644 index 934046ab..00000000 --- a/src/backend.rs +++ /dev/null @@ -1,2 +0,0 @@ -pub mod consumer; -pub mod producer; diff --git a/src/backend/consumer.rs b/src/backend/consumer.rs deleted file mode 100644 index 5970d08c..00000000 --- a/src/backend/consumer.rs +++ /dev/null @@ -1,20 +0,0 @@ -#[cfg(windows)] -pub mod windows; - -#[cfg(all(unix, feature = "x11", not(target_os = "macos")))] -pub mod x11; - -#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))] -pub mod wlroots; - -#[cfg(all(unix, feature = "xdg_desktop_portal", not(target_os = "macos")))] -pub mod xdg_desktop_portal; - -#[cfg(all(unix, feature = "libei", not(target_os = "macos")))] -pub mod libei; - -#[cfg(target_os = "macos")] -pub mod macos; - -/// fallback consumer -pub mod dummy; diff --git a/src/backend/producer.rs b/src/backend/producer.rs deleted file mode 100644 index 4b171bd2..00000000 --- a/src/backend/producer.rs +++ /dev/null @@ -1,17 +0,0 @@ -#[cfg(all(unix, feature = "libei", not(target_os = "macos")))] -pub mod libei; - -#[cfg(target_os = "macos")] -pub mod macos; - -#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))] -pub mod wayland; - -#[cfg(windows)] -pub mod windows; - -#[cfg(all(unix, feature = "x11", not(target_os = "macos")))] -pub mod x11; - -/// fallback event producer -pub mod dummy; diff --git a/src/consumer.rs b/src/consumer.rs index 78eba21d..35a9b1aa 100644 --- a/src/consumer.rs +++ b/src/consumer.rs @@ -2,12 +2,32 @@ use async_trait::async_trait; use std::future; use crate::{ - backend::consumer, client::{ClientEvent, ClientHandle}, event::Event, }; use anyhow::Result; +#[cfg(windows)] +pub mod windows; + +#[cfg(all(unix, feature = "x11", not(target_os = "macos")))] +pub mod x11; + +#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))] +pub mod wlroots; + +#[cfg(all(unix, feature = "xdg_desktop_portal", not(target_os = "macos")))] +pub mod xdg_desktop_portal; + +#[cfg(all(unix, feature = "libei", not(target_os = "macos")))] +pub mod libei; + +#[cfg(target_os = "macos")] +pub mod macos; + +/// fallback consumer +pub mod dummy; + #[async_trait] pub trait EventConsumer: Send { async fn consume(&mut self, event: Event, client_handle: ClientHandle); @@ -23,13 +43,13 @@ pub trait EventConsumer: Send { pub async fn create() -> Box { #[cfg(windows)] - match consumer::windows::WindowsConsumer::new() { + match windows::WindowsConsumer::new() { Ok(c) => return Box::new(c), Err(e) => log::warn!("windows event consumer unavailable: {e}"), } #[cfg(target_os = "macos")] - match consumer::macos::MacOSConsumer::new() { + match macos::MacOSConsumer::new() { Ok(c) => { log::info!("using macos event consumer"); return Box::new(c); @@ -38,7 +58,7 @@ pub async fn create() -> Box { } #[cfg(all(unix, feature = "wayland", not(target_os = "macos")))] - match consumer::wlroots::WlrootsConsumer::new() { + match wlroots::WlrootsConsumer::new() { Ok(c) => { log::info!("using wlroots event consumer"); return Box::new(c); @@ -47,7 +67,7 @@ pub async fn create() -> Box { } #[cfg(all(unix, feature = "libei", not(target_os = "macos")))] - match consumer::libei::LibeiConsumer::new().await { + match libei::LibeiConsumer::new().await { Ok(c) => { log::info!("using libei event consumer"); return Box::new(c); @@ -56,7 +76,7 @@ pub async fn create() -> Box { } #[cfg(all(unix, feature = "xdg_desktop_portal", not(target_os = "macos")))] - match consumer::xdg_desktop_portal::DesktopPortalConsumer::new().await { + match xdg_desktop_portal::DesktopPortalConsumer::new().await { Ok(c) => { log::info!("using xdg-remote-desktop-portal event consumer"); return Box::new(c); @@ -65,7 +85,7 @@ pub async fn create() -> Box { } #[cfg(all(unix, feature = "x11", not(target_os = "macos")))] - match consumer::x11::X11Consumer::new() { + match x11::X11Consumer::new() { Ok(c) => { log::info!("using x11 event consumer"); return Box::new(c); @@ -74,5 +94,5 @@ pub async fn create() -> Box { } log::error!("falling back to dummy event consumer"); - Box::new(consumer::dummy::DummyConsumer::new()) + Box::new(dummy::DummyConsumer::new()) } diff --git a/src/backend/consumer/dummy.rs b/src/consumer/dummy.rs similarity index 100% rename from src/backend/consumer/dummy.rs rename to src/consumer/dummy.rs diff --git a/src/backend/consumer/libei.rs b/src/consumer/libei.rs similarity index 100% rename from src/backend/consumer/libei.rs rename to src/consumer/libei.rs diff --git a/src/backend/consumer/macos.rs b/src/consumer/macos.rs similarity index 100% rename from src/backend/consumer/macos.rs rename to src/consumer/macos.rs diff --git a/src/backend/consumer/windows.rs b/src/consumer/windows.rs similarity index 100% rename from src/backend/consumer/windows.rs rename to src/consumer/windows.rs diff --git a/src/backend/consumer/wlroots.rs b/src/consumer/wlroots.rs similarity index 100% rename from src/backend/consumer/wlroots.rs rename to src/consumer/wlroots.rs diff --git a/src/backend/consumer/x11.rs b/src/consumer/x11.rs similarity index 100% rename from src/backend/consumer/x11.rs rename to src/consumer/x11.rs diff --git a/src/backend/consumer/xdg_desktop_portal.rs b/src/consumer/xdg_desktop_portal.rs similarity index 100% rename from src/backend/consumer/xdg_desktop_portal.rs rename to src/consumer/xdg_desktop_portal.rs diff --git a/src/lib.rs b/src/lib.rs index 9fc69087..79be8dc1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,6 +7,5 @@ pub mod server; pub mod consumer; pub mod producer; -pub mod backend; pub mod frontend; pub mod scancode; diff --git a/src/producer.rs b/src/producer.rs index 192de113..b58f0b21 100644 --- a/src/producer.rs +++ b/src/producer.rs @@ -2,27 +2,44 @@ use std::io; use futures_core::Stream; -use crate::backend::producer; use crate::{ client::{ClientEvent, ClientHandle}, event::Event, }; +#[cfg(all(unix, feature = "libei", not(target_os = "macos")))] +pub mod libei; + +#[cfg(target_os = "macos")] +pub mod macos; + +#[cfg(all(unix, feature = "wayland", not(target_os = "macos")))] +pub mod wayland; + +#[cfg(windows)] +pub mod windows; + +#[cfg(all(unix, feature = "x11", not(target_os = "macos")))] +pub mod x11; + +/// fallback event producer +pub mod dummy; + pub async fn create() -> Box { #[cfg(target_os = "macos")] - match producer::macos::MacOSProducer::new() { + match macos::MacOSProducer::new() { Ok(p) => return Box::new(p), Err(e) => log::info!("macos event producer not available: {e}"), } #[cfg(windows)] - match producer::windows::WindowsProducer::new() { + match windows::WindowsProducer::new() { Ok(p) => return Box::new(p), Err(e) => log::info!("windows event producer not available: {e}"), } #[cfg(all(unix, feature = "libei", not(target_os = "macos")))] - match producer::libei::LibeiProducer::new().await { + match libei::LibeiProducer::new().await { Ok(p) => { log::info!("using libei event producer"); return Box::new(p); @@ -31,7 +48,7 @@ pub async fn create() -> Box { } #[cfg(all(unix, feature = "wayland", not(target_os = "macos")))] - match producer::wayland::WaylandEventProducer::new() { + match wayland::WaylandEventProducer::new() { Ok(p) => { log::info!("using layer-shell event producer"); return Box::new(p); @@ -40,7 +57,7 @@ pub async fn create() -> Box { } #[cfg(all(unix, feature = "x11", not(target_os = "macos")))] - match producer::x11::X11Producer::new() { + match x11::X11Producer::new() { Ok(p) => { log::info!("using x11 event producer"); return Box::new(p); @@ -49,7 +66,7 @@ pub async fn create() -> Box { } log::error!("falling back to dummy event producer"); - Box::new(producer::dummy::DummyProducer::new()) + Box::new(dummy::DummyProducer::new()) } pub trait EventProducer: Stream> + Unpin { diff --git a/src/backend/producer/dummy.rs b/src/producer/dummy.rs similarity index 100% rename from src/backend/producer/dummy.rs rename to src/producer/dummy.rs diff --git a/src/backend/producer/libei.rs b/src/producer/libei.rs similarity index 100% rename from src/backend/producer/libei.rs rename to src/producer/libei.rs diff --git a/src/backend/producer/macos.rs b/src/producer/macos.rs similarity index 100% rename from src/backend/producer/macos.rs rename to src/producer/macos.rs diff --git a/src/backend/producer/wayland.rs b/src/producer/wayland.rs similarity index 100% rename from src/backend/producer/wayland.rs rename to src/producer/wayland.rs diff --git a/src/backend/producer/windows.rs b/src/producer/windows.rs similarity index 100% rename from src/backend/producer/windows.rs rename to src/producer/windows.rs diff --git a/src/backend/producer/x11.rs b/src/producer/x11.rs similarity index 100% rename from src/backend/producer/x11.rs rename to src/producer/x11.rs