ipc: Add CastKind
Browse files at this commitb98f4906da021c2d37729b73f0e8fc4f84a7bc4aParent: e82830c3 changed files +27 -1
- niri-ipc/src/lib.rs +17 -0
- src/ipc/client.rs +7 -1
- src/ipc/server.rs +3 -0
niri-ipc/src/lib.rsmodified+17 -0
| @@ -1490,6 +1490,8 @@ pub struct Cast { | |||
| 1490 | /// | 1490 | /// |
| 1491 | /// Do not confuse `session_id` with [`stream_id`](Self::stream_id). | 1491 | /// Do not confuse `session_id` with [`stream_id`](Self::stream_id). |
| 1492 | pub session_id: u64, | 1492 | pub session_id: u64, |
| 1493 | + /// Kind of this screencast. | ||
| 1494 | + pub kind: CastKind, | ||
| 1493 | /// Target being captured. | 1495 | /// Target being captured. |
| 1494 | pub target: CastTarget, | 1496 | pub target: CastTarget, |
| 1495 | /// Whether this is a Dynamic Cast Target screencast. | 1497 | /// Whether this is a Dynamic Cast Target screencast. |
| @@ -1505,6 +1507,21 @@ pub struct Cast { | |||
| 1505 | pub is_active: bool, | 1507 | pub is_active: bool, |
| 1506 | } | 1508 | } |
| 1507 | 1509 | ||
| 1510 | +/// Kind of screencast. | ||
| 1511 | +#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)] | ||
| 1512 | +#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] | ||
| 1513 | +pub enum CastKind { | ||
| 1514 | + /// PipeWire screencast, typically via xdg-desktop-portal-gnome. | ||
| 1515 | + PipeWire, | ||
| 1516 | + /// wlr-screencopy protocol screencast. | ||
| 1517 | + /// | ||
| 1518 | + /// Tools like wf-recorder, and the xdg-desktop-portal-wlr portal. | ||
| 1519 | + /// | ||
| 1520 | + /// Only wlr-screencopy with damage tracking is reported here. Screencopy without damage is | ||
| 1521 | + /// treated as a regular screenshot and not reported as a screencast. | ||
| 1522 | + WlrScreencopy, | ||
| 1523 | +} | ||
| 1524 | + | ||
| 1508 | /// Target of a screencast. | 1525 | /// Target of a screencast. |
| 1509 | #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] | 1526 | #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] |
| 1510 | #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] | 1527 | #[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))] |
src/ipc/client.rsmodified+7 -1
| @@ -7,7 +7,7 @@ use anyhow::{anyhow, bail, Context}; | |||
| 7 | use niri_config::OutputName; | 7 | use niri_config::OutputName; |
| 8 | use niri_ipc::socket::Socket; | 8 | use niri_ipc::socket::Socket; |
| 9 | use niri_ipc::{ | 9 | use niri_ipc::{ |
| 10 | - Action, Cast, CastTarget, Event, KeyboardLayouts, LogicalOutput, Mode, Output, | 10 | + Action, Cast, CastKind, CastTarget, Event, KeyboardLayouts, LogicalOutput, Mode, Output, |
| 11 | OutputConfigChanged, Overview, Request, Response, Transform, Window, WindowLayout, | 11 | OutputConfigChanged, Overview, Request, Response, Transform, Window, WindowLayout, |
| 12 | }; | 12 | }; |
| 13 | use serde_json::json; | 13 | use serde_json::json; |
| @@ -743,6 +743,12 @@ fn print_cast(cast: &Cast) { | |||
| 743 | println!("Cast stream ID {}:{active}", cast.stream_id); | 743 | println!("Cast stream ID {}:{active}", cast.stream_id); |
| 744 | println!(" Session ID: {}", cast.session_id); | 744 | println!(" Session ID: {}", cast.session_id); |
| 745 | 745 | ||
| 746 | + let kind = match cast.kind { | ||
| 747 | + CastKind::PipeWire => "PipeWire", | ||
| 748 | + CastKind::WlrScreencopy => "wlr-screencopy", | ||
| 749 | + }; | ||
| 750 | + println!(" Kind: {kind}"); | ||
| 751 | + | ||
| 746 | match &cast.target { | 752 | match &cast.target { |
| 747 | CastTarget::Nothing {} => { | 753 | CastTarget::Nothing {} => { |
| 748 | println!(" Target: nothing (cleared)"); | 754 | println!(" Target: nothing (cleared)"); |
src/ipc/server.rsmodified+3 -0
| @@ -825,6 +825,7 @@ impl State { | |||
| 825 | let cast = niri_ipc::Cast { | 825 | let cast = niri_ipc::Cast { |
| 826 | session_id: pending.session_id.get(), | 826 | session_id: pending.session_id.get(), |
| 827 | stream_id, | 827 | stream_id, |
| 828 | + kind: niri_ipc::CastKind::PipeWire, | ||
| 828 | target: niri_ipc::CastTarget::Nothing {}, | 829 | target: niri_ipc::CastTarget::Nothing {}, |
| 829 | is_dynamic_target: true, | 830 | is_dynamic_target: true, |
| 830 | is_active: false, | 831 | is_active: false, |
| @@ -845,6 +846,7 @@ impl State { | |||
| 845 | let cast = niri_ipc::Cast { | 846 | let cast = niri_ipc::Cast { |
| 846 | session_id: cast.session_id.get(), | 847 | session_id: cast.session_id.get(), |
| 847 | stream_id, | 848 | stream_id, |
| 849 | + kind: niri_ipc::CastKind::PipeWire, | ||
| 848 | target: cast.target.make_ipc(), | 850 | target: cast.target.make_ipc(), |
| 849 | is_dynamic_target: cast.dynamic_target, | 851 | is_dynamic_target: cast.dynamic_target, |
| 850 | is_active: cast.is_active(), | 852 | is_active: cast.is_active(), |
| @@ -870,6 +872,7 @@ impl State { | |||
| 870 | let cast = niri_ipc::Cast { | 872 | let cast = niri_ipc::Cast { |
| 871 | session_id: cast_info.session_id.get(), | 873 | session_id: cast_info.session_id.get(), |
| 872 | stream_id, | 874 | stream_id, |
| 875 | + kind: niri_ipc::CastKind::WlrScreencopy, | ||
| 873 | target: niri_ipc::CastTarget::Output { | 876 | target: niri_ipc::CastTarget::Output { |
| 874 | name: cast_info.output_name.clone(), | 877 | name: cast_info.output_name.clone(), |
| 875 | }, | 878 | }, |