diff options
Diffstat (limited to 'src/safe_x11/window.rs')
-rw-r--r-- | src/safe_x11/window.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/safe_x11/window.rs b/src/safe_x11/window.rs index d2fc9ea..24b5b62 100644 --- a/src/safe_x11/window.rs +++ b/src/safe_x11/window.rs @@ -83,9 +83,9 @@ impl XWindow { /// Returns the window attributes from certain window. pub fn attributes(&self) -> XWindowAttributes { unsafe { - let attrptr: *mut XWindowAttributes = uninitialized(); - XGetWindowAttributes(self.display, self.inner, attrptr); - ptr::read(attrptr) + let mut attrptr: XWindowAttributes = uninitialized(); + XGetWindowAttributes(self.display, self.inner, &mut attrptr); + attrptr } } @@ -94,10 +94,6 @@ impl XWindow { unsafe { let mut attributes: XWindowAttributes = uninitialized(); XGetWindowAttributes(self.display, self.inner, &mut attributes); - println!("Moving window({:x}), {} + {} = {}, {} + {} = {}", - self.inner as u64, - attributes.x, xoffset, attributes.x + xoffset, - attributes.y, yoffset, attributes.y + yoffset); XMoveWindow(self.display, self.inner, attributes.x + xoffset, attributes.y + yoffset); @@ -131,7 +127,7 @@ impl XWindow { } } - /// Raise the focus of the window. + /// Raise the focus of the window and set a border. pub fn focus(&self) { let attrs = self.attributes(); if attrs.map_state == IsViewable { @@ -140,5 +136,14 @@ impl XWindow { RevertToParent, CurrentTime) }; } + self.raise(); + self.set_border_width(1); + self.set_border_color("red"); + } + + /// Give a black border. + pub fn unfocus(&self) { + self.set_border_width(1); + self.set_border_color("black"); } } |