From c8e4c9b2b3963601d59803403dea83887fa96f97 Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Mon, 13 Nov 2023 11:44:58 +0100 Subject: [PATCH] Prevent event processing while working. --- src/keyboard.rs | 4 ++++ src/main.rs | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/keyboard.rs b/src/keyboard.rs index f9603dc..57d8ede 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -25,6 +25,10 @@ use crate::{ pub async fn handle(greeter: Arc>, input: KeyEvent, ipc: Ipc) -> Result<(), Box> { let mut greeter = greeter.write().await; + if greeter.working { + return Ok(()); + } + match input { // ^U should erase the current buffer. KeyEvent { diff --git a/src/main.rs b/src/main.rs index d6aa1c8..767ce60 100644 --- a/src/main.rs +++ b/src/main.rs @@ -39,7 +39,7 @@ async fn main() { async fn run() -> Result<(), Box> { let mut events = Events::new().await; - let greeter = Greeter::new(events.sender()).await; + let mut greeter = Greeter::new(events.sender()).await; let mut stdout = io::stdout(); register_panic_handler(); @@ -55,6 +55,8 @@ async fn run() -> Result<(), Box> { let ipc = Ipc::new(); if greeter.remember && !greeter.username.value.is_empty() { + greeter.working = true; + ipc .send(Request::CreateSession { username: greeter.username.value.clone(),