1
0
Fork 0
forked from wry/wry

Merge pull request #784 from mahkoh/jorth/pid

cli: add pid subcommand
This commit is contained in:
mahkoh 2026-03-09 22:40:47 +01:00 committed by GitHub
commit 150ead2127
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 55 additions and 3 deletions

View file

@ -7,6 +7,7 @@ mod generate;
mod idle;
mod input;
mod log;
mod pid;
mod quit;
mod randr;
mod reexec;
@ -98,6 +99,8 @@ pub enum Cmd {
Tree(TreeArgs),
/// Prints the Jay version and exits.
Version,
/// Prints the Jay PID and exits.
Pid,
#[cfg(feature = "it")]
RunTests,
}
@ -236,6 +239,7 @@ pub fn main() {
Cmd::Clients(a) => clients::main(cli.global, a),
Cmd::Tree(a) => tree::main(cli.global, a),
Cmd::Version => version::main(cli.global),
Cmd::Pid => pid::main(cli.global),
#[cfg(feature = "it")]
Cmd::RunTests => crate::it::run_tests(),
Cmd::Reexec(a) => reexec::main(cli.global, a),

29
src/cli/pid.rs Normal file
View file

@ -0,0 +1,29 @@
use {
crate::{
cli::GlobalArgs,
tools::tool_client::{Handle, ToolClient, with_tool_client},
wire::jay_compositor::{GetPid, Pid},
},
std::rc::Rc,
};
pub fn main(global: GlobalArgs) {
with_tool_client(global.log_level, |tc| async move {
let pid = Rc::new(P { tc: tc.clone() });
run(pid).await;
});
}
struct P {
tc: Rc<ToolClient>,
}
async fn run(p: Rc<P>) {
let tc = &p.tc;
let comp = tc.jay_compositor().await;
tc.send(GetPid { self_id: comp });
Pid::handle(tc, comp, (), |_, pid| {
println!("{}", pid.pid);
});
tc.round_trip().await;
}

View file

@ -77,7 +77,7 @@ global_base!(JayCompositorGlobal, JayCompositor, JayCompositorError);
impl Global for JayCompositorGlobal {
fn version(&self) -> u32 {
26
27
}
fn required_caps(&self) -> ClientCaps {
@ -533,6 +533,14 @@ impl JayCompositorRequestHandler for JayCompositor {
self.client.add_client_obj(&obj)?;
Ok(())
}
fn get_pid(&self, _req: GetPid, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client.event(Pid {
self_id: self.id,
pid: self.client.state.pid,
});
Ok(())
}
}
object_base! {

View file

@ -149,7 +149,6 @@ use {
};
pub struct State {
#[expect(dead_code)]
pub pid: c::pid_t,
pub kb_ctx: KbvmContext,
pub backend: CloneCell<Rc<dyn Backend>>,

View file

@ -334,7 +334,7 @@ impl ToolClient {
self_id: s.registry,
name: s.jay_compositor.0,
interface: JayCompositor.name(),
version: s.jay_compositor.1.min(25),
version: s.jay_compositor.1.min(27),
id: id.into(),
});
self.jay_compositor.set(Some(id));

View file

@ -234,6 +234,10 @@ impl JayCompositorEventHandler for UsrJayCompositor {
}
Ok(())
}
fn pid(&self, _ev: Pid, _slf: &Rc<Self>) -> Result<(), Self::Error> {
Ok(())
}
}
usr_object_base! {

View file

@ -131,6 +131,10 @@ request get_sync_file_surface (since = 26) {
surface: id(wl_surface),
}
request get_pid (since = 27) {
}
# events
event client_id {
@ -145,3 +149,7 @@ event seat {
event capabilities {
cap: array(pod(u16)),
}
event pid (since = 27) {
pid: pod(uapi::c::pid_t),
}