wayland_bridge/
data_device_manager.rsuse crate::client::Client;
use crate::object::{NewObjectExt, ObjectRef, RequestReceiver};
use crate::seat::Seat;
use anyhow::Error;
use wayland_server_protocol::{
WlDataDevice, WlDataDeviceManager, WlDataDeviceManagerRequest, WlDataDeviceRequest,
WlDataSource, WlDataSourceRequest,
};
pub struct DataDeviceManager;
impl DataDeviceManager {
pub fn new() -> Self {
DataDeviceManager
}
}
impl RequestReceiver<WlDataDeviceManager> for DataDeviceManager {
fn receive(
_this: ObjectRef<Self>,
request: WlDataDeviceManagerRequest,
client: &mut Client,
) -> Result<(), Error> {
match request {
WlDataDeviceManagerRequest::CreateDataSource { id } => {
id.implement(client, DataSource)?;
}
WlDataDeviceManagerRequest::GetDataDevice { id, seat } => {
id.implement(client, DataDevice { _object: seat.into() })?;
}
}
Ok(())
}
}
struct DataSource;
impl RequestReceiver<WlDataSource> for DataSource {
fn receive(
this: ObjectRef<Self>,
request: WlDataSourceRequest,
client: &mut Client,
) -> Result<(), Error> {
match request {
WlDataSourceRequest::Destroy => {
client.delete_id(this.id())?;
}
WlDataSourceRequest::Offer { .. } => {}
WlDataSourceRequest::SetActions { .. } => {}
}
Ok(())
}
}
struct DataDevice {
_object: ObjectRef<Seat>,
}
impl RequestReceiver<WlDataDevice> for DataDevice {
fn receive(
this: ObjectRef<Self>,
request: WlDataDeviceRequest,
client: &mut Client,
) -> Result<(), Error> {
match request {
WlDataDeviceRequest::Release => {
client.delete_id(this.id())?;
}
WlDataDeviceRequest::StartDrag { .. } => {}
WlDataDeviceRequest::SetSelection { .. } => {}
}
Ok(())
}
}