wayland_bridge/
data_device_manager.rs1use crate::client::Client;
6use crate::object::{NewObjectExt, ObjectRef, RequestReceiver};
7use crate::seat::Seat;
8use anyhow::Error;
9use wayland_server_protocol::{
10 WlDataDevice, WlDataDeviceManager, WlDataDeviceManagerRequest, WlDataDeviceRequest,
11 WlDataSource, WlDataSourceRequest,
12};
13
14pub struct DataDeviceManager;
16
17impl DataDeviceManager {
18 pub fn new() -> Self {
20 DataDeviceManager
21 }
22}
23
24impl RequestReceiver<WlDataDeviceManager> for DataDeviceManager {
25 fn receive(
26 _this: ObjectRef<Self>,
27 request: WlDataDeviceManagerRequest,
28 client: &mut Client,
29 ) -> Result<(), Error> {
30 match request {
31 WlDataDeviceManagerRequest::CreateDataSource { id } => {
32 id.implement(client, DataSource)?;
33 }
34 WlDataDeviceManagerRequest::GetDataDevice { id, seat } => {
35 id.implement(client, DataDevice { _object: seat.into() })?;
36 }
37 }
38 Ok(())
39 }
40}
41
42struct DataSource;
43
44impl RequestReceiver<WlDataSource> for DataSource {
45 fn receive(
46 this: ObjectRef<Self>,
47 request: WlDataSourceRequest,
48 client: &mut Client,
49 ) -> Result<(), Error> {
50 match request {
51 WlDataSourceRequest::Destroy => {
52 client.delete_id(this.id())?;
53 }
54 WlDataSourceRequest::Offer { .. } => {}
55 WlDataSourceRequest::SetActions { .. } => {}
56 }
57 Ok(())
58 }
59}
60
61struct DataDevice {
62 _object: ObjectRef<Seat>,
63}
64
65impl RequestReceiver<WlDataDevice> for DataDevice {
66 fn receive(
67 this: ObjectRef<Self>,
68 request: WlDataDeviceRequest,
69 client: &mut Client,
70 ) -> Result<(), Error> {
71 match request {
72 WlDataDeviceRequest::Release => {
73 client.delete_id(this.id())?;
74 }
75 WlDataDeviceRequest::StartDrag { .. } => {}
76 WlDataDeviceRequest::SetSelection { .. } => {}
77 }
78 Ok(())
79 }
80}