summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/event.rs6
-rw-r--r--src/main.rs14
-rw-r--r--src/socket/mod.rs2
3 files changed, 9 insertions, 13 deletions
diff --git a/src/event.rs b/src/event.rs
index 055a94b..9e96146 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -18,9 +18,7 @@ use x11::xlib::{
use x11::xlib;
use x11::xlib::Display;
-use unix_socket::UnixStream;
-use unix_socket::UnixListener;
-
+use std::os::unix::net::{UnixStream,UnixListener};
use libc::c_int;
use libc::{
FD_SET,
@@ -69,7 +67,7 @@ impl fmt::Debug for Event {
Event::Map(ev) => format!("Map({})", XEvent::from(ev).get_type()),
Event::Configure(ev) => format!("Configure({})", XEvent::from(ev).get_type()),
Event::Expose(ev) => format!("Expose({})", XEvent::from(ev).get_type()),
- Event::Socket(_) => String::from("Socket()"),
+ Event::Socket(ref ev) => format!("Socket({:?})", ev),
Event::NoEvent => String::from("NoEvent"),
};
diff --git a/src/main.rs b/src/main.rs
index 31d0423..b0b5b9b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,6 @@
#![cfg_attr(feature="clippy", plugin(clippy))]
extern crate libc;
extern crate x11;
-extern crate unix_socket;
#[macro_use]
extern crate lazy_static;
@@ -32,7 +31,7 @@ use std::fs;
use std::env;
use std::path::{PathBuf};
use std::io::{Read,Write};
-use unix_socket::UnixListener;
+use std::os::unix::net::UnixListener;
fn dotwm_dir() -> PathBuf {
let mut path = env::home_dir().unwrap();
@@ -79,7 +78,6 @@ fn main() {
// Main loop
while !dotwm.finish {
let event = unsafe { select_event(dotwm.display, x11_fd, &listener) };
- //println!("Event: {:?}", event);
match event {
Event::Key(mut e, true) => {
let keysym = unsafe { xlib::XLookupKeysym(&mut e, 0) as u32 };
@@ -92,6 +90,7 @@ fn main() {
// be handled by the wm.
let map_event = xlib::XMapEvent::from(e);
if map_event.override_redirect == 0 {
+ println!("Creating window {}", map_event.window);
dotwm.add_window(map_event.window);
}
}
@@ -114,19 +113,18 @@ fn main() {
exec_func(&mut dotwm, &mut bindings, 1, e.state, xlib::XEvent::from(e));
},
Event::Socket(stream) => {
- let mut s = stream.try_clone().unwrap();
+ let mut s = stream.try_clone().expect("Cannot clone stream");
let mut buf = String::new();
- s.read_to_string(&mut buf).unwrap();
-
+ s.read_to_string(&mut buf).expect("Cannot read from string");
for line in buf.lines() {
let res = parser::parse(line);
match res {
Ok(pcmd) => {
pcmd.handle(&mut dotwm, &mut bindings);
- let _ = write!(s, "+ok");
+ let _ = write!(s, "+ok\n");
},
Err(e) => {
- let _ = write!(s, "-{}", e);
+ let _ = write!(s, "-{}\n", e);
},
}
}
diff --git a/src/socket/mod.rs b/src/socket/mod.rs
index 6ee1c09..dd55a67 100644
--- a/src/socket/mod.rs
+++ b/src/socket/mod.rs
@@ -4,7 +4,7 @@ pub mod parser;
use std::sync::mpsc::{Receiver, TryRecvError};
-use unix_socket::UnixStream;
+use std::os::unix::net::UnixStream;
use dotwm::DotWM;
use command::*;