refactor: use icon type when starting dnd
This commit is contained in:
parent
5bfbaae180
commit
42a888736b
5 changed files with 43 additions and 9 deletions
|
|
@ -119,6 +119,18 @@ pub struct DndDestinationRectangle {
|
|||
pub preferred: DndAction,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum Icon {
|
||||
Surface(DndSurface),
|
||||
/// Xrgb8888 or Argb8888 image data with premultiplied alpha
|
||||
Buffer {
|
||||
data: Arc<Vec<u8>>,
|
||||
width: u32,
|
||||
height: u32,
|
||||
transparent: bool,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DndSurface(pub Arc<Box<dyn RawSurface + 'static + Send + Sync>>);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use std::{borrow::Cow, ffi::c_void, sync::Arc};
|
||||
|
||||
use crate::{DataWrapper, DndAction, DndSurface};
|
||||
use crate::{DataWrapper, DndAction, DndSurface, Icon};
|
||||
use smithay_clipboard::mime::{AllowedMimeTypes, AsMimeTypes, MimeType};
|
||||
|
||||
impl<
|
||||
|
|
@ -87,3 +87,25 @@ impl From<DndAction>
|
|||
a
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Icon> for smithay_clipboard::dnd::Icon<DndSurface> {
|
||||
fn from(icon: Icon) -> Self {
|
||||
match icon {
|
||||
Icon::Surface(surface) => {
|
||||
smithay_clipboard::dnd::Icon::Surface(surface)
|
||||
}
|
||||
Icon::Buffer {
|
||||
data,
|
||||
width,
|
||||
height,
|
||||
transparent,
|
||||
} => smithay_clipboard::dnd::Icon::Buf {
|
||||
data: Arc::try_unwrap(data)
|
||||
.unwrap_or_else(|d| d.as_ref().clone()),
|
||||
width,
|
||||
height,
|
||||
transparent,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue