diff options
author | Matias Linares <matiaslina@gmail.com> | 2020-06-22 20:33:24 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@gmail.com> | 2020-06-22 20:33:24 -0300 |
commit | 71e220b5f94c8af1ddfbc8e57182d9a51c1f6136 (patch) | |
tree | 2de62131f562224f4377a81961fc3c27bd28070e /src/safe_x11/window.rs | |
parent | 0763564eedc459a98e63a65f7ffee8ad37100fe7 (diff) | |
download | dotwm-master.tar.gz |
Diffstat (limited to 'src/safe_x11/window.rs')
-rw-r--r-- | src/safe_x11/window.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/safe_x11/window.rs b/src/safe_x11/window.rs index 6c483d9..78b3bcf 100644 --- a/src/safe_x11/window.rs +++ b/src/safe_x11/window.rs @@ -28,7 +28,7 @@ use x11::xlib::{ }; use std::ptr; -use std::mem::uninitialized; +use std::mem::MaybeUninit; use std::mem::transmute; use std::cmp::{max}; use std::ffi::CString; @@ -54,7 +54,7 @@ fn fixed_with_ratio(x: i32, ratio: f32) -> i32 { fn window_attribs(display: *mut xlib::Display, w: Window) -> XWindowAttributes { unsafe { - let mut attrptr: XWindowAttributes = uninitialized(); + let mut attrptr: XWindowAttributes = MaybeUninit::uninit().assume_init(); XGetWindowAttributes(display, w, &mut attrptr); attrptr } @@ -65,7 +65,7 @@ impl XWindow { /// `None` if the window is the root window. pub fn new(d: *mut xlib::Display, w: Window) -> Option<XWindow> { if w != 0 { - let attrs: XWindowAttributes = unsafe { uninitialized() }; + let attrs: XWindowAttributes = unsafe { MaybeUninit::uninit().assume_init() }; Some(XWindow { display: d, inner: w, @@ -88,7 +88,7 @@ impl XWindow { /// also perform any confirmation dialog with the user. pub fn delete(&self) { // First delete the border window and then the main window. - let mut ev: XClientMessageEvent = unsafe { uninitialized() }; + let mut ev: XClientMessageEvent = unsafe { MaybeUninit::uninit().assume_init() }; ev.type_ = ClientMessage; ev.window = self.inner; ev.format = 32; @@ -143,7 +143,7 @@ impl XWindow { /// Moves the window given an offset from where it is. pub fn move_offset(&self, xoffset: i32, yoffset: i32) { unsafe { - let mut attributes: XWindowAttributes = uninitialized(); + let mut attributes: XWindowAttributes = MaybeUninit::uninit().assume_init(); XGetWindowAttributes(self.display, self.inner, &mut attributes); XMoveWindow(self.display, self.inner, attributes.x + xoffset, @@ -158,7 +158,7 @@ impl XWindow { ptr::read(s) }; let attrs = self.attributes(); - + if x < -attrs.width && x <= screen.width || -attrs.height > y && y <= screen.height { Err("Cannot move the window outside the screen!") } else { @@ -222,7 +222,7 @@ impl XWindow { XMoveResizeWindow(self.display, self.inner, x, y, w, h as u32); } } - + /// Resizes the window a fixed amount within the height and width. pub fn resize(&self, w: i32, h: i32) { let ratio = screen_ratio(self.display); |