summaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs41
1 files changed, 10 insertions, 31 deletions
diff --git a/src/command.rs b/src/command.rs
index 21760a8..74a7255 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -106,46 +106,25 @@ pub fn move_win_to(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool {
pub fn move_win_sticky(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool {
if let Some(ref win) = wm.current_window() {
- let attrs = win.attributes();
+ let mut xgeometries = wm.x_geometries();
+ let mut ygeometries = wm.y_geometries();
match &*args[0] {
"left" => {
- let mut xgeo = wm.x_geometries();
- xgeo.sort_by(|a,b| b.cmp(a));
-
- let val = xgeo.iter().skip_while(|&a| *a >= attrs.x).next();
- if let Some(v) = val {
- let _ = win.move_to(*v, attrs.y);
- }
+ xgeometries.sort_by(|a,b| b.cmp(a));
+ win.move_sticky_left(&xgeometries);
},
"right" => {
- let mut xgeo = wm.x_geometries();
- let win_right = attrs.x + attrs.width;
- xgeo.sort_by(|a,b| a.cmp(b));
-
- let val = xgeo.iter().skip_while(|&a| *a <= win_right).next();
- if let Some(v) = val {
- let _ = win.move_to(*v - attrs.width, attrs.y);
- }
+ xgeometries.sort_by(|a,b| a.cmp(b));
+ win.move_sticky_right(&xgeometries);
},
"up" => {
- let mut ygeo = wm.y_geometries();
- ygeo.sort_by(|a,b| b.cmp(a));
-
- let val = ygeo.iter().skip_while(|&a| *a >= attrs.y).next();
- if let Some(v) = val {
- let _ = win.move_to(attrs.x, *v);
- }
+ ygeometries.sort_by(|a,b| b.cmp(a));
+ win.move_sticky_up(&ygeometries);
},
"down" => {
- let mut ygeo = wm.y_geometries();
- let win_bot = attrs.y + attrs.height;
- ygeo.sort_by(|a,b| a.cmp(b));
-
- let val = ygeo.iter().skip_while(|&a| *a <= win_bot).next();
- if let Some(v) = val {
- let _ = win.move_to(attrs.x, *v - attrs.height);
- }
+ ygeometries.sort_by(|a,b| a.cmp(b));
+ win.move_sticky_down(&ygeometries);
},
_ => (),
}