cli: add pid subcommand
This commit is contained in:
parent
fe8b51ffb6
commit
447dfb3118
7 changed files with 55 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ mod generate;
|
||||||
mod idle;
|
mod idle;
|
||||||
mod input;
|
mod input;
|
||||||
mod log;
|
mod log;
|
||||||
|
mod pid;
|
||||||
mod quit;
|
mod quit;
|
||||||
mod randr;
|
mod randr;
|
||||||
mod reexec;
|
mod reexec;
|
||||||
|
|
@ -98,6 +99,8 @@ pub enum Cmd {
|
||||||
Tree(TreeArgs),
|
Tree(TreeArgs),
|
||||||
/// Prints the Jay version and exits.
|
/// Prints the Jay version and exits.
|
||||||
Version,
|
Version,
|
||||||
|
/// Prints the Jay PID and exits.
|
||||||
|
Pid,
|
||||||
#[cfg(feature = "it")]
|
#[cfg(feature = "it")]
|
||||||
RunTests,
|
RunTests,
|
||||||
}
|
}
|
||||||
|
|
@ -236,6 +239,7 @@ pub fn main() {
|
||||||
Cmd::Clients(a) => clients::main(cli.global, a),
|
Cmd::Clients(a) => clients::main(cli.global, a),
|
||||||
Cmd::Tree(a) => tree::main(cli.global, a),
|
Cmd::Tree(a) => tree::main(cli.global, a),
|
||||||
Cmd::Version => version::main(cli.global),
|
Cmd::Version => version::main(cli.global),
|
||||||
|
Cmd::Pid => pid::main(cli.global),
|
||||||
#[cfg(feature = "it")]
|
#[cfg(feature = "it")]
|
||||||
Cmd::RunTests => crate::it::run_tests(),
|
Cmd::RunTests => crate::it::run_tests(),
|
||||||
Cmd::Reexec(a) => reexec::main(cli.global, a),
|
Cmd::Reexec(a) => reexec::main(cli.global, a),
|
||||||
|
|
|
||||||
29
src/cli/pid.rs
Normal file
29
src/cli/pid.rs
Normal 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;
|
||||||
|
}
|
||||||
|
|
@ -77,7 +77,7 @@ global_base!(JayCompositorGlobal, JayCompositor, JayCompositorError);
|
||||||
|
|
||||||
impl Global for JayCompositorGlobal {
|
impl Global for JayCompositorGlobal {
|
||||||
fn version(&self) -> u32 {
|
fn version(&self) -> u32 {
|
||||||
26
|
27
|
||||||
}
|
}
|
||||||
|
|
||||||
fn required_caps(&self) -> ClientCaps {
|
fn required_caps(&self) -> ClientCaps {
|
||||||
|
|
@ -533,6 +533,14 @@ impl JayCompositorRequestHandler for JayCompositor {
|
||||||
self.client.add_client_obj(&obj)?;
|
self.client.add_client_obj(&obj)?;
|
||||||
Ok(())
|
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! {
|
object_base! {
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,6 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct State {
|
pub struct State {
|
||||||
#[expect(dead_code)]
|
|
||||||
pub pid: c::pid_t,
|
pub pid: c::pid_t,
|
||||||
pub kb_ctx: KbvmContext,
|
pub kb_ctx: KbvmContext,
|
||||||
pub backend: CloneCell<Rc<dyn Backend>>,
|
pub backend: CloneCell<Rc<dyn Backend>>,
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ impl ToolClient {
|
||||||
self_id: s.registry,
|
self_id: s.registry,
|
||||||
name: s.jay_compositor.0,
|
name: s.jay_compositor.0,
|
||||||
interface: JayCompositor.name(),
|
interface: JayCompositor.name(),
|
||||||
version: s.jay_compositor.1.min(25),
|
version: s.jay_compositor.1.min(27),
|
||||||
id: id.into(),
|
id: id.into(),
|
||||||
});
|
});
|
||||||
self.jay_compositor.set(Some(id));
|
self.jay_compositor.set(Some(id));
|
||||||
|
|
|
||||||
|
|
@ -234,6 +234,10 @@ impl JayCompositorEventHandler for UsrJayCompositor {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pid(&self, _ev: Pid, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usr_object_base! {
|
usr_object_base! {
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,10 @@ request get_sync_file_surface (since = 26) {
|
||||||
surface: id(wl_surface),
|
surface: id(wl_surface),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request get_pid (since = 27) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# events
|
# events
|
||||||
|
|
||||||
event client_id {
|
event client_id {
|
||||||
|
|
@ -145,3 +149,7 @@ event seat {
|
||||||
event capabilities {
|
event capabilities {
|
||||||
cap: array(pod(u16)),
|
cap: array(pod(u16)),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event pid (since = 27) {
|
||||||
|
pid: pod(uapi::c::pid_t),
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue