Skip to content

Commit

Permalink
refactor(wayland/xwayland_rootless): use tokio
Browse files Browse the repository at this point in the history
  • Loading branch information
technobaboo committed Apr 5, 2024
1 parent 4925356 commit 90f60c9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 433 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ fxtypemap = "0.2.0"
toml = "0.8.10"

[dependencies.smithay]
# git = "https://github.com/technobaboo/smithay.git" # Until we get stereokit to understand OES samplers and external textures
git = "https://github.com/smithay/smithay.git" # Until we get stereokit to understand OES samplers and external textures
# git = "https://github.com/technobaboo/smithay.git"
git = "https://github.com/colinmarc/smithay.git"
# git = "https://github.com/smithay/smithay.git"
# path = "../smithay"
default-features = false
features = [
Expand Down
4 changes: 2 additions & 2 deletions src/wayland/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::wayland::surface::CoreSurface;

use super::state::{ClientState, WaylandState};
use portable_atomic::{AtomicU32, Ordering};
#[cfg(feature = "xwayland")]
#[cfg(feature = "xwayland_rootless")]
use smithay::xwayland::XWaylandClientData;
use smithay::{
delegate_compositor,
Expand Down Expand Up @@ -41,7 +41,7 @@ impl CompositorHandler for WaylandState {
if let Some(client_state) = client.get_data::<ClientState>() {
&client_state.compositor_state
} else {
#[cfg(feature = "xwayland")]
#[cfg(feature = "xwayland_rootless")]
if let Some(xwayland_client_data) = client.get_data::<XWaylandClientData>() {
return &xwayland_client_data.compositor_state;
}
Expand Down
15 changes: 9 additions & 6 deletions src/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::wayland::xwayland_rootful::start_xwayland;
#[cfg(feature = "xwayland_rootless")]
pub mod xwayland_rootless;
#[cfg(feature = "xwayland_rootless")]
use self::xwayland_rootless::XWaylandState;
use crate::wayland::xwayland_rootless::start_xwayland;

use self::{state::WaylandState, surface::CORE_SURFACES};
use crate::{core::task, wayland::state::ClientState};
Expand Down Expand Up @@ -101,7 +101,7 @@ pub struct Wayland {
#[cfg(feature = "xwayland_rootful")]
pub x_lock: X11Lock,
#[cfg(feature = "xwayland_rootless")]
pub xwayland_state: XWaylandState,
xwayland_join_handle: JoinHandle<Result<()>>,
}
impl Wayland {
pub fn new() -> Result<Self> {
Expand All @@ -120,9 +120,7 @@ impl Wayland {
let (dmabuf_tx, dmabuf_rx) = mpsc::unbounded_channel();
let display = Arc::new(DisplayWrapper(Mutex::new(display), display_handle.clone()));

#[cfg(feature = "xwayland_rootless")]
let xwayland_state = XWaylandState::create(&display_handle)?;
let wayland_state = WaylandState::new(display_handle, &renderer, dmabuf_tx);
let wayland_state = WaylandState::new(display_handle.clone(), &renderer, dmabuf_tx);
let output = wayland_state.lock().output.clone();

let socket = ListeningSocket::bind_auto("wayland", 0..33)?;
Expand All @@ -138,6 +136,9 @@ impl Wayland {
info!(socket_name, "Wayland active");

let join_handle = Wayland::start_loop(display.clone(), socket, wayland_state)?;
#[cfg(feature = "xwayland_rootless")]
let xwayland_join_handle = task::new(|| "xwayland", start_xwayland(display_handle))?;

Ok(Wayland {
display,
socket_name,
Expand All @@ -148,7 +149,7 @@ impl Wayland {
#[cfg(feature = "xwayland_rootful")]
x_lock: x_display,
#[cfg(feature = "xwayland_rootless")]
xwayland_state,
xwayland_join_handle,
})
}

Expand Down Expand Up @@ -226,5 +227,7 @@ impl Wayland {
impl Drop for Wayland {
fn drop(&mut self) {
self.join_handle.abort();
#[cfg(feature = "xwayland_rootless")]
self.xwayland_join_handle.abort();
}
}
Loading

0 comments on commit 90f60c9

Please sign in to comment.