diff --git a/anvil/Cargo.toml b/anvil/Cargo.toml index 4dbfd7c..4aa7026 100644 --- a/anvil/Cargo.toml +++ b/anvil/Cargo.toml @@ -25,10 +25,11 @@ features = [ "renderer_glium", "backend_egl", "wayland_frontend" ] gl_generator = "0.14" [features] -default = [ "winit", "egl", "udev", "logind" ] +default = [ "winit", "egl", "udev", "logind", "xwayland" ] egl = [ "smithay/use_system_lib" ] winit = [ "smithay/backend_winit" ] udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_atomic", "smithay/backend_drm_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_eglstream", "smithay/backend_drm_egl", "smithay/backend_session", "input" ] logind = [ "smithay/backend_session_logind" ] elogind = ["logind", "smithay/backend_session_elogind" ] +xwayland = [ "smithay/xwayland" ] test_all_features = ["default"] diff --git a/anvil/src/main.rs b/anvil/src/main.rs index f6d28cc..99211e1 100644 --- a/anvil/src/main.rs +++ b/anvil/src/main.rs @@ -25,6 +25,8 @@ mod udev; mod window_map; #[cfg(feature = "winit")] mod winit; +#[cfg(feature = "xwayland")] +mod xwayland; use state::AnvilState; diff --git a/anvil/src/state.rs b/anvil/src/state.rs index 48bc6ce..dca38e3 100644 --- a/anvil/src/state.rs +++ b/anvil/src/state.rs @@ -25,9 +25,13 @@ use smithay::{ #[cfg(feature = "udev")] use smithay::backend::session::{auto::AutoSession, Session}; +#[cfg(feature = "xwayland")] +use smithay::xwayland::XWayland; #[cfg(feature = "udev")] use crate::udev::MyOutput; +#[cfg(feature = "xwayland")] +use crate::xwayland::XWm; use crate::{buffer_utils::BufferUtils, shell::init_shell}; pub struct AnvilState { @@ -51,6 +55,8 @@ pub struct AnvilState { pub session: Option, // things we must keep alive _wayland_event_source: Source>, + #[cfg(feature = "xwayland")] + _xwayland: XWayland, } impl AnvilState { @@ -153,6 +159,12 @@ impl AnvilState { }) .expect("Failed to initialize the keyboard"); + #[cfg(feature = "xwayland")] + let _xwayland = { + let xwm = XWm::new(); + XWayland::init(xwm, handle.clone(), display.clone(), &mut (), log.clone()).unwrap() + }; + AnvilState { running: Arc::new(AtomicBool::new(true)), display, @@ -172,6 +184,8 @@ impl AnvilState { #[cfg(feature = "udev")] session, _wayland_event_source, + #[cfg(feature = "xwayland")] + _xwayland, } } } diff --git a/anvil/src/xwayland.rs b/anvil/src/xwayland.rs new file mode 100644 index 0000000..dffd8b0 --- /dev/null +++ b/anvil/src/xwayland.rs @@ -0,0 +1,21 @@ +use std::os::unix::net::UnixStream; + +use smithay:: { + reexports::wayland_server::Client, + xwayland::XWindowManager, +}; + +pub struct XWm; + +impl XWm { + pub fn new() -> Self { + Self + } +} + +impl XWindowManager for XWm { + fn xwayland_ready(&mut self, _connection: UnixStream, _client: Client) { + } + + fn xwayland_exited(&mut self) {} +}