other: remove the mouse throttler except for scroll events (#886)
The throttler is only really needed for scrolls (e.g. free scroll wheels in Logitech mice), I don't really see it being needed in any other contexts. Moves/drag is another one I guess but we outright ignore those events right now.
This commit is contained in:
parent
99fc5fc2c8
commit
9dc6d0c0d5
42
src/lib.rs
42
src/lib.rs
|
@ -67,9 +67,9 @@ pub type Pid = usize;
|
||||||
pub type Pid = libc::pid_t;
|
pub type Pid = libc::pid_t;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BottomEvent<I, J> {
|
pub enum BottomEvent {
|
||||||
KeyInput(I),
|
KeyInput(KeyEvent),
|
||||||
MouseInput(J),
|
MouseInput(MouseEvent),
|
||||||
PasteEvent(String),
|
PasteEvent(String),
|
||||||
Update(Box<data_harvester::Data>),
|
Update(Box<data_harvester::Data>),
|
||||||
Clean,
|
Clean,
|
||||||
|
@ -410,8 +410,7 @@ pub fn update_data(app: &mut App) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_input_thread(
|
pub fn create_input_thread(
|
||||||
sender: Sender<BottomEvent<crossterm::event::KeyEvent, crossterm::event::MouseEvent>>,
|
sender: Sender<BottomEvent>, termination_ctrl_lock: Arc<Mutex<bool>>,
|
||||||
termination_ctrl_lock: Arc<Mutex<bool>>,
|
|
||||||
) -> JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut mouse_timer = Instant::now();
|
let mut mouse_timer = Instant::now();
|
||||||
|
@ -439,20 +438,23 @@ pub fn create_input_thread(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::Mouse(mouse) => {
|
Event::Mouse(mouse) => match mouse.kind {
|
||||||
if Instant::now().duration_since(mouse_timer).as_millis() >= 20 {
|
MouseEventKind::Moved | MouseEventKind::Drag(..) => {}
|
||||||
match mouse.kind {
|
MouseEventKind::ScrollDown | MouseEventKind::ScrollUp => {
|
||||||
MouseEventKind::Moved => {}
|
if Instant::now().duration_since(mouse_timer).as_millis() >= 20
|
||||||
_ => {
|
{
|
||||||
if sender.send(BottomEvent::MouseInput(mouse)).is_err()
|
if sender.send(BottomEvent::MouseInput(mouse)).is_err() {
|
||||||
{
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
mouse_timer = Instant::now();
|
|
||||||
}
|
}
|
||||||
|
mouse_timer = Instant::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
_ => {
|
||||||
|
if sender.send(BottomEvent::MouseInput(mouse)).is_err() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,10 +465,10 @@ pub fn create_input_thread(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_collection_thread(
|
pub fn create_collection_thread(
|
||||||
sender: Sender<BottomEvent<crossterm::event::KeyEvent, crossterm::event::MouseEvent>>,
|
sender: Sender<BottomEvent>, control_receiver: Receiver<ThreadControlEvent>,
|
||||||
control_receiver: Receiver<ThreadControlEvent>, termination_ctrl_lock: Arc<Mutex<bool>>,
|
termination_ctrl_lock: Arc<Mutex<bool>>, termination_ctrl_cvar: Arc<Condvar>,
|
||||||
termination_ctrl_cvar: Arc<Condvar>, app_config_fields: &app::AppConfigFields,
|
app_config_fields: &app::AppConfigFields, filters: app::DataFilters,
|
||||||
filters: app::DataFilters, used_widget_set: UsedWidgets,
|
used_widget_set: UsedWidgets,
|
||||||
) -> JoinHandle<()> {
|
) -> JoinHandle<()> {
|
||||||
let temp_type = app_config_fields.temperature_type;
|
let temp_type = app_config_fields.temperature_type;
|
||||||
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
let use_current_cpu_total = app_config_fields.use_current_cpu_total;
|
||||||
|
|
Loading…
Reference in New Issue