1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-19 19:31:49 +03:00
wezterm/src/wakeup.rs
2018-02-22 09:02:01 -08:00

30 lines
631 B
Rust

use failure::Error;
use glium::glutin::EventsLoopProxy;
use std::sync::mpsc::{channel, Receiver, Sender};
#[derive(Debug)]
pub enum WakeupMsg {
PtyReadable,
SigChld,
Paint,
Paste,
}
#[derive(Clone)]
pub struct Wakeup {
sender: Sender<WakeupMsg>,
proxy: EventsLoopProxy,
}
impl Wakeup {
pub fn new(proxy: EventsLoopProxy) -> (Receiver<WakeupMsg>, Self) {
let (sender, receiver) = channel();
(receiver, Self { sender, proxy })
}
pub fn send(&mut self, what: WakeupMsg) -> Result<(), Error> {
self.sender.send(what)?;
self.proxy.wakeup()?;
Ok(())
}
}