From 59e085cf4b96eca709039e0495c8bd16279f9719 Mon Sep 17 00:00:00 2001 From: Hyeon Kim Date: Sat, 6 Feb 2021 20:26:49 +0900 Subject: [PATCH] wayland: Don't forget RepeatInfo on deactivate --- src/frontends/wayland/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/frontends/wayland/src/main.rs b/src/frontends/wayland/src/main.rs index 39c14b3c..e6cb637a 100644 --- a/src/frontends/wayland/src/main.rs +++ b/src/frontends/wayland/src/main.rs @@ -105,8 +105,9 @@ struct KimeContext { // Key repeat contexts timer: TimerFd, - /// `None` if `KimeContext` have never received a `RepeatInfo`. `Some(..)` if `RepeatInfo` is - /// known and kime-wayland started tracking the press state of keys. + /// `None` if `KimeContext` have never received a `RepeatInfo` or repeat is disabled (i.e. rate + /// is zero). `Some(..)` if `RepeatInfo` is known and kime-wayland started tracking the press + /// state of keys. repeat_state: Option<(RepeatInfo, PressState)>, } @@ -191,8 +192,12 @@ impl KimeContext { // Focus lost, reset states self.engine.reset(); self.grab_activate = false; + + // Input deactivated, stop repeating self.timer.disarm().unwrap(); - self.repeat_state = None + if let Some((_, ref mut press_state)) = self.repeat_state { + *press_state = PressState::NotPressing + } } self.current_state = std::mem::take(&mut self.pending_state); }