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 crate::ffi;
4use glib::translate::*;
5
6/// Generated when a window size or position has changed.
7#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
8pub struct EventConfigure(crate::Event);
9
10event_wrapper!(EventConfigure, GdkEventConfigure);
11event_subtype!(EventConfigure, ffi::GDK_CONFIGURE);
12
13impl EventConfigure {
14    #[doc(alias = "get_position")]
15    pub fn position(&self) -> (i32, i32) {
16        (self.as_ref().x, self.as_ref().y)
17    }
18
19    #[doc(alias = "get_size")]
20    pub fn size(&self) -> (u32, u32) {
21        let width = self.as_ref().width;
22        let height = self.as_ref().height;
23        assert!(width >= 0 && height >= 0, "Unexpected negative value");
24        (width as u32, height as u32)
25    }
26}