diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2015-11-22 04:02:19 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2015-11-22 04:02:19 -0300 |
commit | 13310ee7dce177a24252970f607c08f3d658e676 (patch) | |
tree | 225d8c3fff3f033cdd2584e408b19aade31affba /src/main.rs | |
parent | 5da38341bc54f24c8cad41f1b63405d8cc955fe7 (diff) | |
download | dotwm-13310ee7dce177a24252970f607c08f3d658e676.tar.gz |
Add socket functionality.
Something simple, but it works pretty well. The mapping between the strings that
comes from the socket and functions, modifiers, keys, etc. needs some rewrite
because now there's a manual mapping.
The autostart file shows some functionality on how it will work. Since the
next_xevent is ticking on 1s, it's preferible to make the writes on the
socket all together, otherwise will pass 1 sec between two calls.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/main.rs b/src/main.rs index 8bf3caa..a7d8077 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ extern crate libc; extern crate x11; extern crate unix_socket; +#[macro_use] +extern crate nom; pub mod safe_x11; pub mod command; @@ -13,7 +15,7 @@ pub mod socket; use dotwm::DotWM; use command::*; use event::{Event,next_event}; -use socket::{configure_wm, listen_socket}; +use socket::listen_socket; use safe_x11::event as x11_event; use std::collections::HashMap; @@ -32,15 +34,14 @@ fn main() { let mut bindings: BindingHash = HashMap::new(); let x11_fd = x11_event::x11_fd(dotwm.display); - add_binding(&mut dotwm,&mut bindings, keysym::XK_Return, xlib::Mod4Mask, exec, - &["xterm"]); - add_binding(&mut dotwm,&mut bindings, keysym::XK_p, xlib::Mod4Mask, exec, - &["dmenu_run"]); - add_binding(&mut dotwm,&mut bindings, keysym::XK_Tab, xlib::Mod4Mask, focus_next, &[]); - add_binding(&mut dotwm,&mut bindings, keysym::XK_h, xlib::Mod4Mask, move_win, &["-10", "0"]); - add_binding(&mut dotwm,&mut bindings, keysym::XK_j, xlib::Mod4Mask, move_win, &["0", "10"]); - add_binding(&mut dotwm,&mut bindings, keysym::XK_k, xlib::Mod4Mask, move_win, &["0", "-10"]); - add_binding(&mut dotwm,&mut bindings, keysym::XK_l, xlib::Mod4Mask, move_win, &["10", "0"]); + //add_binding(&mut dotwm,&mut bindings, keysym::XK_Return, xlib::Mod4Mask, exec, + // &["xterm"]); + //add_binding(&mut dotwm,&mut bindings, keysym::XK_p, xlib::Mod4Mask, exec, + // &["dmenu_run"]); + //add_binding(&mut dotwm,&mut bindings, keysym::XK_h, xlib::Mod4Mask, move_win, &["-10", "0"]); + //add_binding(&mut dotwm,&mut bindings, keysym::XK_j, xlib::Mod4Mask, move_win, &["0", "10"]); + //add_binding(&mut dotwm,&mut bindings, keysym::XK_k, xlib::Mod4Mask, move_win, &["0", "-10"]); + //add_binding(&mut dotwm,&mut bindings, keysym::XK_l, xlib::Mod4Mask, move_win, &["10", "0"]); // Resize add_binding(&mut dotwm,&mut bindings, keysym::XK_h, xlib::Mod4Mask | xlib::ControlMask, @@ -52,6 +53,7 @@ fn main() { add_binding(&mut dotwm,&mut bindings, keysym::XK_l, xlib::Mod4Mask | xlib::ControlMask, resize_win, &["10", "0"]); + add_binding(&mut dotwm,&mut bindings, keysym::XK_Tab, xlib::Mod4Mask, focus_next, &[]); add_binding(&mut dotwm, &mut bindings, keysym::XK_q, xlib::Mod4Mask | xlib::ShiftMask, quit_dotwm, &[]); let (transmission, receiver) = channel(); @@ -67,12 +69,13 @@ fn main() { } } }); - configure_wm(&mut dotwm, &receiver); + + exec_cmd("./autostart", &[]).unwrap(); // Main loop loop { println!("Listening socket"); - listen_socket(&mut dotwm, &receiver); + listen_socket(&mut dotwm, &mut bindings, &receiver); // Event handling. println!("Waiting event"); let event = next_event(dotwm.display, x11_fd); |