Skip to content

Commit

Permalink
chroe: add note
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Mar 25, 2024
1 parent e91be7d commit 6bc7781
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions examples/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ use url::Url;

const MIN_DIM_SIZE: usize = 256;

#[allow(dead_code)]
// Example usage if RawSurface weren't already implemented
struct MySurface(WlSurface);

// Example usage if RawSurface weren't already implemented
impl smithay_clipboard::dnd::RawSurface for MySurface {
unsafe fn get_ptr(&mut self) -> *mut c_void {
self.0.id().as_ptr().cast()
Expand Down Expand Up @@ -78,32 +81,34 @@ fn main() {
return;

Check failure on line 81 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
};
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();
println!("Received DnD data for {}: {}", id.unwrap_or_default(), s.0);
},
smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Leave) => {
if state.internal_dnd {
smithay_clipboard::dnd::DndEvent::Offer(id, OfferEvent::Leave) =>

Check failure on line 90 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
{
if state.internal_dnd {
if state.pointer_focus {
println!("Internal drop completed!");
} else {
// Internal DnD will be ignored after leaving the window in which it
// started. Another approach might be to allow it to
// re-enter before some time has passed.
// Internal DnD will be ignored after leaving the window in which it started.

Check failure on line 96 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
// Another approach might be to allow it to re-enter before some time has passed.
state.internal_dnd = false;
state.clipboard.end_dnd();
}
} else {

Check failure on line 101 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
println!("Dnd offer left {id:?}.");
}
},
},
smithay_clipboard::dnd::DndEvent::Source(SourceEvent::Finished) => {
println!("Finished sending data.");
state.internal_dnd = false;
},

Check failure on line 108 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
e => {
dbg!(e);
},
}
}
});

Expand Down Expand Up @@ -148,6 +153,7 @@ fn main() {
actions: DndAction::Move,

Check failure on line 153 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
preferred: DndAction::Move,
},

]);

let mut simple_window = SimpleWindow {
Expand Down Expand Up @@ -381,12 +387,12 @@ impl PointerHandler for SimpleWindow {
DndAction::all(),

Check failure on line 387 in examples/clipboard.rs

View workflow job for this annotation

GitHub Actions / Check Formatting

Diff in /home/runner/work/smithay-clipboard/smithay-clipboard/examples/clipboard.rs
);
},
PointerEventKind::Leave { .. } => {
PointerEventKind::Leave {..} => {
self.pointer_focus = false;
},
PointerEventKind::Enter { .. } => {
}
PointerEventKind::Enter {..} => {
self.pointer_focus = true;
},
}
_ => {},
}
}
Expand Down

0 comments on commit 6bc7781

Please sign in to comment.