screencapture: implement ext_output_image_capture_source_manager_v1
This commit is contained in:
parent
b754e37bfe
commit
40bce507a6
9 changed files with 228 additions and 49 deletions
|
|
@ -2,6 +2,7 @@ use {
|
|||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::{
|
||||
ext_image_capture_source_v1::ExtImageCaptureSourceV1,
|
||||
ipc::{
|
||||
wl_data_source::WlDataSource, zwlr_data_control_source_v1::ZwlrDataControlSourceV1,
|
||||
zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1,
|
||||
|
|
@ -31,11 +32,11 @@ use {
|
|||
copyhashmap::{CopyHashMap, Locked},
|
||||
},
|
||||
wire::{
|
||||
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
|
||||
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
|
||||
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPopupId,
|
||||
XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
|
||||
ZwpPrimarySelectionSourceV1Id, ZwpTabletToolV2Id,
|
||||
ExtImageCaptureSourceV1Id, JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId,
|
||||
WlBufferId, WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId,
|
||||
WlSeatId, WlSurfaceId, WpDrmLeaseConnectorV1Id, WpLinuxDrmSyncobjTimelineV1Id,
|
||||
XdgPopupId, XdgPositionerId, XdgSurfaceId, XdgToplevelId, XdgWmBaseId,
|
||||
ZwlrDataControlSourceV1Id, ZwpPrimarySelectionSourceV1Id, ZwpTabletToolV2Id,
|
||||
},
|
||||
},
|
||||
std::{cell::RefCell, mem, rc::Rc},
|
||||
|
|
@ -67,6 +68,7 @@ pub struct Objects {
|
|||
pub drm_lease_outputs: CopyHashMap<WpDrmLeaseConnectorV1Id, Rc<WpDrmLeaseConnectorV1>>,
|
||||
pub tablet_tools: CopyHashMap<ZwpTabletToolV2Id, Rc<ZwpTabletToolV2>>,
|
||||
pub xdg_popups: CopyHashMap<XdgPopupId, Rc<XdgPopup>>,
|
||||
pub image_capture_sources: CopyHashMap<ExtImageCaptureSourceV1Id, Rc<ExtImageCaptureSourceV1>>,
|
||||
ids: RefCell<Vec<usize>>,
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +102,7 @@ impl Objects {
|
|||
drm_lease_outputs: Default::default(),
|
||||
tablet_tools: Default::default(),
|
||||
xdg_popups: Default::default(),
|
||||
image_capture_sources: Default::default(),
|
||||
ids: RefCell::new(vec![]),
|
||||
}
|
||||
}
|
||||
|
|
@ -137,6 +140,7 @@ impl Objects {
|
|||
self.drm_lease_outputs.clear();
|
||||
self.tablet_tools.clear();
|
||||
self.xdg_popups.clear();
|
||||
self.image_capture_sources.clear();
|
||||
}
|
||||
|
||||
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use {
|
|||
ifs::{
|
||||
ext_foreign_toplevel_list_v1::ExtForeignToplevelListV1Global,
|
||||
ext_idle_notifier_v1::ExtIdleNotifierV1Global,
|
||||
ext_output_image_capture_source_manager_v1::ExtOutputImageCaptureSourceManagerV1Global,
|
||||
ext_session_lock_manager_v1::ExtSessionLockManagerV1Global,
|
||||
ipc::{
|
||||
wl_data_device_manager::WlDataDeviceManagerGlobal,
|
||||
|
|
@ -197,6 +198,7 @@ impl Globals {
|
|||
add_singleton!(ZwpPointerGesturesV1Global);
|
||||
add_singleton!(ZwpTabletManagerV2Global);
|
||||
add_singleton!(JayDamageTrackingGlobal);
|
||||
add_singleton!(ExtOutputImageCaptureSourceManagerV1Global);
|
||||
}
|
||||
|
||||
pub fn add_backend_singletons(&self, backend: &Rc<dyn Backend>) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ pub mod ext_foreign_toplevel_handle_v1;
|
|||
pub mod ext_foreign_toplevel_list_v1;
|
||||
pub mod ext_idle_notification_v1;
|
||||
pub mod ext_idle_notifier_v1;
|
||||
pub mod ext_image_capture_source_v1;
|
||||
pub mod ext_output_image_capture_source_manager_v1;
|
||||
pub mod ext_session_lock_manager_v1;
|
||||
pub mod ext_session_lock_v1;
|
||||
pub mod ipc;
|
||||
|
|
|
|||
54
src/ifs/ext_image_capture_source_v1.rs
Normal file
54
src/ifs/ext_image_capture_source_v1.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::wl_output::OutputGlobalOpt,
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{ext_image_capture_source_v1::*, ExtImageCaptureSourceV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[expect(dead_code)]
|
||||
#[derive(Clone)]
|
||||
pub enum ImageCaptureSource {
|
||||
Output(Rc<OutputGlobalOpt>),
|
||||
}
|
||||
|
||||
pub struct ExtImageCaptureSourceV1 {
|
||||
pub id: ExtImageCaptureSourceV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
#[expect(dead_code)]
|
||||
pub ty: ImageCaptureSource,
|
||||
}
|
||||
|
||||
impl ExtImageCaptureSourceV1RequestHandler for ExtImageCaptureSourceV1 {
|
||||
type Error = ExtImageCaptureSourceError;
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base! {
|
||||
self = ExtImageCaptureSourceV1;
|
||||
version = Version(1);
|
||||
}
|
||||
|
||||
impl Object for ExtImageCaptureSourceV1 {}
|
||||
|
||||
dedicated_add_obj!(
|
||||
ExtImageCaptureSourceV1,
|
||||
ExtImageCaptureSourceV1Id,
|
||||
image_capture_sources
|
||||
);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ExtImageCaptureSourceError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ExtImageCaptureSourceError, ClientError);
|
||||
104
src/ifs/ext_output_image_capture_source_manager_v1.rs
Normal file
104
src/ifs/ext_output_image_capture_source_manager_v1.rs
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::ext_image_capture_source_v1::{ExtImageCaptureSourceV1, ImageCaptureSource},
|
||||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
wire::{
|
||||
ext_output_image_capture_source_manager_v1::*, ExtOutputImageCaptureSourceManagerV1Id,
|
||||
},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct ExtOutputImageCaptureSourceManagerV1Global {
|
||||
pub name: GlobalName,
|
||||
}
|
||||
|
||||
impl ExtOutputImageCaptureSourceManagerV1Global {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: ExtOutputImageCaptureSourceManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: Version,
|
||||
) -> Result<(), ExtOutputImageCaptureSourceManagerV1Error> {
|
||||
let obj = Rc::new(ExtOutputImageCaptureSourceManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
tracker: Default::default(),
|
||||
version,
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ExtOutputImageCaptureSourceManagerV1 {
|
||||
pub id: ExtOutputImageCaptureSourceManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub tracker: Tracker<Self>,
|
||||
pub version: Version,
|
||||
}
|
||||
|
||||
impl ExtOutputImageCaptureSourceManagerV1RequestHandler for ExtOutputImageCaptureSourceManagerV1 {
|
||||
type Error = ExtOutputImageCaptureSourceManagerV1Error;
|
||||
|
||||
fn create_source(&self, req: CreateSource, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
let output = self.client.lookup(req.output)?;
|
||||
let obj = Rc::new(ExtImageCaptureSourceV1 {
|
||||
id: req.source,
|
||||
client: self.client.clone(),
|
||||
tracker: Default::default(),
|
||||
ty: ImageCaptureSource::Output(output.global.clone()),
|
||||
});
|
||||
track!(self.client, obj);
|
||||
self.client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(
|
||||
ExtOutputImageCaptureSourceManagerV1Global,
|
||||
ExtOutputImageCaptureSourceManagerV1,
|
||||
ExtOutputImageCaptureSourceManagerV1Error
|
||||
);
|
||||
|
||||
impl Global for ExtOutputImageCaptureSourceManagerV1Global {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(ExtOutputImageCaptureSourceManagerV1Global);
|
||||
|
||||
object_base! {
|
||||
self = ExtOutputImageCaptureSourceManagerV1;
|
||||
version = self.version;
|
||||
}
|
||||
|
||||
impl Object for ExtOutputImageCaptureSourceManagerV1 {}
|
||||
|
||||
simple_add_obj!(ExtOutputImageCaptureSourceManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ExtOutputImageCaptureSourceManagerV1Error {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(ExtOutputImageCaptureSourceManagerV1Error, ClientError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue