fix: stop_running function
Use stop_running to set the global is_running AtomicBool to false, and to also, on a seperate thread, enable & then disable mouse capture, as was experience strange issue on Linux & WSL with mouse movements being piped to stdout
This commit is contained in:
@@ -20,6 +20,7 @@ use crate::{
|
|||||||
app_data::{AppData, ContainerId, DockerControls},
|
app_data::{AppData, ContainerId, DockerControls},
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
parse_args::CliArgs,
|
parse_args::CliArgs,
|
||||||
|
stop_running,
|
||||||
ui::{GuiState, Status},
|
ui::{GuiState, Status},
|
||||||
ENTRY_POINT,
|
ENTRY_POINT,
|
||||||
};
|
};
|
||||||
@@ -408,12 +409,7 @@ impl DockerData {
|
|||||||
.values()
|
.values()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.for_each(tokio::task::JoinHandle::abort);
|
.for_each(tokio::task::JoinHandle::abort);
|
||||||
// This is a fix for a weird bug on Linux + WSL which will output mouse movement to the stdout
|
stop_running(&self.is_running);
|
||||||
// execute!(std::io::stdout(), DisableMouseCapture).unwrap_or(());
|
|
||||||
std::thread::spawn(||{
|
|
||||||
execute!(std::io::stdout(), DisableMouseCapture).unwrap_or(());
|
|
||||||
});
|
|
||||||
self.is_running.store(false, Ordering::SeqCst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use crate::{
|
|||||||
app_data::{AppData, DockerControls, Header},
|
app_data::{AppData, DockerControls, Header},
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
docker_data::DockerMessage,
|
docker_data::DockerMessage,
|
||||||
|
stop_running,
|
||||||
ui::{GuiState, SelectablePanel, Status},
|
ui::{GuiState, SelectablePanel, Status},
|
||||||
};
|
};
|
||||||
pub use message::InputMessages;
|
pub use message::InputMessages;
|
||||||
@@ -134,12 +135,7 @@ impl InputHandler {
|
|||||||
.lock()
|
.lock()
|
||||||
.status_contains(&[Status::Error, Status::Init]);
|
.status_contains(&[Status::Error, Status::Init]);
|
||||||
if error_init || self.docker_sender.send(DockerMessage::Quit).await.is_err() {
|
if error_init || self.docker_sender.send(DockerMessage::Quit).await.is_err() {
|
||||||
// This is a fix for a weird bug on Linux + WSL which will output mouse movement to the stdout
|
stop_running(&self.is_running);
|
||||||
|
|
||||||
std::thread::spawn(||{
|
|
||||||
execute!(std::io::stdout(), DisableMouseCapture).unwrap_or(());
|
|
||||||
});
|
|
||||||
self.is_running.store(false, Ordering::SeqCst);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+27
-25
@@ -1,24 +1,28 @@
|
|||||||
#![forbid(unsafe_code)]
|
#![forbid(unsafe_code)]
|
||||||
// #![warn(
|
#![warn(
|
||||||
// clippy::nursery,
|
clippy::nursery,
|
||||||
// clippy::pedantic,
|
clippy::pedantic,
|
||||||
// clippy::expect_used,
|
clippy::expect_used,
|
||||||
// clippy::todo,
|
clippy::todo,
|
||||||
// clippy::unused_async,
|
clippy::unused_async,
|
||||||
// clippy::unwrap_used
|
clippy::unwrap_used
|
||||||
// )]
|
)]
|
||||||
// // Warning - These are indeed pedantic
|
// Warning - These are indeed pedantic
|
||||||
// #![allow(
|
#![allow(
|
||||||
// clippy::module_name_repetitions,
|
clippy::module_name_repetitions,
|
||||||
// clippy::doc_markdown,
|
clippy::doc_markdown,
|
||||||
// clippy::similar_names
|
clippy::similar_names
|
||||||
// )]
|
)]
|
||||||
// Only allow when debugging
|
// Only allow when debugging
|
||||||
#![allow(unused)]
|
#![allow(unused)]
|
||||||
|
|
||||||
use app_data::AppData;
|
use app_data::AppData;
|
||||||
use app_error::AppError;
|
use app_error::AppError;
|
||||||
use bollard::Docker;
|
use bollard::Docker;
|
||||||
|
use crossterm::{
|
||||||
|
event::{DisableMouseCapture, EnableMouseCapture},
|
||||||
|
execute,
|
||||||
|
};
|
||||||
use docker_data::DockerData;
|
use docker_data::DockerData;
|
||||||
use input_handler::InputMessages;
|
use input_handler::InputMessages;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@@ -66,6 +70,15 @@ fn check_if_containerised() -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set is_running to false, disable mouse capture, due to weird bug on Linux & WSL terminals
|
||||||
|
/// where mouse movement will be piped to the stdout
|
||||||
|
fn stop_running(is_running: &AtomicBool) {
|
||||||
|
std::thread::spawn(|| {
|
||||||
|
execute!(std::io::stdout(), EnableMouseCapture).unwrap_or(());
|
||||||
|
execute!(std::io::stdout(), DisableMouseCapture).unwrap_or(());
|
||||||
|
});
|
||||||
|
is_running.store(false, std::sync::atomic::Ordering::SeqCst);
|
||||||
|
}
|
||||||
/// Create docker daemon handler, and only spawn up the docker data handler if a ping returns non-error
|
/// Create docker daemon handler, and only spawn up the docker data handler if a ping returns non-error
|
||||||
async fn docker_init(
|
async fn docker_init(
|
||||||
app_data: &Arc<Mutex<AppData>>,
|
app_data: &Arc<Mutex<AppData>>,
|
||||||
@@ -149,15 +162,4 @@ async fn main() {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// let mut child = std::process::Command::new("tput").arg("reset").spawn().unwrap_or_else(|e| panic!("Could not run tput: {}", e));
|
|
||||||
// let result = child.wait().unwrap_or_else(|e| panic!("Could not wait for tput process: {}", e));
|
|
||||||
|
|
||||||
// if ! result.success() {
|
|
||||||
// panic!("tput failed with error code {}", result.code().unwrap());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// std::io::stdout().lock().flush().unwrap_or(());
|
|
||||||
// std::io::stdout().lock().write(b"").unwrap_or_default();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user