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