gdk/
event_configure.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 EventConfigure(::Event);
10
11event_wrapper!(EventConfigure, GdkEventConfigure);
12event_subtype!(EventConfigure, gdk_sys::GDK_CONFIGURE);
13
14impl EventConfigure {
15    pub fn get_position(&self) -> (i32, i32) {
16        (self.as_ref().x, self.as_ref().y)
17    }
18
19    pub fn get_size(&self) -> (u32, u32) {
20        let width = self.as_ref().width;
21        let height = self.as_ref().height;
22        assert!(width >= 0 && height >= 0, "Unexpected negative value");
23        (width as u32, height as u32)
24    }
25}