feat(wayland): data device

This commit is contained in:
Nova
2025-07-31 03:05:50 -07:00
parent f4c75c5705
commit d234d6f765
3 changed files with 167 additions and 4 deletions

View 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(())
}
}

View File

@@ -1,6 +1,7 @@
pub mod buffer;
pub mod callback;
pub mod compositor;
pub mod data_device;
pub mod keyboard;
pub mod output;
pub mod pointer;

View File

@@ -1,6 +1,7 @@
use crate::wayland::{
core::{
compositor::{Compositor, WlCompositor},
data_device::DataDeviceManager,
output::{Output, WlOutput},
seat::{Seat, WlSeat},
shm::{Shm, WlShm},
@@ -14,7 +15,8 @@ use waynest::{
server::{
Client, Dispatcher, Error, Result,
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,
},
},
@@ -27,9 +29,10 @@ impl RegistryGlobals {
pub const SHM: u32 = 1;
pub const WM_BASE: u32 = 2;
pub const SEAT: u32 = 3;
pub const OUTPUT: u32 = 4;
pub const DMABUF: u32 = 5;
pub const WL_DRM: u32 = 6;
pub const DATA_DEVICE_MANAGER: u32 = 4;
pub const OUTPUT: u32 = 5;
pub const DMABUF: u32 = 6;
pub const WL_DRM: u32 = 7;
}
#[derive(Debug, Dispatcher, Default)]
@@ -73,6 +76,15 @@ impl Registry {
)
.await?;
self.global(
client,
sender_id,
RegistryGlobals::DATA_DEVICE_MANAGER,
DataDeviceManager::INTERFACE.to_string(),
DataDeviceManager::VERSION,
)
.await?;
self.global(
client,
sender_id,
@@ -140,6 +152,10 @@ impl WlRegistry for Registry {
.await?;
tracing::info!("Seat capabilities advertised");
}
RegistryGlobals::DATA_DEVICE_MANAGER => {
tracing::info!("Binding data device manager");
client.insert(new_id.object_id, DataDeviceManager);
}
RegistryGlobals::OUTPUT => {
tracing::info!("Binding output");
let output = client.insert(new_id.object_id, Output(new_id.object_id));