feat(wayland): data device
This commit is contained in:
146
src/wayland/core/data_device.rs
Normal file
146
src/wayland/core/data_device.rs
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
use std::os::fd::OwnedFd;
|
||||||
|
use waynest::{
|
||||||
|
server::{
|
||||||
|
Client, Dispatcher, Result,
|
||||||
|
protocol::core::wayland::{
|
||||||
|
wl_data_device::*, wl_data_device_manager::*, wl_data_offer::WlDataOffer,
|
||||||
|
wl_data_source::*,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
wire::ObjectId,
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: actually implement this
|
||||||
|
|
||||||
|
#[derive(Debug, Dispatcher)]
|
||||||
|
pub struct DataDeviceManager;
|
||||||
|
impl WlDataDeviceManager for DataDeviceManager {
|
||||||
|
async fn create_data_source(
|
||||||
|
&self,
|
||||||
|
client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
id: ObjectId,
|
||||||
|
) -> Result<()> {
|
||||||
|
client.insert(id, DataSource);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_data_device(
|
||||||
|
&self,
|
||||||
|
client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
id: ObjectId,
|
||||||
|
_seat: ObjectId,
|
||||||
|
) -> Result<()> {
|
||||||
|
client.insert(id, DataDevice);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Dispatcher)]
|
||||||
|
pub struct DataSource;
|
||||||
|
impl WlDataSource for DataSource {
|
||||||
|
async fn send(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_mime_type: String,
|
||||||
|
_fd: OwnedFd,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn offer(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_mime_type: String,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn set_actions(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_dnd_actions: DndAction,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Dispatcher)]
|
||||||
|
pub struct DataDevice;
|
||||||
|
impl WlDataDevice for DataDevice {
|
||||||
|
async fn start_drag(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_source: Option<ObjectId>,
|
||||||
|
_origin: ObjectId,
|
||||||
|
_icon: Option<ObjectId>,
|
||||||
|
_serial: u32,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn set_selection(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_source: Option<ObjectId>,
|
||||||
|
_serial: u32,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn release(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Dispatcher)]
|
||||||
|
pub struct DataOffer;
|
||||||
|
impl WlDataOffer for DataOffer {
|
||||||
|
async fn accept(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_serial: u32,
|
||||||
|
_mime_type: Option<String>,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn receive(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_mime_type: String,
|
||||||
|
_fd: OwnedFd,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn finish(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn set_actions(
|
||||||
|
&self,
|
||||||
|
_client: &mut Client,
|
||||||
|
_sender_id: ObjectId,
|
||||||
|
_dnd_actions: DndAction,
|
||||||
|
_preferred_action: DndAction,
|
||||||
|
) -> Result<()> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
pub mod buffer;
|
pub mod buffer;
|
||||||
pub mod callback;
|
pub mod callback;
|
||||||
pub mod compositor;
|
pub mod compositor;
|
||||||
|
pub mod data_device;
|
||||||
pub mod keyboard;
|
pub mod keyboard;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
pub mod pointer;
|
pub mod pointer;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use crate::wayland::{
|
use crate::wayland::{
|
||||||
core::{
|
core::{
|
||||||
compositor::{Compositor, WlCompositor},
|
compositor::{Compositor, WlCompositor},
|
||||||
|
data_device::DataDeviceManager,
|
||||||
output::{Output, WlOutput},
|
output::{Output, WlOutput},
|
||||||
seat::{Seat, WlSeat},
|
seat::{Seat, WlSeat},
|
||||||
shm::{Shm, WlShm},
|
shm::{Shm, WlShm},
|
||||||
@@ -14,7 +15,8 @@ use waynest::{
|
|||||||
server::{
|
server::{
|
||||||
Client, Dispatcher, Error, Result,
|
Client, Dispatcher, Error, Result,
|
||||||
protocol::{
|
protocol::{
|
||||||
core::wayland::wl_registry::*, external::drm::wl_drm::WlDrm,
|
core::wayland::{wl_data_device_manager::WlDataDeviceManager, wl_registry::*},
|
||||||
|
external::drm::wl_drm::WlDrm,
|
||||||
stable::linux_dmabuf_v1::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1,
|
stable::linux_dmabuf_v1::zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -27,9 +29,10 @@ impl RegistryGlobals {
|
|||||||
pub const SHM: u32 = 1;
|
pub const SHM: u32 = 1;
|
||||||
pub const WM_BASE: u32 = 2;
|
pub const WM_BASE: u32 = 2;
|
||||||
pub const SEAT: u32 = 3;
|
pub const SEAT: u32 = 3;
|
||||||
pub const OUTPUT: u32 = 4;
|
pub const DATA_DEVICE_MANAGER: u32 = 4;
|
||||||
pub const DMABUF: u32 = 5;
|
pub const OUTPUT: u32 = 5;
|
||||||
pub const WL_DRM: u32 = 6;
|
pub const DMABUF: u32 = 6;
|
||||||
|
pub const WL_DRM: u32 = 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Dispatcher, Default)]
|
#[derive(Debug, Dispatcher, Default)]
|
||||||
@@ -73,6 +76,15 @@ impl Registry {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
self.global(
|
||||||
|
client,
|
||||||
|
sender_id,
|
||||||
|
RegistryGlobals::DATA_DEVICE_MANAGER,
|
||||||
|
DataDeviceManager::INTERFACE.to_string(),
|
||||||
|
DataDeviceManager::VERSION,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
self.global(
|
self.global(
|
||||||
client,
|
client,
|
||||||
sender_id,
|
sender_id,
|
||||||
@@ -140,6 +152,10 @@ impl WlRegistry for Registry {
|
|||||||
.await?;
|
.await?;
|
||||||
tracing::info!("Seat capabilities advertised");
|
tracing::info!("Seat capabilities advertised");
|
||||||
}
|
}
|
||||||
|
RegistryGlobals::DATA_DEVICE_MANAGER => {
|
||||||
|
tracing::info!("Binding data device manager");
|
||||||
|
client.insert(new_id.object_id, DataDeviceManager);
|
||||||
|
}
|
||||||
RegistryGlobals::OUTPUT => {
|
RegistryGlobals::OUTPUT => {
|
||||||
tracing::info!("Binding output");
|
tracing::info!("Binding output");
|
||||||
let output = client.insert(new_id.object_id, Output(new_id.object_id));
|
let output = client.insert(new_id.object_id, Output(new_id.object_id));
|
||||||
|
|||||||
Reference in New Issue
Block a user