window_clipboard/dnd/
mod.rsuse std::borrow::Cow;
use ::dnd::{DndAction, DndDestinationRectangle, Sender};
use dnd::{DndSurface, Icon};
use mime::{AllowedMimeTypes, AsMimeTypes};
pub trait DndProvider {
fn init_dnd(
&self,
_tx: Box<dyn dnd::Sender<DndSurface> + Send + Sync + 'static>,
) {
}
fn start_dnd<D: AsMimeTypes + Send + 'static>(
&self,
_internal: bool,
_source_surface: DndSurface,
_icon_surface: Option<Icon>,
_content: D,
_actions: DndAction,
) {
}
fn end_dnd(&self) {}
fn register_dnd_destination(
&self,
_surface: DndSurface,
_rectangles: Vec<DndDestinationRectangle>,
) {
}
fn set_action(&self, _action: DndAction) {}
fn peek_offer<D: AllowedMimeTypes + 'static>(
&self,
_mime_type: Option<Cow<'static, str>>,
) -> std::io::Result<D> {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
"DnD not supported",
))
}
}
impl<C: DndProvider> DndProvider for crate::PlatformClipboard<C> {
fn init_dnd(
&self,
tx: Box<dyn Sender<DndSurface> + Send + Sync + 'static>,
) {
self.raw.init_dnd(tx);
}
fn start_dnd<D: AsMimeTypes + Send + 'static>(
&self,
internal: bool,
source_surface: DndSurface,
icon_surface: Option<Icon>,
content: D,
actions: DndAction,
) {
self.raw.start_dnd(
internal,
source_surface,
icon_surface,
content,
actions,
);
}
fn end_dnd(&self) {
self.raw.end_dnd();
}
fn register_dnd_destination(
&self,
surface: DndSurface,
rectangles: Vec<DndDestinationRectangle>,
) {
self.raw.register_dnd_destination(surface, rectangles);
}
fn set_action(&self, action: DndAction) {
self.raw.set_action(action);
}
fn peek_offer<D: AllowedMimeTypes + 'static>(
&self,
mime_type: Option<Cow<'static, str>>,
) -> std::io::Result<D> {
self.raw.peek_offer::<D>(mime_type)
}
}