fix(wayland): properly kill off xwayland

This commit is contained in:
Nova
2024-06-13 10:18:42 -04:00
parent 83e3a913c5
commit f73c8f968d
6 changed files with 14 additions and 78 deletions

39
Cargo.lock generated
View File

@@ -623,15 +623,6 @@ version = "1.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b"
[[package]]
name = "encoding_rs"
version = "0.8.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
dependencies = [
"cfg-if",
]
[[package]]
name = "env_logger"
version = "0.10.2"
@@ -766,16 +757,6 @@ dependencies = [
"windows",
]
[[package]]
name = "gethostname"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0176e0459c2e4a1fe232f984bca6890e681076abb9934f6cea7c326f3fc47818"
dependencies = [
"libc",
"windows-targets 0.48.5",
]
[[package]]
name = "getrandom"
version = "0.2.15"
@@ -1984,7 +1965,6 @@ dependencies = [
"drm",
"drm-ffi",
"drm-fourcc",
"encoding_rs",
"errno",
"gl_generator",
"indexmap 2.2.6",
@@ -1996,7 +1976,6 @@ dependencies = [
"rand",
"rustix",
"scan_fmt",
"scopeguard",
"smallvec",
"tempfile",
"thiserror",
@@ -2005,7 +1984,6 @@ dependencies = [
"wayland-protocols-misc",
"wayland-protocols-wlr",
"wayland-server",
"x11rb",
"xkbcommon",
]
@@ -2906,23 +2884,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "x11rb"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d91ffca73ee7f68ce055750bf9f6eca0780b8c85eff9bc046a3b0da41755e12"
dependencies = [
"gethostname",
"rustix",
"x11rb-protocol",
]
[[package]]
name = "x11rb-protocol"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d"
[[package]]
name = "xkbcommon"
version = "0.7.0"

View File

@@ -19,8 +19,6 @@ path = "src/main.rs"
[features]
default = ["wayland"]
wayland = ["dep:smithay", "dep:xkbcommon"]
xwayland_rootful = []
xwayland_rootless = ["smithay/xwayland"]
profile_tokio = ["dep:console-subscriber", "tokio/tracing"]
profile_app = ["dep:tracing-tracy"]

View File

@@ -6,8 +6,6 @@ use crate::core::registry::Registry;
use crate::nodes::spatial::SPATIAL_REF_ASPECT_ALIAS_INFO;
#[cfg(feature = "wayland")]
use crate::wayland::WAYLAND_DISPLAY;
#[cfg(feature = "xwayland")]
use crate::wayland::X_DISPLAY;
use crate::STARDUST_INSTANCE;
use color_eyre::eyre::{bail, Result};
use glam::Mat4;
@@ -74,11 +72,6 @@ impl RootAspect for Root {
#[cfg(feature = "wayland")]
{
var_env_insert!(env, WAYLAND_DISPLAY);
#[cfg(feature = "xwayland")]
env.insert(
"DISPLAY".to_string(),
format!(":{}", X_DISPLAY.get().unwrap()),
);
env.insert("GDK_BACKEND".to_string(), "wayland".to_string());
env.insert("QT_QPA_PLATFORM".to_string(), "wayland".to_string());
env.insert("MOZ_ENABLE_WAYLAND".to_string(), "1".to_string());

View File

@@ -2,8 +2,6 @@ use crate::wayland::surface::CoreSurface;
use super::state::{ClientState, WaylandState};
use portable_atomic::{AtomicU32, Ordering};
#[cfg(feature = "xwayland_rootless")]
use smithay::xwayland::XWaylandClientData;
use smithay::{
delegate_compositor,
reexports::wayland_server::{protocol::wl_surface::WlSurface, Client},
@@ -38,15 +36,7 @@ impl CompositorHandler for WaylandState {
}
fn client_compositor_state<'a>(&self, client: &'a Client) -> &'a CompositorClientState {
if let Some(client_state) = client.get_data::<ClientState>() {
&client_state.compositor_state
} else {
#[cfg(feature = "xwayland_rootless")]
if let Some(xwayland_client_data) = client.get_data::<XWaylandClientData>() {
return &xwayland_client_data.compositor_state;
}
unimplemented!()
}
&client.get_data::<ClientState>().unwrap().compositor_state
}
}

View File

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

View File

@@ -1,4 +1,4 @@
use super::{state::WaylandState, utils::get_data};
use super::{state::WaylandState, utils};
use crate::{
core::{delta::Delta, destroy_queue, registry::Registry},
nodes::{
@@ -12,7 +12,6 @@ use crate::{
use mint::Vector2;
use once_cell::sync::OnceCell;
use parking_lot::Mutex;
use send_wrapper::SendWrapper;
use smithay::{
backend::renderer::{
@@ -64,21 +63,18 @@ impl CoreSurface {
on_mapped: impl Fn() + Send + Sync + 'static,
on_commit: impl Fn(u32) + Send + Sync + 'static,
) {
compositor::with_states(surface, |data| {
data.data_map.insert_if_missing_threadsafe(|| {
CORE_SURFACES.add(CoreSurface {
dh,
weak_surface: surface.downgrade(),
mapped_data: Mutex::new(None),
sk_tex: OnceCell::new(),
sk_mat: OnceCell::new(),
material_offset: Mutex::new(Delta::new(0)),
on_mapped: Mutex::new(Box::new(on_mapped) as Box<dyn Fn() + Send + Sync>),
on_commit: Mutex::new(Box::new(on_commit) as Box<dyn Fn(u32) + Send + Sync>),
pending_material_applications: Registry::new(),
})
});
let core_surface = CORE_SURFACES.add(CoreSurface {
dh,
weak_surface: surface.downgrade(),
mapped_data: Mutex::new(None),
sk_tex: OnceCell::new(),
sk_mat: OnceCell::new(),
material_offset: Mutex::new(Delta::new(0)),
on_mapped: Mutex::new(Box::new(on_mapped) as Box<dyn Fn() + Send + Sync>),
on_commit: Mutex::new(Box::new(on_commit) as Box<dyn Fn(u32) + Send + Sync>),
pending_material_applications: Registry::new(),
});
utils::insert_data_raw(surface, core_surface);
}
pub fn commit(&self, count: u32) {
@@ -86,7 +82,7 @@ impl CoreSurface {
}
pub fn from_wl_surface(surf: &WlSurface) -> Option<Arc<CoreSurface>> {
get_data(surf)
utils::get_data(surf)
}
pub fn decycle(&self) {