fix: stubs for various platforms
This commit is contained in:
parent
a5be704055
commit
7c59b07b91
3 changed files with 130 additions and 6 deletions
|
|
@ -1,12 +1,15 @@
|
||||||
use crate::ClipboardProvider;
|
use crate::ClipboardProvider;
|
||||||
|
|
||||||
|
use crate::dnd::DndProvider;
|
||||||
|
use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon};
|
||||||
|
use mime::{AllowedMimeTypes, AsMimeTypes};
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
use std::error::Error;
|
use std::{borrow::Cow, error::Error};
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
Ok(Clipboard::new())
|
Clipboard::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Clipboard;
|
pub struct Clipboard;
|
||||||
|
|
@ -36,7 +39,46 @@ impl ClipboardProvider for Clipboard {
|
||||||
Err(Box::new(AndroidClipboardError::Unimplemented))
|
Err(Box::new(AndroidClipboardError::Unimplemented))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&mut self, contents: String) -> Result<(), Box<dyn Error>> {
|
fn write(&mut self, _contents: String) -> Result<(), Box<dyn Error>> {
|
||||||
Err(Box::new(AndroidClipboardError::Unimplemented))
|
Err(Box::new(AndroidClipboardError::Unimplemented))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DndProvider for Clipboard {
|
||||||
|
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",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
use crate::ClipboardProvider;
|
use crate::ClipboardProvider;
|
||||||
|
|
||||||
|
use crate::dnd::DndProvider;
|
||||||
pub(crate) use clipboard_macos::Clipboard;
|
pub(crate) use clipboard_macos::Clipboard;
|
||||||
|
use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon};
|
||||||
|
use mime::{AllowedMimeTypes, AsMimeTypes};
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
use std::error::Error;
|
use std::{borrow::Cow, error::Error};
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
|
|
@ -10,6 +13,45 @@ pub fn connect<W: HasDisplayHandle>(
|
||||||
Clipboard::new()
|
Clipboard::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DndProvider for Clipboard {
|
||||||
|
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 ClipboardProvider for Clipboard {
|
impl ClipboardProvider for Clipboard {
|
||||||
fn read(&self) -> Result<String, Box<dyn Error>> {
|
fn read(&self) -> Result<String, Box<dyn Error>> {
|
||||||
self.read()
|
self.read()
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,55 @@
|
||||||
use crate::ClipboardProvider;
|
use crate::ClipboardProvider;
|
||||||
|
|
||||||
|
use crate::dnd::DndProvider;
|
||||||
use clipboard_win::{get_clipboard_string, set_clipboard_string};
|
use clipboard_win::{get_clipboard_string, set_clipboard_string};
|
||||||
|
use dnd::{DndAction, DndDestinationRectangle, DndSurface, Icon};
|
||||||
|
use mime::{AllowedMimeTypes, AsMimeTypes};
|
||||||
use raw_window_handle::HasDisplayHandle;
|
use raw_window_handle::HasDisplayHandle;
|
||||||
|
use std::{borrow::Cow, error::Error};
|
||||||
use std::error::Error;
|
|
||||||
|
|
||||||
pub fn connect<W: HasDisplayHandle>(
|
pub fn connect<W: HasDisplayHandle>(
|
||||||
_window: &W,
|
_window: &W,
|
||||||
) -> Result<Clipboard, Box<dyn Error>> {
|
) -> Result<Clipboard, Box<dyn Error>> {
|
||||||
Ok(Clipboard)
|
Ok(Clipboard)
|
||||||
}
|
}
|
||||||
|
impl DndProvider for Clipboard {
|
||||||
|
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",
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct Clipboard;
|
pub struct Clipboard;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue