Skip to main content

gdk/
event_configure.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5/// Generated when a window size or position has changed.
6#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct EventConfigure(crate::Event);
8
9event_wrapper!(EventConfigure, GdkEventConfigure);
10event_subtype!(EventConfigure, ffi::GDK_CONFIGURE);
11
12impl EventConfigure {
13    #[doc(alias = "get_position")]
14    pub fn position(&self) -> (i32, i32) {
15        (self.as_ref().x, self.as_ref().y)
16    }
17
18    #[doc(alias = "get_size")]
19    pub fn 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}