gdk/
event_dnd.rs

1// Copyright 2016, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use gdk_sys;
6use glib::translate::*;
7
8#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct EventDND(::Event);
10
11event_wrapper!(EventDND, GdkEventDND);
12event_subtype!(
13    EventDND,
14    gdk_sys::GDK_DRAG_ENTER
15        | gdk_sys::GDK_DRAG_LEAVE
16        | gdk_sys::GDK_DRAG_MOTION
17        | gdk_sys::GDK_DRAG_STATUS
18        | gdk_sys::GDK_DROP_START
19        | gdk_sys::GDK_DROP_FINISHED
20);
21
22impl EventDND {
23    pub fn get_context(&self) -> Option<::DragContext> {
24        unsafe { from_glib_none(self.as_ref().context) }
25    }
26
27    pub fn get_time(&self) -> u32 {
28        self.as_ref().time
29    }
30
31    pub fn get_root(&self) -> (i16, i16) {
32        let x_root = self.as_ref().x_root;
33        let y_root = self.as_ref().y_root;
34        (x_root, y_root)
35    }
36}