mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
ipc: Add pw_node_id to PipeWire Casts
This commit is contained in:
@@ -1509,6 +1509,11 @@ pub struct Cast {
|
||||
///
|
||||
/// Currently, only wlr-screencopy screencasts can have a pid.
|
||||
pub pid: Option<i32>,
|
||||
/// PipeWire node ID of the screencast stream.
|
||||
///
|
||||
/// This is `None` for wlr-screencopy casts, and also for PipeWire casts before the node is
|
||||
/// created (when the cast is just starting up).
|
||||
pub pw_node_id: Option<u32>,
|
||||
}
|
||||
|
||||
/// Kind of screencast.
|
||||
|
||||
@@ -768,6 +768,10 @@ fn print_cast(cast: &Cast) {
|
||||
if let Some(pid) = cast.pid {
|
||||
println!(" PID: {pid}");
|
||||
}
|
||||
|
||||
if let Some(node_id) = cast.pw_node_id {
|
||||
println!(" PipeWire node ID: {node_id}");
|
||||
}
|
||||
}
|
||||
|
||||
fn fmt_rounded(x: f64) -> String {
|
||||
|
||||
+7
-1
@@ -830,6 +830,7 @@ impl State {
|
||||
is_dynamic_target: true,
|
||||
is_active: false,
|
||||
pid: None,
|
||||
pw_node_id: None,
|
||||
};
|
||||
events.push(Event::CastStartedOrChanged { cast });
|
||||
}
|
||||
@@ -840,9 +841,12 @@ impl State {
|
||||
let stream_id = cast.stream_id.get();
|
||||
seen.insert(stream_id);
|
||||
|
||||
let pw_node_id = cast.node_id();
|
||||
if state.casts.get(&stream_id).is_none_or(|existing| {
|
||||
// Only these properties can change.
|
||||
existing.is_active != cast.is_active() || !cast.target.matches(&existing.target)
|
||||
existing.is_active != cast.is_active()
|
||||
|| !cast.target.matches(&existing.target)
|
||||
|| existing.pw_node_id != pw_node_id
|
||||
}) {
|
||||
let cast = niri_ipc::Cast {
|
||||
session_id: cast.session_id.get(),
|
||||
@@ -852,6 +856,7 @@ impl State {
|
||||
is_dynamic_target: cast.dynamic_target,
|
||||
is_active: cast.is_active(),
|
||||
pid: None,
|
||||
pw_node_id,
|
||||
};
|
||||
events.push(Event::CastStartedOrChanged { cast });
|
||||
}
|
||||
@@ -886,6 +891,7 @@ impl State {
|
||||
is_dynamic_target: false,
|
||||
is_active: true,
|
||||
pid: queue.credentials().map(|creds| creds.pid),
|
||||
pw_node_id: None,
|
||||
};
|
||||
events.push(Event::CastStartedOrChanged { cast });
|
||||
}
|
||||
|
||||
@@ -819,6 +819,10 @@ impl Cast {
|
||||
self.inner.borrow().is_active
|
||||
}
|
||||
|
||||
pub fn node_id(&self) -> Option<u32> {
|
||||
self.inner.borrow().node_id
|
||||
}
|
||||
|
||||
pub fn ensure_size(&self, size: Size<i32, Physical>) -> anyhow::Result<CastSizeChange> {
|
||||
let mut inner = self.inner.borrow_mut();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user