forge
Explore
Log in

Don't you dare go Hollow

Add CastKind::ExtImageCopyCaptureCursor

Browse files at this commit

2c0b311be3004b1376ea8086dc58766f58b709a4Ivan MolodetskikhParent: f68577d
niri-ipc/src/lib.rsmodified+5 -0
@@ -1609,6 +1609,11 @@ pub enum CastKind {
1609 /// A client capturing both an output and the cursor creates two sessions, which are reported1609 /// A client capturing both an output and the cursor creates two sessions, which are reported
1610 /// as two `Cast`s sharing one [`session_id`](Cast::session_id).1610 /// as two `Cast`s sharing one [`session_id`](Cast::session_id).
1611 ExtImageCopyCapture,1611 ExtImageCopyCapture,
1612+ /// ext-image-copy-capture protocol cursor screencast.
1613+ ///
1614+ /// `Cast`s of this kind show the image of the cursor and cursor position. Their
1615+ /// [`target`](Cast::target) indicates the output or window that the cursor is captured over.
1616+ ExtImageCopyCaptureCursor,
1612 }1617 }
1613 1618
1614 /// Target of a screencast.1619 /// Target of a screencast.
src/ipc/client.rsmodified+1 -0
@@ -784,6 +784,7 @@ fn print_cast(cast: &Cast) {
784 CastKind::PipeWire => "PipeWire",784 CastKind::PipeWire => "PipeWire",
785 CastKind::WlrScreencopy => "wlr-screencopy",785 CastKind::WlrScreencopy => "wlr-screencopy",
786 CastKind::ExtImageCopyCapture => "ext-image-copy-capture",786 CastKind::ExtImageCopyCapture => "ext-image-copy-capture",
787+ CastKind::ExtImageCopyCaptureCursor => "ext-image-copy-capture (cursor)",
787 };788 };
788 println!(" Kind: {kind}");789 println!(" Kind: {kind}");
789 790
src/ipc/server.rsmodified+22 -12
@@ -912,17 +912,27 @@ impl State {
912 // Unlike wlr-screencopy, a session is an explicit protocol object, so912 // Unlike wlr-screencopy, a session is an explicit protocol object, so
913 // the cast lifetime is tied to it. Dead sessions are already dropped by913 // the cast lifetime is tied to it. Dead sessions are already dropped by
914 // refresh_image_copy_capture(), which runs before this.914 // refresh_image_copy_capture(), which runs before this.
915- let output_sessions = self915+ let output_sessions = self.niri.image_copy_sessions.iter().map(|s| {
916- .niri916+ (
917- .image_copy_sessions917+ niri_ipc::CastKind::ExtImageCopyCapture,
918- .iter()918+ s.session_id,
919- .map(|s| (s.session_id, s.stream_id, s.session.source(), s.credentials));919+ s.stream_id,
920- let cursor_sessions = self920+ s.session.source(),
921- .niri921+ s.credentials,
922- .image_copy_cursor_sessions922+ )
923- .iter()923+ });
924- .map(|s| (s.session_id, s.stream_id, s.session.source(), s.credentials));924+ let cursor_sessions = self.niri.image_copy_cursor_sessions.iter().map(|s| {
925- for (session_id, stream_id, source, credentials) in output_sessions.chain(cursor_sessions) {925+ (
926+ niri_ipc::CastKind::ExtImageCopyCaptureCursor,
927+ s.session_id,
928+ s.stream_id,
929+ s.session.source(),
930+ s.credentials,
931+ )
932+ });
933+ for (kind, session_id, stream_id, source, credentials) in
934+ output_sessions.chain(cursor_sessions)
935+ {
926 let target = if let Some(output) = source_output(&source) {936 let target = if let Some(output) = source_output(&source) {
927 niri_ipc::CastTarget::Output {937 niri_ipc::CastTarget::Output {
928 name: output.name(),938 name: output.name(),
@@ -940,7 +950,7 @@ impl State {
940 let cast = niri_ipc::Cast {950 let cast = niri_ipc::Cast {
941 session_id: session_id.get(),951 session_id: session_id.get(),
942 stream_id,952 stream_id,
943- kind: niri_ipc::CastKind::ExtImageCopyCapture,953+ kind,
944 target,954 target,
945 is_dynamic_target: false,955 is_dynamic_target: false,
946 is_active: true,956 is_active: true,