From 83b7d0cb4f30c95ce6f27d2c0944727d75eb6e5e Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 22 Nov 2015 20:02:10 -0300 Subject: Death to the threads. All the socket stuff is done syncing it with select calls so we can get either a X11 event or a Socket event. Also cleanup the C mess, it's done all in rust now :). --- src/socket/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/socket') diff --git a/src/socket/mod.rs b/src/socket/mod.rs index 804f7ac..e260284 100644 --- a/src/socket/mod.rs +++ b/src/socket/mod.rs @@ -10,6 +10,14 @@ use unix_socket::UnixStream; use dotwm::DotWM; use command::*; +pub fn next_socket_event(rx: &Receiver) -> Option { + match rx.try_recv() { + Ok(stream) => Some(stream), + Err(TryRecvError::Empty) => None, + Err(TryRecvError::Disconnected) => panic!("Socket disconnected"), + } +} + /// Listen a socket parsing and executing all the commands. pub fn listen_socket(dotwm: &mut DotWM, bindings: &mut BindingHash, rx: &Receiver) { loop { -- cgit v1.2.3-70-g09d2