diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2016-01-27 12:27:34 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2016-01-27 12:27:34 -0300 |
commit | 5d7d8a19f6364dfb6e6583125ced3103d069f2b3 (patch) | |
tree | d6906802f0427fd843783dba1d608cf3c54fcd82 /src/command.rs | |
parent | f7a827971f436d9d493cff9ecb7fe91958f71be1 (diff) | |
download | dotwm-5d7d8a19f6364dfb6e6583125ced3103d069f2b3.tar.gz |
Refactor move sticky.
Diffstat (limited to 'src/command.rs')
-rw-r--r-- | src/command.rs | 41 |
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); }, _ => (), } |