aboutsummaryrefslogtreecommitdiff
path: root/src/socket
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2015-11-22 20:02:10 -0300
committerMatias Linares <matiaslina@openmailbox.org>2015-11-22 20:02:10 -0300
commit83b7d0cb4f30c95ce6f27d2c0944727d75eb6e5e (patch)
tree255c9e3f5e0703676382fda1157bdb5daf14bc62 /src/socket
parent47fc031feeddc955e6c7c43410613c75e3370e96 (diff)
downloaddotwm-83b7d0cb4f30c95ce6f27d2c0944727d75eb6e5e.tar.gz
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 :).
Diffstat (limited to 'src/socket')
-rw-r--r--src/socket/mod.rs8
1 files changed, 8 insertions, 0 deletions
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<UnixStream>) -> Option<UnixStream> {
+ 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<UnixStream>) {
loop {