From 0cb7a19d22fbd4683bd2ce00a391063a8b0250f1 Mon Sep 17 00:00:00 2001 From: ShootingStarDragons Date: Fri, 8 Nov 2024 22:33:38 +0900 Subject: [PATCH] feat: follow the change of layershellev --- sessionlockev/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/sessionlockev/src/lib.rs b/sessionlockev/src/lib.rs index ea9fb09..a49382f 100644 --- a/sessionlockev/src/lib.rs +++ b/sessionlockev/src/lib.rs @@ -656,12 +656,26 @@ impl Dispatch for WindowState { } _ => unreachable!(), }, + wl_keyboard::Event::Enter { .. } => { + if let (Some(token), Some(loop_handle)) = ( + keyboard_state.repeat_token.take(), + state.loop_handler.as_ref(), + ) { + loop_handle.remove(token); + } + } wl_keyboard::Event::Leave { .. } => { keyboard_state.current_repeat = None; state.message.push(( surface_id, DispatchMessageInner::ModifiersChanged(ModifiersState::empty()), )); + if let (Some(token), Some(loop_handle)) = ( + keyboard_state.repeat_token.take(), + state.loop_handler.as_ref(), + ) { + loop_handle.remove(token); + } } wl_keyboard::Event::Key { state: keystate, @@ -700,6 +714,13 @@ impl Dispatch for WindowState { } keyboard_state.current_repeat = Some(key); + + if let (Some(token), Some(loop_handle)) = ( + keyboard_state.repeat_token.take(), + state.loop_handler.as_ref(), + ) { + loop_handle.remove(token); + } let timer = Timer::from_duration(delay); if let Some(looph) = state.loop_handler.as_ref() { @@ -751,6 +772,12 @@ impl Dispatch for WindowState { && Some(key) == keyboard_state.current_repeat { keyboard_state.current_repeat = None; + if let (Some(token), Some(loop_handle)) = ( + keyboard_state.repeat_token.take(), + state.loop_handler.as_ref(), + ) { + loop_handle.remove(token); + } } } } @@ -779,6 +806,12 @@ impl Dispatch for WindowState { keyboard_state.repeat_info = if rate == 0 { // Stop the repeat once we get a disable event. keyboard_state.current_repeat = None; + if let (Some(token), Some(loop_handle)) = ( + keyboard_state.repeat_token.take(), + state.loop_handler.as_ref(), + ) { + loop_handle.remove(token); + } RepeatInfo::Disable } else { let gap = Duration::from_micros(1_000_000 / rate as u64);