summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathan Schleußer <paradoxspiral@riseup.net>2017-08-30 21:34:23 +0200
committerJoe Wilm <jwilm@users.noreply.github.com>2017-09-05 09:07:00 -0700
commita7b50e0eb8b0888baee71e329117d38f10878b01 (patch)
treead785690933ae6420e0b1cd16c9252fde145be69 /src
parenta3d35ec1859802a2440d29ac24d87bf347a6144e (diff)
downloadalacritty-a7b50e0eb8b0888baee71e329117d38f10878b01.tar.gz
alacritty-a7b50e0eb8b0888baee71e329117d38f10878b01.zip
Update notify
Diffstat (limited to 'src')
-rw-r--r--src/config.rs35
-rw-r--r--src/renderer/mod.rs31
2 files changed, 23 insertions, 43 deletions
diff --git a/src/config.rs b/src/config.rs
index 6a656a36..260c1a70 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -19,7 +19,7 @@ use serde_yaml;
use serde::{self, de, Deserialize};
use serde::de::Error as SerdeError;
use serde::de::{Visitor, MapAccess, Unexpected};
-use notify::{Watcher as WatcherApi, RecommendedWatcher as FileWatcher, op};
+use notify::{Watcher, watcher, DebouncedEvent, RecursiveMode};
use glutin::ModifiersState;
@@ -1474,34 +1474,20 @@ impl Monitor {
Monitor {
_thread: ::util::thread::spawn_named("config watcher", move || {
let (tx, rx) = mpsc::channel();
- let mut watcher = FileWatcher::new(tx).unwrap();
+ let mut watcher = watcher(tx, Duration::from_millis(500)).unwrap();
let config_path = ::std::fs::canonicalize(path)
.expect("canonicalize config path");
- watcher.watch(&config_path).expect("watch alacritty yml");
+ watcher.watch(&config_path, RecursiveMode::NonRecursive).expect("watch alacritty yml");
loop {
let event = rx.recv().expect("watcher event");
- let ::notify::Event { path, op } = event;
- if let Ok(op) = op {
- // Skip events that are just a rename
- if op.contains(op::RENAME) && !op.contains(op::WRITE) {
- continue;
- }
-
- // Need to handle ignore for linux
- if op.contains(op::IGNORED) {
- if let Some(path) = path.as_ref() {
- if let Err(err) = watcher.watch(&path) {
- err_println!("failed to establish watch on {:?}: {:?}",
- path, err);
- }
- }
- }
-
- // Reload file
- path.map(|path| {
+ match event {
+ DebouncedEvent::Rename(_, _) => continue,
+ DebouncedEvent::Write(path) | DebouncedEvent::Create(path)
+ | DebouncedEvent::Chmod(path) => {
+ // Reload file
if path == config_path {
match Config::load_from(path) {
Ok(config) => {
@@ -1510,8 +1496,9 @@ impl Monitor {
},
Err(err) => err_println!("Ignoring invalid config: {}", err),
}
- }
- });
+ }
+ }
+ _ => {}
}
}
}),
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");
}
+ _ => {}
}
}
});