fix: correctly set gui error

This commit is contained in:
Jack Wills
2023-03-02 05:18:06 +00:00
parent cda0913616
commit 340893a860
2 changed files with 24 additions and 24 deletions
+12 -11
View File
@@ -80,22 +80,23 @@ impl InputHandler {
/// Toggle the mouse capture (via input of the 'm' key)
fn m_key(&mut self) {
if self.mouse_capture {
match execute!(std::io::stdout(), DisableMouseCapture) {
Ok(_) => self
.gui_state
if execute!(std::io::stdout(), DisableMouseCapture).is_ok() {
self.gui_state
.lock()
.set_info_box("✖ mouse capture disabled".to_owned()),
Err(_) => {
self.app_data
.lock()
.set_error(AppError::MouseCapture(false));
}
.set_info_box("✖ mouse capture disabled".to_owned());
} else {
self.app_data
.lock()
.set_error(AppError::MouseCapture(false));
self.gui_state.lock().status_push(Status::Error);
}
} else {
Ui::enable_mouse_capture();
} else if Ui::enable_mouse_capture().is_ok() {
self.gui_state
.lock()
.set_info_box("✓ mouse capture enabled".to_owned());
} else {
self.app_data.lock().set_error(AppError::MouseCapture(true));
self.gui_state.lock().status_push(Status::Error);
};
// If the info box sleep handle is currently being executed, as in 'm' is pressed twice within a 4000ms window