chroe: add note

This commit is contained in:
Ashley Wulber 2024-03-25 16:21:41 -04:00
parent e91be7dfc2
commit 6bc77815ef
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820

View file

@ -38,8 +38,11 @@ use url::Url;
const MIN_DIM_SIZE: usize = 256; const MIN_DIM_SIZE: usize = 256;
#[allow(dead_code)]
// Example usage if RawSurface weren't already implemented
struct MySurface(WlSurface); struct MySurface(WlSurface);
// Example usage if RawSurface weren't already implemented
impl smithay_clipboard::dnd::RawSurface for MySurface { impl smithay_clipboard::dnd::RawSurface for MySurface {
unsafe fn get_ptr(&mut self) -> *mut c_void { unsafe fn get_ptr(&mut self) -> *mut c_void {
self.0.id().as_ptr().cast() self.0.id().as_ptr().cast()
@ -78,18 +81,20 @@ fn main() {
return; return;
}; };
match event { match event {
smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Data { data, mime_type }) => { smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Data {
data, mime_type
}) => {
let s = smithay_clipboard::text::Text::try_from((data, mime_type)).unwrap(); let s = smithay_clipboard::text::Text::try_from((data, mime_type)).unwrap();
println!("Received DnD data for {}: {}", id.unwrap_or_default(), s.0); println!("Received DnD data for {}: {}", id.unwrap_or_default(), s.0);
}, },
smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Leave) => { smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Leave) =>
{
if state.internal_dnd { if state.internal_dnd {
if state.pointer_focus { if state.pointer_focus {
println!("Internal drop completed!"); println!("Internal drop completed!");
} else { } else {
// Internal DnD will be ignored after leaving the window in which it // Internal DnD will be ignored after leaving the window in which it started.
// started. Another approach might be to allow it to // Another approach might be to allow it to re-enter before some time has passed.
// re-enter before some time has passed.
state.internal_dnd = false; state.internal_dnd = false;
state.clipboard.end_dnd(); state.clipboard.end_dnd();
} }
@ -103,7 +108,7 @@ fn main() {
}, },
e => { e => {
dbg!(e); dbg!(e);
}, }
} }
}); });
@ -148,6 +153,7 @@ fn main() {
actions: DndAction::Move, actions: DndAction::Move,
preferred: DndAction::Move, preferred: DndAction::Move,
}, },
]); ]);
let mut simple_window = SimpleWindow { let mut simple_window = SimpleWindow {
@ -383,10 +389,10 @@ impl PointerHandler for SimpleWindow {
}, },
PointerEventKind::Leave {..} => { PointerEventKind::Leave {..} => {
self.pointer_focus = false; self.pointer_focus = false;
}, }
PointerEventKind::Enter {..} => { PointerEventKind::Enter {..} => {
self.pointer_focus = true; self.pointer_focus = true;
}, }
_ => {}, _ => {},
} }
} }