From 5df018046c42c413282a90eb308e17c34c73eaf0 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Fri, 11 Oct 2024 13:23:54 +0200 Subject: [PATCH] portal: include mapping_id in screencasts --- src/ei/ei_ifs/ei_device.rs | 11 +++++++++-- src/ei/ei_ifs/ei_seat.rs | 1 + src/portal/ptl_remote_desktop.rs | 2 +- src/portal/ptl_screencast.rs | 15 +++++++++++++-- src/portal/ptl_session.rs | 7 +++++++ 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/ei/ei_ifs/ei_device.rs b/src/ei/ei_ifs/ei_device.rs index 7f87fbae..e3e6cc6a 100644 --- a/src/ei/ei_ifs/ei_device.rs +++ b/src/ei/ei_ifs/ei_device.rs @@ -15,8 +15,8 @@ use { wire_ei::{ ei_device::{ ClientFrame, ClientStartEmulating, ClientStopEmulating, Destroyed, DeviceType, - Done, EiDeviceRequestHandler, Interface, Paused, Region, Release, Resumed, - ServerFrame, ServerStartEmulating, + Done, EiDeviceRequestHandler, Interface, Paused, Region, RegionMappingId, Release, + Resumed, ServerFrame, ServerStartEmulating, }, EiDeviceId, }, @@ -100,6 +100,13 @@ impl EiDevice { }); } + pub fn send_region_mapping_id(&self, mapping_id: &str) { + self.client.event(RegionMappingId { + self_id: self.id, + mapping_id, + }); + } + #[expect(dead_code)] pub fn send_paused(&self, serial: u32) { self.client.event(Paused { diff --git a/src/ei/ei_ifs/ei_seat.rs b/src/ei/ei_ifs/ei_seat.rs index 40430299..d8469b40 100644 --- a/src/ei/ei_ifs/ei_seat.rs +++ b/src/ei/ei_ifs/ei_seat.rs @@ -346,6 +346,7 @@ impl EiSeat { apply!(EI_CAP_KEYBOARD, create_keyboard); apply!(EI_CAP_TOUCHSCREEN, create_touchscreen); for output in self.client.state.root.outputs.lock().values() { + device.send_region_mapping_id(&output.global.connector.name); device.send_region( output.node_absolute_position(), output.global.persistent.scale.get(), diff --git a/src/portal/ptl_remote_desktop.rs b/src/portal/ptl_remote_desktop.rs index 166b0592..2c0f8634 100644 --- a/src/portal/ptl_remote_desktop.rs +++ b/src/portal/ptl_remote_desktop.rs @@ -90,7 +90,7 @@ impl UsrJayEiSessionOwner for StartingRemoteDesktop { Some(self.dpy.clone()), ); } else { - self.session.send_start_reply(None, None); + self.session.send_start_reply(None, None, None); } } diff --git a/src/portal/ptl_screencast.rs b/src/portal/ptl_screencast.rs index f13b9087..567813ab 100644 --- a/src/portal/ptl_screencast.rs +++ b/src/portal/ptl_screencast.rs @@ -159,8 +159,19 @@ bitflags! { impl PwClientNodeOwner for StartingScreencast { fn bound_id(&self, node_id: u32) { - self.session - .send_start_reply(Some(node_id), create_restore_data(&self.dpy, &self.target)); + { + let output = match &self.target { + ScreencastTarget::Output(o) => Some(o), + ScreencastTarget::Workspace(o, _, _) => Some(o), + ScreencastTarget::Toplevel(_) => None, + }; + let mapping_id = output.and_then(|o| o.wl.name.borrow().clone()); + self.session.send_start_reply( + Some(node_id), + create_restore_data(&self.dpy, &self.target), + mapping_id.as_deref(), + ); + } let mut supported_formats = PwClientNodePortSupportedFormats { media_type: Some(SPA_MEDIA_TYPE_video), media_sub_type: Some(SPA_MEDIA_SUBTYPE_raw), diff --git a/src/portal/ptl_session.rs b/src/portal/ptl_session.rs index e0d897fb..5a94df5a 100644 --- a/src/portal/ptl_session.rs +++ b/src/portal/ptl_session.rs @@ -100,6 +100,7 @@ impl PortalSession { &self, pw_node_id: Option, restore_data: Option>, + mapping_id: Option<&str>, ) { let inner_type = DynamicType::DictEntry( Box::new(DynamicType::String), @@ -133,6 +134,12 @@ impl PortalSession { value: rd, }); } + if let Some(mapping_id) = mapping_id { + variants.push(DictEntry { + key: "mapping_id".into(), + value: Variant::String(mapping_id.into()), + }); + } if let Some(reply) = self.start_reply.take() { match reply { PortalSessionReply::RemoteDesktop(reply) => {