From 975aabe3362baf56e47d0ba022f7ea35f7bc5c7f Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Mon, 9 Nov 2015 05:53:12 -0300 Subject: ExecFn Rewrite. This now allows to call a ExecFn with a &mut DotWM by parameter. This help to do some things like do the window swapping. through mod4 + tab. Also the bindings are not longer on the wm, because this generates some problems with the ExecFn. Also, now it's posible to resize the windows :) --- src/safe_x11/window.rs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/safe_x11') 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"); } } -- cgit v1.2.3-70-g09d2