1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-20 03:41:36 +03:00
wezterm/src/wakeup.rs

30 lines
631 B
Rust
Raw Normal View History

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(())
}
}