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 | |
parent | 0763564eedc459a98e63a65f7ffee8ad37100fe7 (diff) | |
download | dotwm-71e220b5f94c8af1ddfbc8e57182d9a51c1f6136.tar.gz |
Diffstat (limited to 'src/safe_x11')
-rw-r--r-- | src/safe_x11/mod.rs | 8 | ||||
-rw-r--r-- | src/safe_x11/window.rs | 14 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/safe_x11/mod.rs b/src/safe_x11/mod.rs index a65c132..7dcdce1 100644 --- a/src/safe_x11/mod.rs +++ b/src/safe_x11/mod.rs @@ -29,7 +29,7 @@ use std::ffi::CString; use std::ffi::NulError; use std::ptr; use std::error; -use std::mem::uninitialized; +use std::mem::MaybeUninit; use std::slice; use std::fmt; use libc::c_int; @@ -81,7 +81,7 @@ pub fn x11_fd(display: *mut Display) -> c_int { /// on the main thread. pub fn next_xevent(display: *mut Display) -> XEvent { unsafe { - let mut last_event: XEvent = uninitialized(); + let mut last_event: XEvent = MaybeUninit::uninit().assume_init(); XNextEvent(display, &mut last_event); last_event } @@ -171,7 +171,7 @@ pub fn window_list(display: *mut Display) -> &'static [Window] { let mut children_count: u32 = 0; unsafe { let root_window = XDefaultRootWindow(display); - let mut children: *mut Window = uninitialized(); + let mut children: *mut Window = MaybeUninit::uninit().assume_init(); XQueryTree(display, root_window, &mut root, &mut parent, &mut children, &mut children_count); @@ -201,7 +201,7 @@ fn get_color<T: Into<Vec<u8>>>(display: *mut Display, color: T) -> u64{ let screen_num = unsafe { xlib::XDefaultScreen(display) }; let colormap = unsafe { xlib::XDefaultColormap(display, screen_num) }; unsafe { - let mut xcolor: xlib::XColor = uninitialized(); + let mut xcolor: xlib::XColor = MaybeUninit::uninit().assume_init(); let cstr = CString::new(color).unwrap(); xlib::XAllocNamedColor(display, colormap, cstr.as_ptr(), &mut xcolor, &mut xcolor); 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); |