mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07:00
ipc: Add CastKind
This commit is contained in:
@@ -1490,6 +1490,8 @@ pub struct Cast {
|
|||||||
///
|
///
|
||||||
/// Do not confuse `session_id` with [`stream_id`](Self::stream_id).
|
/// Do not confuse `session_id` with [`stream_id`](Self::stream_id).
|
||||||
pub session_id: u64,
|
pub session_id: u64,
|
||||||
|
/// Kind of this screencast.
|
||||||
|
pub kind: CastKind,
|
||||||
/// Target being captured.
|
/// Target being captured.
|
||||||
pub target: CastTarget,
|
pub target: CastTarget,
|
||||||
/// Whether this is a Dynamic Cast Target screencast.
|
/// Whether this is a Dynamic Cast Target screencast.
|
||||||
@@ -1505,6 +1507,21 @@ pub struct Cast {
|
|||||||
pub is_active: bool,
|
pub is_active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Kind of screencast.
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
|
||||||
|
pub enum CastKind {
|
||||||
|
/// PipeWire screencast, typically via xdg-desktop-portal-gnome.
|
||||||
|
PipeWire,
|
||||||
|
/// wlr-screencopy protocol screencast.
|
||||||
|
///
|
||||||
|
/// Tools like wf-recorder, and the xdg-desktop-portal-wlr portal.
|
||||||
|
///
|
||||||
|
/// Only wlr-screencopy with damage tracking is reported here. Screencopy without damage is
|
||||||
|
/// treated as a regular screenshot and not reported as a screencast.
|
||||||
|
WlrScreencopy,
|
||||||
|
}
|
||||||
|
|
||||||
/// Target of a screencast.
|
/// Target of a screencast.
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
|
#[cfg_attr(feature = "json-schema", derive(schemars::JsonSchema))]
|
||||||
|
|||||||
+7
-1
@@ -7,7 +7,7 @@ use anyhow::{anyhow, bail, Context};
|
|||||||
use niri_config::OutputName;
|
use niri_config::OutputName;
|
||||||
use niri_ipc::socket::Socket;
|
use niri_ipc::socket::Socket;
|
||||||
use niri_ipc::{
|
use niri_ipc::{
|
||||||
Action, Cast, CastTarget, Event, KeyboardLayouts, LogicalOutput, Mode, Output,
|
Action, Cast, CastKind, CastTarget, Event, KeyboardLayouts, LogicalOutput, Mode, Output,
|
||||||
OutputConfigChanged, Overview, Request, Response, Transform, Window, WindowLayout,
|
OutputConfigChanged, Overview, Request, Response, Transform, Window, WindowLayout,
|
||||||
};
|
};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
@@ -743,6 +743,12 @@ fn print_cast(cast: &Cast) {
|
|||||||
println!("Cast stream ID {}:{active}", cast.stream_id);
|
println!("Cast stream ID {}:{active}", cast.stream_id);
|
||||||
println!(" Session ID: {}", cast.session_id);
|
println!(" Session ID: {}", cast.session_id);
|
||||||
|
|
||||||
|
let kind = match cast.kind {
|
||||||
|
CastKind::PipeWire => "PipeWire",
|
||||||
|
CastKind::WlrScreencopy => "wlr-screencopy",
|
||||||
|
};
|
||||||
|
println!(" Kind: {kind}");
|
||||||
|
|
||||||
match &cast.target {
|
match &cast.target {
|
||||||
CastTarget::Nothing {} => {
|
CastTarget::Nothing {} => {
|
||||||
println!(" Target: nothing (cleared)");
|
println!(" Target: nothing (cleared)");
|
||||||
|
|||||||
@@ -825,6 +825,7 @@ impl State {
|
|||||||
let cast = niri_ipc::Cast {
|
let cast = niri_ipc::Cast {
|
||||||
session_id: pending.session_id.get(),
|
session_id: pending.session_id.get(),
|
||||||
stream_id,
|
stream_id,
|
||||||
|
kind: niri_ipc::CastKind::PipeWire,
|
||||||
target: niri_ipc::CastTarget::Nothing {},
|
target: niri_ipc::CastTarget::Nothing {},
|
||||||
is_dynamic_target: true,
|
is_dynamic_target: true,
|
||||||
is_active: false,
|
is_active: false,
|
||||||
@@ -845,6 +846,7 @@ impl State {
|
|||||||
let cast = niri_ipc::Cast {
|
let cast = niri_ipc::Cast {
|
||||||
session_id: cast.session_id.get(),
|
session_id: cast.session_id.get(),
|
||||||
stream_id,
|
stream_id,
|
||||||
|
kind: niri_ipc::CastKind::PipeWire,
|
||||||
target: cast.target.make_ipc(),
|
target: cast.target.make_ipc(),
|
||||||
is_dynamic_target: cast.dynamic_target,
|
is_dynamic_target: cast.dynamic_target,
|
||||||
is_active: cast.is_active(),
|
is_active: cast.is_active(),
|
||||||
@@ -870,6 +872,7 @@ impl State {
|
|||||||
let cast = niri_ipc::Cast {
|
let cast = niri_ipc::Cast {
|
||||||
session_id: cast_info.session_id.get(),
|
session_id: cast_info.session_id.get(),
|
||||||
stream_id,
|
stream_id,
|
||||||
|
kind: niri_ipc::CastKind::WlrScreencopy,
|
||||||
target: niri_ipc::CastTarget::Output {
|
target: niri_ipc::CastTarget::Output {
|
||||||
name: cast_info.output_name.clone(),
|
name: cast_info.output_name.clone(),
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user