1
0
Fork 0
forked from wry/wry

all: refactor to cargo workspace, remove config shared library, remove protocol perms, add dpms cli (#7)

This commit is contained in:
kossLAN 2026-06-06 23:14:53 -04:00
parent 5db14936e7
commit bfc2a525de
616 changed files with 32344 additions and 31026 deletions

View file

@ -167,7 +167,6 @@ pub struct Client {
pub is_xwayland: bool,
pub comm: Option<String>,
pub exe: Option<String>,
pub tag: Option<String>,
}
pub async fn handle_client_query(
@ -212,9 +211,6 @@ pub async fn handle_client_query(
Exe::handle(tl, id, c.clone(), |c, event| {
last!(c).exe = Some(event.exe.to_string());
});
Tag::handle(tl, id, c.clone(), |c, event| {
last!(c).tag = Some(event.tag.to_string());
});
tl.round_trip().await;
mem::take(&mut *c.borrow_mut())
.into_iter()
@ -253,7 +249,6 @@ impl ClientPrinter<'_> {
bol!(is_xwayland, "xwayland");
opt!(comm, "comm");
opt!(exe, "exe");
opt!(tag, "tag");
}
}
@ -269,6 +264,5 @@ pub fn make_json_client(client: &Client) -> JsonClient<'_> {
is_xwayland: client.is_xwayland,
comm: client.comm.as_deref(),
exe: client.exe.as_deref(),
tag: client.tag.as_deref(),
}
}

23
src/cli/dpms.rs Normal file
View file

@ -0,0 +1,23 @@
use {
crate::{
cli::{DpmsArgs, DpmsState, GlobalArgs},
tools::tool_client::{ToolClient, with_tool_client},
wire::jay_compositor::SetDpms,
},
std::rc::Rc,
};
pub fn main(global: GlobalArgs, args: DpmsArgs) {
with_tool_client(global.log_level, |tc| async move {
run(tc, args).await;
});
}
async fn run(tc: Rc<ToolClient>, args: DpmsArgs) {
let comp = tc.jay_compositor().await;
tc.send(SetDpms {
self_id: comp,
active: (args.state == DpmsState::On) as u32,
});
tc.round_trip().await;
}

View file

@ -66,8 +66,6 @@ pub struct JsonClient<'a> {
pub comm: Option<&'a str>,
#[serde(skip_serializing_if = "is_none")]
pub exe: Option<&'a str>,
#[serde(skip_serializing_if = "is_none")]
pub tag: Option<&'a str>,
}
#[derive(Serialize)]

View file

@ -1,35 +0,0 @@
use {
crate::{
cli::{GlobalArgs, RunPrivilegedArgs},
compositor::WAYLAND_DISPLAY,
logger::Logger,
utils::{errorfmt::ErrorFmt, oserror::OsErrorExt, xrd::xrd},
},
std::path::PathBuf,
uapi::UstrPtr,
};
pub fn main(global: GlobalArgs, args: RunPrivilegedArgs) {
Logger::install_stderr(global.log_level);
if let Some(xrd) = xrd() {
let mut wd = match std::env::var(WAYLAND_DISPLAY) {
Ok(v) => v,
_ => fatal!("{} is not set", WAYLAND_DISPLAY),
};
wd.push_str(".jay");
let mut path = PathBuf::from(xrd);
path.push(&wd);
if path.exists() {
unsafe {
std::env::set_var(WAYLAND_DISPLAY, &wd);
}
}
}
let mut argv = UstrPtr::new();
for arg in &args.program {
argv.push(arg.as_str());
}
let program = args.program[0].as_str();
let res = uapi::execvp(program, &argv).to_os_error().unwrap_err();
fatal!("Could not execute `{}`: {}", program, ErrorFmt(res));
}

View file

@ -1,70 +0,0 @@
use {
crate::{
cli::GlobalArgs,
compositor::WAYLAND_DISPLAY,
tools::tool_client::{Handle, ToolClient, with_tool_client},
utils::{errorfmt::ErrorFmt, oserror::OsErrorExt},
wire::{jay_acceptor_request, jay_compositor},
},
clap::{Args, ValueHint},
std::{cell::Cell, env, rc::Rc},
uapi::UstrPtr,
};
#[derive(Args, Debug)]
pub struct RunTaggedArgs {
/// Specifies a tag to apply to all spawned wayland connections.
tag: String,
/// The program to run.
#[clap(required = true, trailing_var_arg = true, value_hint = ValueHint::CommandWithArguments)]
pub program: Vec<String>,
}
pub fn main(global: GlobalArgs, run_tagged_args: RunTaggedArgs) {
with_tool_client(global.log_level, |tc| async move {
let run_tagged = Rc::new(RunTagged { tc: tc.clone() });
run_tagged.run(run_tagged_args).await;
});
}
struct RunTagged {
tc: Rc<ToolClient>,
}
impl RunTagged {
async fn run(&self, args: RunTaggedArgs) {
let tc = &self.tc;
let comp = tc.jay_compositor().await;
let req = tc.id();
tc.send(jay_compositor::GetTaggedAcceptor {
self_id: comp,
id: req,
tag: &args.tag,
});
let res = Rc::new(Cell::new(None));
jay_acceptor_request::Done::handle(&tc, req, res.clone(), |res, ev| {
res.set(Some(Ok(ev.name.to_owned())));
});
jay_acceptor_request::Failed::handle(&tc, req, res.clone(), |res, ev| {
res.set(Some(Err(ev.msg.to_owned())));
});
tc.round_trip().await;
match res.take().unwrap() {
Ok(n) => {
unsafe {
env::set_var(WAYLAND_DISPLAY, &n);
}
let mut argv = UstrPtr::new();
for arg in &args.program {
argv.push(arg.as_str());
}
let program = args.program[0].as_str();
let res = uapi::execvp(program, &argv).to_os_error().unwrap_err();
fatal!("Could not execute `{}`: {}", program, ErrorFmt(res));
}
Err(msg) => {
fatal!("Could not create acceptor: {}", msg);
}
}
}
}