diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2015-11-28 22:16:43 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2015-11-28 22:16:43 -0300 |
commit | e1ec354306742a5804a20e2651cf49945cd17287 (patch) | |
tree | 7f607096fa43f96680d933b7a046f603227e566c /src/command.rs | |
parent | 901d03b3a8ac0b7d8533fd9a8d43238d665d9cb8 (diff) | |
download | dotwm-e1ec354306742a5804a20e2651cf49945cd17287.tar.gz |
Better socket handling
The socket interface now allows almost everything that vould be done by
the internals of the window manager.
Also the Window manager now closes fine (on a success exit).
Diffstat (limited to 'src/command.rs')
-rw-r--r-- | src/command.rs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/command.rs b/src/command.rs index 3bebc52..0ccee17 100644 --- a/src/command.rs +++ b/src/command.rs @@ -7,7 +7,6 @@ use std::ffi::OsStr; use std::io::Result; use std::ops::Deref; use std::process::{Command,Child}; -use std::process; use std::ptr; use libc::c_int; @@ -47,6 +46,7 @@ pub type ExecFn = fn(&mut DotWM, XEvent, &[String]) -> bool; /// Map for keys => functions pub type BindingHash = HashMap<(u32, u32), (ExecFn, Vec<String>)>; +/// Exec a binding function. pub fn exec_func(wm: &mut DotWM, bindings: &mut BindingHash, key: u32, modifiers: u32, ev: xlib::XEvent) { if let Some(&(func, ref args)) = bindings.get(&(key, modifiers)) { let v = args.clone(); @@ -54,6 +54,7 @@ pub fn exec_func(wm: &mut DotWM, bindings: &mut BindingHash, key: u32, modifiers } } +/// Exec a external function pub fn exec(_: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { if let Some(program) = args.first() { let mut prog_args = vec![]; @@ -65,6 +66,7 @@ pub fn exec(_: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { true } +/// Move the window to a relative position pub fn move_win(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { let x = args[0].parse::<i32>().unwrap(); let y = args[1].parse::<i32>().unwrap(); @@ -74,6 +76,24 @@ pub fn move_win(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { true } +/// Move the window to an absolute position. +pub fn move_win_to(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { + let x = args[0].parse::<i32>().unwrap(); + let y = args[1].parse::<i32>().unwrap(); + if let Some(ref win) = wm.current_window() { + match win.move_to(x, y) { + Ok(()) => true, + Err(e) => { + println!("{}", e); + false + } + } + } else { + true + } +} + +/// Resize the window certain amount in x and y. pub fn resize_win(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { let w = args[0].parse::<i32>().unwrap(); let h = args[1].parse::<i32>().unwrap(); @@ -85,13 +105,16 @@ pub fn resize_win(wm: &mut DotWM, _: xlib::XEvent, args: &[String]) -> bool { true } +/// Focus the next window on the list pub fn focus_next(wm: &mut DotWM, _: xlib::XEvent, _: &[String]) -> bool { wm.focus_next(); true } -pub fn quit_dotwm(_: &mut DotWM, _: xlib::XEvent, _: &[String]) -> bool { - process::exit(0); +/// Tells the window manager that is time to exit. +pub fn quit_dotwm(wm: &mut DotWM, _: xlib::XEvent, _: &[String]) -> bool { + wm.finish = true; + true } /// Add a binding to the WM. |