Fixed problem caused by overfilling the input queue with scroll events.
This commit is contained in:
parent
902ed9a839
commit
b87edceb86
|
@ -5,6 +5,8 @@ os:
|
|||
- windows
|
||||
- osx
|
||||
- linux
|
||||
env:
|
||||
- RUST_BACKTRACE=1
|
||||
|
||||
GH_TOKEN: &GH_TOKEN
|
||||
secure: ckWcEQHz8SekxaAdBNpiT+YF6ST0pJS15lC4MNT1mIzLMgEXpJI/peNwwRf+FGJiyqNtaK5YUAB6cP25w9QZsrwBLmLJ9wcGaHJuPc7XKvpHkEiFwTDaOqrIRmYhvAfjwH5IycnyAlAzsHsPujmhCWQyiW4YSziCOqtByY4ftzchOCh44kWmqf7HI6uSPSFfqHtTdkM21Dgwm+NpYPmwO0wmrEIwCNkN62Fb+Ghk9AqJH67vDLs+mvKQTdDc2X+fDT9sQxTI4dftSGx2JDkivwVfxX3kOroZvIRG6WmEGYyzU6wLYJlfFSg6svofdOZwNC71Byr5gEFLZOCfWrd2P4gF+CMA61PqGQMBAgAMVX4kCMblERyAdTVFKtP+WPOEBoWqsNLdzQhulF+w71MDRBnfDmuQ2TRegobCTvKefp0I3YYLLoKrDNMIvQ9572DcvLME4hzBwnizy8G1UBepqz3oa3R/6Kr8NlYBHnbbUBmzVZW1jZokz3T/c7r2fqC7h6pC8VtUh/e246ROF0k9mCVKKrsfrEZ4UjRL8RmuAQ12CeAa1GsSSwtbbwW2VIX0iVVXo080iGMKZHTTvDIRHkjA3MzPuAZyUruCjp9yQmpbG/cSzR8aJPzIia9+qXp0jmML3Du52qsF8m68gbcOpNS0CHOQY9wmuWhCatmzt2Y=
|
||||
|
|
2
TODO.md
2
TODO.md
|
@ -26,7 +26,7 @@ Note this will probably migrate to GitHub's native Issues; this was mostly for p
|
|||
|
||||
- Refactoring!
|
||||
|
||||
- Mouse + key events conflict? Make it so that some events don't clog up the loop if they are not valid keys!
|
||||
- Ensure there's a max number of inputs you can send at once --- for example, sending MANY scroll events clogs up the system
|
||||
|
||||
- Modularity
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ impl DataState {
|
|||
}
|
||||
|
||||
pub async fn update_data(&mut self) {
|
||||
debug!("Start updating...");
|
||||
//debug!("Start updating...");
|
||||
self.sys.refresh_system();
|
||||
self.sys.refresh_network();
|
||||
|
||||
|
@ -166,6 +166,6 @@ impl DataState {
|
|||
self.last_clean = current_instant;
|
||||
}
|
||||
|
||||
debug!("End updating...");
|
||||
//debug!("End updating...");
|
||||
}
|
||||
}
|
||||
|
|
26
src/main.rs
26
src/main.rs
|
@ -8,7 +8,12 @@ extern crate clap;
|
|||
extern crate failure;
|
||||
|
||||
use crossterm::{input, AlternateScreen, InputEvent, KeyEvent, MouseButton, MouseEvent};
|
||||
use std::{io::stdout, sync::mpsc, thread, time::Duration};
|
||||
use std::{
|
||||
io::stdout,
|
||||
sync::mpsc,
|
||||
thread,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
use tui_temp_fork::{backend::CrosstermBackend, Terminal};
|
||||
|
||||
pub mod app;
|
||||
|
@ -112,6 +117,7 @@ fn main() -> error::Result<()> {
|
|||
thread::spawn(move || {
|
||||
let input = input();
|
||||
input.enable_mouse_mode().unwrap();
|
||||
let mut input_timer = Instant::now();
|
||||
|
||||
// TODO: I don't like this... seems odd async doesn't work on linux (then again, sync didn't work on windows)
|
||||
if cfg!(target_os = "linux") {
|
||||
|
@ -119,13 +125,16 @@ fn main() -> error::Result<()> {
|
|||
for event in reader {
|
||||
match event {
|
||||
InputEvent::Keyboard(key) => {
|
||||
if tx.send(Event::KeyInput(key.clone())).is_err() {
|
||||
if tx.send(Event::KeyInput(key)).is_err() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
InputEvent::Mouse(mouse) => {
|
||||
if tx.send(Event::MouseInput(mouse)).is_err() {
|
||||
return;
|
||||
if Instant::now().duration_since(input_timer).as_millis() >= 40 {
|
||||
if tx.send(Event::MouseInput(mouse)).is_err() {
|
||||
return;
|
||||
}
|
||||
input_timer = Instant::now();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
@ -138,13 +147,16 @@ fn main() -> error::Result<()> {
|
|||
if let Some(event) = reader.next() {
|
||||
match event {
|
||||
InputEvent::Keyboard(key) => {
|
||||
if tx.send(Event::KeyInput(key.clone())).is_err() {
|
||||
if tx.send(Event::KeyInput(key)).is_err() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
InputEvent::Mouse(mouse) => {
|
||||
if tx.send(Event::MouseInput(mouse)).is_err() {
|
||||
return;
|
||||
if Instant::now().duration_since(input_timer).as_millis() >= 40 {
|
||||
if tx.send(Event::MouseInput(mouse)).is_err() {
|
||||
return;
|
||||
}
|
||||
input_timer = Instant::now();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
Loading…
Reference in New Issue