anvil: Add a xwayland feature

This commit adds an xwayland feature to anvil. Right now, this feature
doesn't do much. anvil uses the smithay code to start XWayland, but does
not do anything with it once it is running.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2021-01-03 16:21:22 +01:00 committed by Victor Berger
parent 4a065818c4
commit 2f0dadd6ca
4 changed files with 39 additions and 1 deletions

View File

@ -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"]

View File

@ -25,6 +25,8 @@ mod udev;
mod window_map;
#[cfg(feature = "winit")]
mod winit;
#[cfg(feature = "xwayland")]
mod xwayland;
use state::AnvilState;

View File

@ -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<AutoSession>,
// things we must keep alive
_wayland_event_source: Source<Generic<Fd>>,
#[cfg(feature = "xwayland")]
_xwayland: XWayland<XWm>,
}
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,
}
}
}

21
anvil/src/xwayland.rs Normal file
View File

@ -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) {}
}