1
0
Fork 0
forked from wry/wry

refactor: split cargo workspace

This commit is contained in:
kossLAN 2026-06-05 11:56:21 -04:00
parent 5db14936e7
commit 1c21bd1259
695 changed files with 32023 additions and 44964 deletions

View file

@ -3,20 +3,18 @@ mod xwm;
use {
crate::{
client::{ClientCaps, ClientError},
client::{ClientError, ClientMetadata},
compositor::DISPLAY,
forker::{ForkerError, ForkerProxy},
ifs::{
ipc::{DataOfferId, DataSourceId, IpcLocation, x_data_offer::XDataOffer},
data_transfer::{DataOfferId, DataSourceId, TransferLocation, x_data_offer::XDataOffer},
wl_seat::SeatId,
wl_surface::x_surface::xwindow::{Xwindow, XwindowData},
},
io_uring::IoUringError,
security_context_acceptor::AcceptorMetadata,
state::State,
user_session::import_environment,
utils::{
buf::Buf,
errorfmt::ErrorFmt,
line_logger::log_lines,
oserror::{OsError, OsErrorExt2},
@ -192,10 +190,8 @@ async fn run(
Rc::new(client1),
uapi::getuid(),
pid,
ClientCaps::all(),
false,
true,
&Rc::new(AcceptorMetadata::default()),
&Rc::new(ClientMetadata::default()),
);
let client = match client {
Ok(c) => c,
@ -226,11 +222,11 @@ async fn run(
}
const PROG: &str = "Xwayland";
const ENABLE_EI_PORTAL: &str = "-enable-ei-portal";
pub async fn build_args(state: &State, forker: &ForkerProxy) -> (String, Vec<String>) {
let _ = (state, forker);
let prog = PROG.to_string();
let mut args = vec![
let args = vec![
"-terminate".to_string(),
"-rootless".to_string(),
"-verbose".to_string(),
@ -242,45 +238,9 @@ pub async fn build_args(state: &State, forker: &ForkerProxy) -> (String, Vec<Str
"-wm".to_string(),
"5".to_string(),
];
let features = detect_features(state, forker).await;
if features.ei_portal {
args.push(ENABLE_EI_PORTAL.to_string());
}
(prog, args)
}
#[derive(Default, Debug)]
struct XwaylandFeatures {
ei_portal: bool,
}
async fn detect_features(state: &State, forker: &ForkerProxy) -> XwaylandFeatures {
let mut features = Default::default();
let Ok(Pipe { read, write }) = pipe() else {
return features;
};
forker.spawn(
PROG.to_string(),
vec!["-help".to_string()],
vec![],
vec![(2, Rc::new(write))],
);
let read = Rc::new(read);
let mut help = Vec::new();
let mut buf = Buf::new(1024);
loop {
match state.ring.read(&read, buf.clone()).await {
Ok(0) => break,
Ok(n) => help.extend_from_slice(&buf[..n]),
Err(_) => return features,
}
}
if help.as_bstr().contains_str(ENABLE_EI_PORTAL) {
features.ei_portal = true;
}
features
}
async fn log_xwayland(state: Rc<State>, stderr: OwnedFd) {
let stderr = Rc::new(stderr);
let res = log_lines(&state.ring, &stderr, |left, right| {
@ -303,30 +263,30 @@ pub enum XWaylandEvent {
#[expect(dead_code)]
SeatChanged,
IpcCancelSource {
location: IpcLocation,
DataTransferCancelSource {
location: TransferLocation,
seat: SeatId,
source: DataSourceId,
},
IpcSendSource {
location: IpcLocation,
DataTransferSendSource {
location: TransferLocation,
seat: SeatId,
source: DataSourceId,
mime_type: String,
fd: Rc<OwnedFd>,
},
IpcSetOffer {
location: IpcLocation,
DataTransferSetOffer {
location: TransferLocation,
seat: SeatId,
offer: Rc<XDataOffer>,
},
IpcSetSelection {
location: IpcLocation,
DataTransferSetSelection {
location: TransferLocation,
seat: SeatId,
offer: Option<Rc<XDataOffer>>,
},
IpcAddOfferMimeType {
location: IpcLocation,
DataTransferAddOfferMimeType {
location: TransferLocation,
seat: SeatId,
offer: DataOfferId,
mime_type: String,