diff options
author | Jonathan Schleußer <paradoxspiral@riseup.net> | 2017-08-30 21:34:23 +0200 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-09-05 09:07:00 -0700 |
commit | a7b50e0eb8b0888baee71e329117d38f10878b01 (patch) | |
tree | ad785690933ae6420e0b1cd16c9252fde145be69 /src/renderer/mod.rs | |
parent | a3d35ec1859802a2440d29ac24d87bf347a6144e (diff) | |
download | alacritty-a7b50e0eb8b0888baee71e329117d38f10878b01.tar.gz alacritty-a7b50e0eb8b0888baee71e329117d38f10878b01.zip |
Update notify
Diffstat (limited to 'src/renderer/mod.rs')
-rw-r--r-- | src/renderer/mod.rs | 31 |
1 files changed, 12 insertions, 19 deletions
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index 0dad716e..3c07450b 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -19,6 +19,7 @@ use std::mem::size_of; use std::path::{PathBuf}; use std::ptr; use std::sync::mpsc; +use std::time::Duration; use cgmath; use fnv::FnvHasher; @@ -26,7 +27,7 @@ use font::{self, Rasterizer, Rasterize, RasterizedGlyph, FontDesc, GlyphKey, Fon use gl::types::*; use gl; use index::{Line, Column, RangeInclusive}; -use notify::{Watcher as WatcherApi, RecommendedWatcher as Watcher, op}; +use notify::{Watcher, watcher, RecursiveMode, DebouncedEvent}; use config::{self, Config, Delta}; use term::{self, cell, RenderableCell}; @@ -536,29 +537,21 @@ impl QuadRenderer { if cfg!(feature = "live-shader-reload") { ::std::thread::spawn(move || { let (tx, rx) = ::std::sync::mpsc::channel(); - let mut watcher = Watcher::new(tx).expect("create file watcher"); - watcher.watch(TEXT_SHADER_F_PATH).expect("watch fragment shader"); - watcher.watch(TEXT_SHADER_V_PATH).expect("watch vertex shader"); + let mut watcher = watcher(tx, Duration::from_millis(500)).expect("create file watcher"); + watcher.watch(TEXT_SHADER_F_PATH, RecursiveMode::NonRecursive) + .expect("watch fragment shader"); + watcher.watch(TEXT_SHADER_V_PATH, RecursiveMode::NonRecursive) + .expect("watch vertex shader"); loop { let event = rx.recv().expect("watcher event"); - let ::notify::Event { path, op } = event; - if let Ok(op) = op { - if op.contains(op::RENAME) { - continue; - } - - if op.contains(op::IGNORED) { - if let Some(path) = path.as_ref() { - if let Err(err) = watcher.watch(path) { - warn!("failed to establish watch on {:?}: {:?}", path, err); - } - } - - msg_tx.send(Msg::ShaderReload) - .expect("msg send ok"); + match event { + DebouncedEvent::Rename(_, _) => continue, + DebouncedEvent::Create(_) | DebouncedEvent::Write(_) | DebouncedEvent::Chmod(_) => { + msg_tx.send(Msg::ShaderReload).expect("msg send ok"); } + _ => {} } } }); |