forge
Explore
Log in

Don't you dare go Hollow

Show client in cast ipc for ext-image-copy-capture

Browse files at this commit

66d04a7d72e25a6c74307bab33a91924d124755dPatrick GaskinParent: 298acfe
  • feat
    • show client in cast ipc for ext-image-copy-capture
Show full message
feat: show client in cast ipc for ext-image-copy-capture
Cargo.lockmodified+2 -2
@@ -3455,7 +3455,7 @@ checksum = "e8e2fb0f499abb4d162f2bedad68f5ef91a1682b5a03596ddb67efd37768d100"
3455 [[package]]3455 [[package]]
3456 name = "smithay"3456 name = "smithay"
3457 version = "0.7.0"3457 version = "0.7.0"
3458-source = "git+https://github.com/Smithay/smithay.git?rev=0ff00983b6007257a7a161a4fe8b14a778e2ac8f#0ff00983b6007257a7a161a4fe8b14a778e2ac8f"3458+source = "git+https://github.com/Smithay/smithay.git?rev=22571baa20d34d71092942dbb520c4e3fbbd6263#22571baa20d34d71092942dbb520c4e3fbbd6263"
3459 dependencies = [3459 dependencies = [
3460 "aliasable",3460 "aliasable",
3461 "appendlist",3461 "appendlist",
@@ -3532,7 +3532,7 @@ dependencies = [
3532 [[package]]3532 [[package]]
3533 name = "smithay-drm-extras"3533 name = "smithay-drm-extras"
3534 version = "0.1.0"3534 version = "0.1.0"
3535-source = "git+https://github.com/Smithay/smithay.git?rev=0ff00983b6007257a7a161a4fe8b14a778e2ac8f#0ff00983b6007257a7a161a4fe8b14a778e2ac8f"3535+source = "git+https://github.com/Smithay/smithay.git?rev=22571baa20d34d71092942dbb520c4e3fbbd6263#22571baa20d34d71092942dbb520c4e3fbbd6263"
3536 dependencies = [3536 dependencies = [
3537 "drm",3537 "drm",
3538 "libdisplay-info",3538 "libdisplay-info",
Cargo.tomlmodified+2 -2
@@ -28,13 +28,13 @@ tracy-client = { version = "0.18.5", default-features = false }
28 [workspace.dependencies.smithay]28 [workspace.dependencies.smithay]
29 # version = "0.4.1"29 # version = "0.4.1"
30 git = "https://github.com/Smithay/smithay.git"30 git = "https://github.com/Smithay/smithay.git"
31-rev = "0ff00983b6007257a7a161a4fe8b14a778e2ac8f"31+rev = "22571baa20d34d71092942dbb520c4e3fbbd6263"
32 default-features = false32 default-features = false
33 33
34 [workspace.dependencies.smithay-drm-extras]34 [workspace.dependencies.smithay-drm-extras]
35 # version = "0.1.0"35 # version = "0.1.0"
36 git = "https://github.com/Smithay/smithay.git"36 git = "https://github.com/Smithay/smithay.git"
37-rev = "0ff00983b6007257a7a161a4fe8b14a778e2ac8f"37+rev = "22571baa20d34d71092942dbb520c4e3fbbd6263"
38 # path = "../smithay/smithay-drm-extras"38 # path = "../smithay/smithay-drm-extras"
39 39
40 [package]40 [package]
src/handlers/image_copy_capture.rsmodified+20 -1
@@ -12,6 +12,7 @@ use smithay::reexports::calloop::{Interest, LoopHandle, Mode, PostAction};
12 use smithay::reexports::wayland_server::protocol::wl_buffer::WlBuffer;12 use smithay::reexports::wayland_server::protocol::wl_buffer::WlBuffer;
13 use smithay::reexports::wayland_server::protocol::wl_pointer::WlPointer;13 use smithay::reexports::wayland_server::protocol::wl_pointer::WlPointer;
14 use smithay::reexports::wayland_server::protocol::wl_shm;14 use smithay::reexports::wayland_server::protocol::wl_shm;
15+use smithay::reexports::wayland_server::{Client, DisplayHandle};
15 use smithay::utils::{16 use smithay::utils::{
16 Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale, Size, Transform,17 Buffer as BufferCoords, Logical, Physical, Point, Rectangle, Scale, Size, Transform,
17 };18 };
@@ -25,10 +26,11 @@ use smithay::wayland::image_copy_capture::{
25 Frame, FrameRef, ImageCopyCaptureHandler, ImageCopyCaptureState, Session, SessionRef,26 Frame, FrameRef, ImageCopyCaptureHandler, ImageCopyCaptureState, Session, SessionRef,
26 };27 };
27 use smithay::wayland::shm;28 use smithay::wayland::shm;
29+use wayland_backend::server::Credentials;
28 30
29 use crate::cursor::{RenderCursor, XCursor};31 use crate::cursor::{RenderCursor, XCursor};
30 use crate::niri::{Niri, State};32 use crate::niri::{Niri, State};
31-use crate::utils::{CastSessionId, CastStreamId};33+use crate::utils::{get_credentials_for_client, CastSessionId, CastStreamId};
32 34
33 /// Output capture session.35 /// Output capture session.
34 pub struct ImageCopySession {36 pub struct ImageCopySession {
@@ -40,6 +42,8 @@ pub struct ImageCopySession {
40 pub session_id: CastSessionId,42 pub session_id: CastSessionId,
41 /// Cast stream id, unique to this session.43 /// Cast stream id, unique to this session.
42 pub stream_id: CastStreamId,44 pub stream_id: CastStreamId,
45+ /// Credentials of the capturing client, if known.
46+ pub credentials: Option<Credentials>,
43 }47 }
44 48
45 /// Cursor capture session of an output.49 /// Cursor capture session of an output.
@@ -53,6 +57,17 @@ pub struct ImageCopyCursorSession {
53 pub session_id: CastSessionId,57 pub session_id: CastSessionId,
54 /// Cast stream id, unique to this session.58 /// Cast stream id, unique to this session.
55 pub stream_id: CastStreamId,59 pub stream_id: CastStreamId,
60+ /// Credentials of the capturing client, if known.
61+ pub credentials: Option<Credentials>,
62+}
63+
64+/// Credentials for the client which created a capture session.
65+///
66+/// Returns `None` if the session doesn't have its client (it has already been
67+/// dropped) or if the credentials cannot be determined (e.g., if peer is
68+/// credentials_unknown like mutter_service_channel).
69+fn session_credentials(dh: &DisplayHandle, client: Option<Client>) -> Option<Credentials> {
70+ get_credentials_for_client(dh, &client?)
56 }71 }
57 72
58 /// Cast session id of an image capture source.73 /// Cast session id of an image capture source.
@@ -311,12 +326,14 @@ impl ImageCopyCaptureHandler for State {
311 // Will be updated with the output properties before capture.326 // Will be updated with the output properties before capture.
312 let damage_tracker = OutputDamageTracker::new((0, 0), 1.0, Transform::Normal);327 let damage_tracker = OutputDamageTracker::new((0, 0), 1.0, Transform::Normal);
313 let session_id = source_session_id(&session.source());328 let session_id = source_session_id(&session.source());
329+ let credentials = session_credentials(&self.niri.display_handle, session.client());
314 self.niri.image_copy_sessions.push(ImageCopySession {330 self.niri.image_copy_sessions.push(ImageCopySession {
315 session,331 session,
316 damage_tracker,332 damage_tracker,
317 pending_frame: None,333 pending_frame: None,
318 session_id,334 session_id,
319 stream_id: CastStreamId::next(),335 stream_id: CastStreamId::next(),
336+ credentials,
320 });337 });
321 }338 }
322 339
@@ -324,6 +341,7 @@ impl ImageCopyCaptureHandler for State {
324 // Will be updated with the output properties before capture.341 // Will be updated with the output properties before capture.
325 let damage_tracker = OutputDamageTracker::new((0, 0), 1.0, Transform::Normal);342 let damage_tracker = OutputDamageTracker::new((0, 0), 1.0, Transform::Normal);
326 let session_id = source_session_id(&session.source());343 let session_id = source_session_id(&session.source());
344+ let credentials = session_credentials(&self.niri.display_handle, session.client());
327 self.niri345 self.niri
328 .image_copy_cursor_sessions346 .image_copy_cursor_sessions
329 .push(ImageCopyCursorSession {347 .push(ImageCopyCursorSession {
@@ -332,6 +350,7 @@ impl ImageCopyCaptureHandler for State {
332 pending_frame: None,350 pending_frame: None,
333 session_id,351 session_id,
334 stream_id: CastStreamId::next(),352 stream_id: CastStreamId::next(),
353+ credentials,
335 });354 });
336 // Send the initial cursor position and hotspot.355 // Send the initial cursor position and hotspot.
337 self.niri.refresh_image_copy_cursor_sessions();356 self.niri.refresh_image_copy_cursor_sessions();
src/ipc/server.rsmodified+4 -5
@@ -916,13 +916,13 @@ impl State {
916 .niri916 .niri
917 .image_copy_sessions917 .image_copy_sessions
918 .iter()918 .iter()
919- .map(|s| (s.session_id, s.stream_id, s.session.source()));919+ .map(|s| (s.session_id, s.stream_id, s.session.source(), s.credentials));
920 let cursor_sessions = self920 let cursor_sessions = self
921 .niri921 .niri
922 .image_copy_cursor_sessions922 .image_copy_cursor_sessions
923 .iter()923 .iter()
924- .map(|s| (s.session_id, s.stream_id, s.session.source()));924+ .map(|s| (s.session_id, s.stream_id, s.session.source(), s.credentials));
925- for (session_id, stream_id, source) in output_sessions.chain(cursor_sessions) {925+ for (session_id, stream_id, source, credentials) in output_sessions.chain(cursor_sessions) {
926 let Some(output) = image_copy_capture::source_output(&source) else {926 let Some(output) = image_copy_capture::source_output(&source) else {
927 continue;927 continue;
928 };928 };
@@ -940,8 +940,7 @@ impl State {
940 },940 },
941 is_dynamic_target: false,941 is_dynamic_target: false,
942 is_active: true,942 is_active: true,
943- // FIXME: smithay doesn't expose the client of a image-copy-capture session.943+ pid: credentials.map(|creds| creds.pid),
944- pid: None,
945 pw_node_id: None,944 pw_node_id: None,
946 };945 };
947 events.push(Event::CastStartedOrChanged { cast });946 events.push(Event::CastStartedOrChanged { cast });