get_registry/common/protocols_data/wayland/wl_data_source.rs
1//! offer to transfer data
2//!
3//! The wl_data_source object is the source side of a wl_data_offer.
4//! It is created by the source client in a data transfer and
5//! provides a way to describe the offered data and a way to respond
6//! to requests to transfer the data.
7
8use super::super::all_types::*;
9use ::wl_client::builder::prelude::*;
10
11static INTERFACE: wl_interface = wl_interface {
12 name: c"wl_data_source".as_ptr(),
13 version: 3,
14 method_count: 3,
15 methods: {
16 static MESSAGES: [wl_message; 3] = [
17 wl_message {
18 name: c"offer".as_ptr(),
19 signature: c"s".as_ptr(),
20 types: {
21 static TYPES: [Option<&'static wl_interface>; 1] = [None];
22 TYPES.as_ptr().cast()
23 },
24 },
25 wl_message {
26 name: c"destroy".as_ptr(),
27 signature: c"".as_ptr(),
28 types: {
29 static TYPES: [Option<&'static wl_interface>; 0] = [];
30 TYPES.as_ptr().cast()
31 },
32 },
33 wl_message {
34 name: c"set_actions".as_ptr(),
35 signature: c"u".as_ptr(),
36 types: {
37 static TYPES: [Option<&'static wl_interface>; 1] = [None];
38 TYPES.as_ptr().cast()
39 },
40 },
41 ];
42 MESSAGES.as_ptr()
43 },
44 event_count: 6,
45 events: {
46 static MESSAGES: [wl_message; 6] = [
47 wl_message {
48 name: c"target".as_ptr(),
49 signature: c"?s".as_ptr(),
50 types: {
51 static TYPES: [Option<&'static wl_interface>; 1] = [None];
52 TYPES.as_ptr().cast()
53 },
54 },
55 wl_message {
56 name: c"send".as_ptr(),
57 signature: c"sh".as_ptr(),
58 types: {
59 static TYPES: [Option<&'static wl_interface>; 2] = [None, None];
60 TYPES.as_ptr().cast()
61 },
62 },
63 wl_message {
64 name: c"cancelled".as_ptr(),
65 signature: c"".as_ptr(),
66 types: {
67 static TYPES: [Option<&'static wl_interface>; 0] = [];
68 TYPES.as_ptr().cast()
69 },
70 },
71 wl_message {
72 name: c"dnd_drop_performed".as_ptr(),
73 signature: c"".as_ptr(),
74 types: {
75 static TYPES: [Option<&'static wl_interface>; 0] = [];
76 TYPES.as_ptr().cast()
77 },
78 },
79 wl_message {
80 name: c"dnd_finished".as_ptr(),
81 signature: c"".as_ptr(),
82 types: {
83 static TYPES: [Option<&'static wl_interface>; 0] = [];
84 TYPES.as_ptr().cast()
85 },
86 },
87 wl_message {
88 name: c"action".as_ptr(),
89 signature: c"u".as_ptr(),
90 types: {
91 static TYPES: [Option<&'static wl_interface>; 1] = [None];
92 TYPES.as_ptr().cast()
93 },
94 },
95 ];
96 MESSAGES.as_ptr()
97 },
98};
99
100/// An owned wl_data_source proxy.
101///
102/// See the documentation of [the module][self] for the interface description.
103#[derive(Clone, Eq, PartialEq)]
104#[repr(transparent)]
105pub struct WlDataSource {
106 /// This proxy has the interface INTERFACE.
107 proxy: UntypedOwnedProxy,
108}
109
110/// A borrowed wl_data_source proxy.
111///
112/// See the documentation of [the module][self] for the interface description.
113#[derive(Eq, PartialEq)]
114#[repr(transparent)]
115pub struct WlDataSourceRef {
116 /// This proxy has the interface INTERFACE.
117 proxy: UntypedBorrowedProxy,
118}
119
120// SAFETY: WlDataSource is a transparent wrapper around UntypedOwnedProxy
121unsafe impl UntypedOwnedProxyWrapper for WlDataSource {}
122
123// SAFETY: - INTERFACE is a valid wl_interface
124// - The only invariant is that self.proxy has a compatible interface
125unsafe impl OwnedProxy for WlDataSource {
126 const INTERFACE: &'static str = "wl_data_source";
127 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
128 const NO_OP_EVENT_HANDLER: Self::NoOpEventHandler =
129 private::EventHandler(private::NoOpEventHandler);
130 const MAX_VERSION: u32 = 3;
131
132 type Borrowed = WlDataSourceRef;
133 type Api = private::ProxyApi;
134 type NoOpEventHandler = private::EventHandler<private::NoOpEventHandler>;
135}
136
137// SAFETY: WlDataSourceRef is a transparent wrapper around UntypedBorrowedProxy
138unsafe impl UntypedBorrowedProxyWrapper for WlDataSourceRef {}
139
140// SAFETY: - The only invariant is that self.proxy has a compatible interface
141unsafe impl BorrowedProxy for WlDataSourceRef {
142 type Owned = WlDataSource;
143}
144
145impl Deref for WlDataSource {
146 type Target = WlDataSourceRef;
147
148 fn deref(&self) -> &Self::Target {
149 proxy::low_level::deref(self)
150 }
151}
152
153mod private {
154 pub struct ProxyApi;
155
156 #[allow(dead_code)]
157 pub struct EventHandler<H>(pub(super) H);
158
159 #[allow(dead_code)]
160 pub struct NoOpEventHandler;
161}
162
163impl Debug for WlDataSource {
164 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
165 write!(f, "wl_data_source#{}", self.proxy.id())
166 }
167}
168
169impl Debug for WlDataSourceRef {
170 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
171 write!(f, "wl_data_source#{}", self.proxy.id())
172 }
173}
174
175impl PartialEq<WlDataSourceRef> for WlDataSource {
176 fn eq(&self, other: &WlDataSourceRef) -> bool {
177 self.proxy == other.proxy
178 }
179}
180
181impl PartialEq<WlDataSource> for WlDataSourceRef {
182 fn eq(&self, other: &WlDataSource) -> bool {
183 self.proxy == other.proxy
184 }
185}
186
187#[allow(dead_code)]
188impl WlDataSource {
189 /// Since when the offer request is available.
190 #[allow(dead_code)]
191 pub const REQ__OFFER__SINCE: u32 = 1;
192
193 /// Since when the destroy request is available.
194 #[allow(dead_code)]
195 pub const REQ__DESTROY__SINCE: u32 = 1;
196
197 /// Since when the set_actions request is available.
198 #[allow(dead_code)]
199 pub const REQ__SET_ACTIONS__SINCE: u32 = 3;
200}
201
202#[allow(dead_code)]
203impl WlDataSource {
204 /// destroy the data source
205 ///
206 /// Destroy the data source.
207 #[inline]
208 pub fn destroy(&self) {
209 let mut args = [];
210 // SAFETY: - self.proxy has the interface INTERFACE
211 // - 1 < INTERFACE.method_count = 3
212 // - the request signature is ``
213 unsafe {
214 self.proxy.send_destructor(1, &mut args);
215 }
216 }
217}
218
219#[allow(dead_code)]
220impl WlDataSourceRef {
221 /// add an offered mime type
222 ///
223 /// This request adds a mime type to the set of mime types
224 /// advertised to targets. Can be called several times to offer
225 /// multiple types.
226 ///
227 /// # Arguments
228 ///
229 /// - `mime_type`: mime type offered by the data source
230 #[inline]
231 pub fn offer(&self, mime_type: &str) {
232 let (arg0,) = (mime_type,);
233 with_cstr_cache(|cache| {
234 let str0_offset = cache.len();
235 cache.extend_from_slice(arg0.as_bytes());
236 cache.push(0);
237 let str0 = cache[str0_offset..].as_ptr().cast();
238 let mut args = [wl_argument { s: str0 }];
239 // SAFETY: - self.proxy has the interface INTERFACE
240 // - 0 < INTERFACE.method_count = 3
241 // - the request signature is `s`
242 unsafe {
243 self.proxy.send_request(0, &mut args);
244 }
245 })
246 }
247
248 /// set the available drag-and-drop actions
249 ///
250 /// Sets the actions that the source side client supports for this
251 /// operation. This request may trigger wl_data_source.action and
252 /// wl_data_offer.action events if the compositor needs to change the
253 /// selected action.
254 ///
255 /// The dnd_actions argument must contain only values expressed in the
256 /// wl_data_device_manager.dnd_actions enum, otherwise it will result
257 /// in a protocol error.
258 ///
259 /// This request must be made once only, and can only be made on sources
260 /// used in drag-and-drop, so it must be performed before
261 /// wl_data_device.start_drag. Attempting to use the source other than
262 /// for drag-and-drop will raise a protocol error.
263 ///
264 /// # Arguments
265 ///
266 /// - `dnd_actions`: actions supported by the data source
267 #[inline]
268 pub fn set_actions(&self, dnd_actions: WlDataDeviceManagerDndAction) {
269 let (arg0,) = (dnd_actions,);
270 let mut args = [wl_argument { u: arg0.0 }];
271 // SAFETY: - self.proxy has the interface INTERFACE
272 // - 2 < INTERFACE.method_count = 3
273 // - the request signature is `u`
274 unsafe {
275 self.proxy.send_request(2, &mut args);
276 }
277 }
278}
279
280impl WlDataSource {
281 /// Since when the target event is available.
282 #[allow(dead_code)]
283 pub const EVT__TARGET__SINCE: u32 = 1;
284
285 /// Since when the send event is available.
286 #[allow(dead_code)]
287 pub const EVT__SEND__SINCE: u32 = 1;
288
289 /// Since when the cancelled event is available.
290 #[allow(dead_code)]
291 pub const EVT__CANCELLED__SINCE: u32 = 1;
292
293 /// Since when the dnd_drop_performed event is available.
294 #[allow(dead_code)]
295 pub const EVT__DND_DROP_PERFORMED__SINCE: u32 = 3;
296
297 /// Since when the dnd_finished event is available.
298 #[allow(dead_code)]
299 pub const EVT__DND_FINISHED__SINCE: u32 = 3;
300
301 /// Since when the action event is available.
302 #[allow(dead_code)]
303 pub const EVT__ACTION__SINCE: u32 = 3;
304}
305
306/// An event handler for [WlDataSource] proxies.
307#[allow(dead_code)]
308pub trait WlDataSourceEventHandler {
309 type Data: 'static;
310
311 /// a target accepts an offered mime type
312 ///
313 /// Sent when a target accepts pointer_focus or motion events. If
314 /// a target does not accept any of the offered types, type is NULL.
315 ///
316 /// Used for feedback during drag-and-drop.
317 ///
318 /// # Arguments
319 ///
320 /// - `mime_type`: mime type accepted by the target
321 #[inline]
322 fn target(&self, _data: &mut Self::Data, _slf: &WlDataSourceRef, mime_type: Option<&str>) {
323 let _ = mime_type;
324 }
325
326 /// send the data
327 ///
328 /// Request for data from the client. Send the data as the
329 /// specified mime type over the passed file descriptor, then
330 /// close it.
331 ///
332 /// # Arguments
333 ///
334 /// - `mime_type`: mime type for the data
335 /// - `fd`: file descriptor for the data
336 #[inline]
337 fn send(&self, _data: &mut Self::Data, _slf: &WlDataSourceRef, mime_type: &str, fd: OwnedFd) {
338 let _ = mime_type;
339 let _ = fd;
340 }
341
342 /// selection was cancelled
343 ///
344 /// This data source is no longer valid. There are several reasons why
345 /// this could happen:
346 ///
347 /// - The data source has been replaced by another data source.
348 /// - The drag-and-drop operation was performed, but the drop destination
349 /// did not accept any of the mime types offered through
350 /// wl_data_source.target.
351 /// - The drag-and-drop operation was performed, but the drop destination
352 /// did not select any of the actions present in the mask offered through
353 /// wl_data_source.action.
354 /// - The drag-and-drop operation was performed but didn't happen over a
355 /// surface.
356 /// - The compositor cancelled the drag-and-drop operation (e.g. compositor
357 /// dependent timeouts to avoid stale drag-and-drop transfers).
358 ///
359 /// The client should clean up and destroy this data source.
360 ///
361 /// For objects of version 2 or older, wl_data_source.cancelled will
362 /// only be emitted if the data source was replaced by another data
363 /// source.
364 #[inline]
365 fn cancelled(&self, _data: &mut Self::Data, _slf: &WlDataSourceRef) {}
366
367 /// the drag-and-drop operation physically finished
368 ///
369 /// The user performed the drop action. This event does not indicate
370 /// acceptance, wl_data_source.cancelled may still be emitted afterwards
371 /// if the drop destination does not accept any mime type.
372 ///
373 /// However, this event might however not be received if the compositor
374 /// cancelled the drag-and-drop operation before this event could happen.
375 ///
376 /// Note that the data_source may still be used in the future and should
377 /// not be destroyed here.
378 #[inline]
379 fn dnd_drop_performed(&self, _data: &mut Self::Data, _slf: &WlDataSourceRef) {}
380
381 /// the drag-and-drop operation concluded
382 ///
383 /// The drop destination finished interoperating with this data
384 /// source, so the client is now free to destroy this data source and
385 /// free all associated data.
386 ///
387 /// If the action used to perform the operation was "move", the
388 /// source can now delete the transferred data.
389 #[inline]
390 fn dnd_finished(&self, _data: &mut Self::Data, _slf: &WlDataSourceRef) {}
391
392 /// notify the selected action
393 ///
394 /// This event indicates the action selected by the compositor after
395 /// matching the source/destination side actions. Only one action (or
396 /// none) will be offered here.
397 ///
398 /// This event can be emitted multiple times during the drag-and-drop
399 /// operation, mainly in response to destination side changes through
400 /// wl_data_offer.set_actions, and as the data device enters/leaves
401 /// surfaces.
402 ///
403 /// It is only possible to receive this event after
404 /// wl_data_source.dnd_drop_performed if the drag-and-drop operation
405 /// ended in an "ask" action, in which case the final wl_data_source.action
406 /// event will happen immediately before wl_data_source.dnd_finished.
407 ///
408 /// Compositors may also change the selected action on the fly, mainly
409 /// in response to keyboard modifier changes during the drag-and-drop
410 /// operation.
411 ///
412 /// The most recent action received is always the valid one. The chosen
413 /// action may change alongside negotiation (e.g. an "ask" action can turn
414 /// into a "move" operation), so the effects of the final action must
415 /// always be applied in wl_data_offer.dnd_finished.
416 ///
417 /// Clients can trigger cursor surface changes from this point, so
418 /// they reflect the current action.
419 ///
420 /// # Arguments
421 ///
422 /// - `dnd_action`: action selected by the compositor
423 #[inline]
424 fn action(
425 &self,
426 _data: &mut Self::Data,
427 _slf: &WlDataSourceRef,
428 dnd_action: WlDataDeviceManagerDndAction,
429 ) {
430 let _ = dnd_action;
431 }
432}
433
434impl WlDataSourceEventHandler for private::NoOpEventHandler {
435 type Data = ();
436}
437
438// SAFETY: - INTERFACE is a valid wl_interface
439// - mutable_type always returns the same value
440unsafe impl<H> EventHandler for private::EventHandler<H>
441where
442 H: WlDataSourceEventHandler,
443{
444 const WL_INTERFACE: &'static wl_interface = &INTERFACE;
445
446 #[inline]
447 fn mutable_type() -> Option<(TypeId, &'static str)> {
448 let id = TypeId::of::<H::Data>();
449 let name = std::any::type_name::<H::Data>();
450 Some((id, name))
451 }
452
453 #[allow(unused_variables)]
454 unsafe fn handle_event(
455 &self,
456 queue: &Queue,
457 data: *mut u8,
458 slf: &UntypedBorrowedProxy,
459 opcode: u32,
460 args: *mut wl_argument,
461 ) {
462 // SAFETY: This function requires that slf has the interface INTERFACE
463 let slf = unsafe { proxy::low_level::from_untyped_borrowed::<WlDataSourceRef>(slf) };
464 // SAFETY: This function requires that data is `&mut T` where `T`
465 // has the type id returned by `Self::mutable_type`, i.e.,
466 // `T = H::Data`.
467 let data: &mut H::Data = unsafe { &mut *data.cast() };
468 match opcode {
469 0 => {
470 // SAFETY: INTERFACE requires that there are 1 arguments
471 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
472 // SAFETY: - INTERFACE requires that args[0] contains a string
473 // - if the pointer is not null, then it is a c string
474 let arg0 = unsafe {
475 convert_optional_string_arg("wl_data_source", "mime_type", args[0].s)
476 };
477 self.0.target(data, slf, arg0);
478 }
479 1 => {
480 // SAFETY: INTERFACE requires that there are 2 arguments
481 let args = unsafe { &*args.cast::<[wl_argument; 2]>() };
482 // SAFETY: - INTERFACE requires that args[0] contains a string
483 // - if the pointer is not null, then it is a c string
484 let arg0 = unsafe { convert_string_arg("wl_data_source", "mime_type", args[0].s) };
485 // SAFETY: - INTERFACE requires that args[1] contains a file descriptor
486 let arg1 = unsafe { OwnedFd::from_raw_fd(args[1].h) };
487 self.0.send(data, slf, arg0, arg1);
488 }
489 2 => {
490 self.0.cancelled(data, slf);
491 }
492 3 => {
493 self.0.dnd_drop_performed(data, slf);
494 }
495 4 => {
496 self.0.dnd_finished(data, slf);
497 }
498 5 => {
499 // SAFETY: INTERFACE requires that there are 1 arguments
500 let args = unsafe { &*args.cast::<[wl_argument; 1]>() };
501 // SAFETY: - INTERFACE requires that args[0] contains a uint
502 let arg0 = unsafe { WlDataDeviceManagerDndAction(args[0].u) };
503 self.0.action(data, slf, arg0);
504 }
505 _ => {
506 invalid_opcode("wl_data_source", opcode);
507 }
508 }
509 }
510}
511
512impl<H> CreateEventHandler<H> for private::ProxyApi
513where
514 H: WlDataSourceEventHandler,
515{
516 type EventHandler = private::EventHandler<H>;
517
518 #[inline]
519 fn create_event_handler(handler: H) -> Self::EventHandler {
520 private::EventHandler(handler)
521 }
522}
523
524impl WlDataSource {
525 /// Since when the error.invalid_action_mask enum variant is available.
526 #[allow(dead_code)]
527 pub const ENM__ERROR_INVALID_ACTION_MASK__SINCE: u32 = 1;
528 /// Since when the error.invalid_source enum variant is available.
529 #[allow(dead_code)]
530 pub const ENM__ERROR_INVALID_SOURCE__SINCE: u32 = 1;
531}
532
533#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
534#[allow(dead_code)]
535pub struct WlDataSourceError(pub u32);
536
537impl WlDataSourceError {
538 /// action mask contains invalid values
539 #[allow(dead_code)]
540 pub const INVALID_ACTION_MASK: Self = Self(0);
541
542 /// source doesn't accept this request
543 #[allow(dead_code)]
544 pub const INVALID_SOURCE: Self = Self(1);
545}
546
547impl Debug for WlDataSourceError {
548 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
549 let name = match *self {
550 Self::INVALID_ACTION_MASK => "INVALID_ACTION_MASK",
551 Self::INVALID_SOURCE => "INVALID_SOURCE",
552 _ => return Debug::fmt(&self.0, f),
553 };
554 f.write_str(name)
555 }
556}
557
558/// Functional event handlers.
559pub mod event_handlers {
560 use super::*;
561
562 /// Event handler for target events.
563 pub struct Target<T, F>(F, PhantomData<fn(&mut T)>);
564 impl<T, F> WlDataSourceEventHandler for Target<T, F>
565 where
566 T: 'static,
567 F: Fn(&mut T, &WlDataSourceRef, Option<&str>),
568 {
569 type Data = T;
570
571 #[inline]
572 fn target(&self, _data: &mut T, _slf: &WlDataSourceRef, mime_type: Option<&str>) {
573 self.0(_data, _slf, mime_type)
574 }
575 }
576
577 /// Event handler for send events.
578 pub struct Send<T, F>(F, PhantomData<fn(&mut T)>);
579 impl<T, F> WlDataSourceEventHandler for Send<T, F>
580 where
581 T: 'static,
582 F: Fn(&mut T, &WlDataSourceRef, &str, OwnedFd),
583 {
584 type Data = T;
585
586 #[inline]
587 fn send(&self, _data: &mut T, _slf: &WlDataSourceRef, mime_type: &str, fd: OwnedFd) {
588 self.0(_data, _slf, mime_type, fd)
589 }
590 }
591
592 /// Event handler for cancelled events.
593 pub struct Cancelled<T, F>(F, PhantomData<fn(&mut T)>);
594 impl<T, F> WlDataSourceEventHandler for Cancelled<T, F>
595 where
596 T: 'static,
597 F: Fn(&mut T, &WlDataSourceRef),
598 {
599 type Data = T;
600
601 #[inline]
602 fn cancelled(&self, _data: &mut T, _slf: &WlDataSourceRef) {
603 self.0(_data, _slf)
604 }
605 }
606
607 /// Event handler for dnd_drop_performed events.
608 pub struct DndDropPerformed<T, F>(F, PhantomData<fn(&mut T)>);
609 impl<T, F> WlDataSourceEventHandler for DndDropPerformed<T, F>
610 where
611 T: 'static,
612 F: Fn(&mut T, &WlDataSourceRef),
613 {
614 type Data = T;
615
616 #[inline]
617 fn dnd_drop_performed(&self, _data: &mut T, _slf: &WlDataSourceRef) {
618 self.0(_data, _slf)
619 }
620 }
621
622 /// Event handler for dnd_finished events.
623 pub struct DndFinished<T, F>(F, PhantomData<fn(&mut T)>);
624 impl<T, F> WlDataSourceEventHandler for DndFinished<T, F>
625 where
626 T: 'static,
627 F: Fn(&mut T, &WlDataSourceRef),
628 {
629 type Data = T;
630
631 #[inline]
632 fn dnd_finished(&self, _data: &mut T, _slf: &WlDataSourceRef) {
633 self.0(_data, _slf)
634 }
635 }
636
637 /// Event handler for action events.
638 pub struct Action<T, F>(F, PhantomData<fn(&mut T)>);
639 impl<T, F> WlDataSourceEventHandler for Action<T, F>
640 where
641 T: 'static,
642 F: Fn(&mut T, &WlDataSourceRef, WlDataDeviceManagerDndAction),
643 {
644 type Data = T;
645
646 #[inline]
647 fn action(
648 &self,
649 _data: &mut T,
650 _slf: &WlDataSourceRef,
651 dnd_action: WlDataDeviceManagerDndAction,
652 ) {
653 self.0(_data, _slf, dnd_action)
654 }
655 }
656
657 impl WlDataSource {
658 /// Creates an event handler for target events.
659 ///
660 /// The event handler ignores all other events.
661 #[allow(dead_code)]
662 pub fn on_target<T, F>(f: F) -> Target<T, F>
663 where
664 T: 'static,
665 F: Fn(&mut T, &WlDataSourceRef, Option<&str>),
666 {
667 Target(f, PhantomData)
668 }
669
670 /// Creates an event handler for send events.
671 ///
672 /// The event handler ignores all other events.
673 #[allow(dead_code)]
674 pub fn on_send<T, F>(f: F) -> Send<T, F>
675 where
676 T: 'static,
677 F: Fn(&mut T, &WlDataSourceRef, &str, OwnedFd),
678 {
679 Send(f, PhantomData)
680 }
681
682 /// Creates an event handler for cancelled events.
683 ///
684 /// The event handler ignores all other events.
685 #[allow(dead_code)]
686 pub fn on_cancelled<T, F>(f: F) -> Cancelled<T, F>
687 where
688 T: 'static,
689 F: Fn(&mut T, &WlDataSourceRef),
690 {
691 Cancelled(f, PhantomData)
692 }
693
694 /// Creates an event handler for dnd_drop_performed events.
695 ///
696 /// The event handler ignores all other events.
697 #[allow(dead_code)]
698 pub fn on_dnd_drop_performed<T, F>(f: F) -> DndDropPerformed<T, F>
699 where
700 T: 'static,
701 F: Fn(&mut T, &WlDataSourceRef),
702 {
703 DndDropPerformed(f, PhantomData)
704 }
705
706 /// Creates an event handler for dnd_finished events.
707 ///
708 /// The event handler ignores all other events.
709 #[allow(dead_code)]
710 pub fn on_dnd_finished<T, F>(f: F) -> DndFinished<T, F>
711 where
712 T: 'static,
713 F: Fn(&mut T, &WlDataSourceRef),
714 {
715 DndFinished(f, PhantomData)
716 }
717
718 /// Creates an event handler for action events.
719 ///
720 /// The event handler ignores all other events.
721 #[allow(dead_code)]
722 pub fn on_action<T, F>(f: F) -> Action<T, F>
723 where
724 T: 'static,
725 F: Fn(&mut T, &WlDataSourceRef, WlDataDeviceManagerDndAction),
726 {
727 Action(f, PhantomData)
728 }
729 }
730}