Skip to content

Commit

Permalink
feat: follow the change of layershellev
Browse files Browse the repository at this point in the history
  • Loading branch information
Decodetalkers committed Nov 8, 2024
1 parent 7393b26 commit 0cb7a19
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions sessionlockev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,12 +656,26 @@ impl<T> Dispatch<wl_keyboard::WlKeyboard, ()> for WindowState<T> {
}
_ => 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,
Expand Down Expand Up @@ -700,6 +714,13 @@ impl<T> Dispatch<wl_keyboard::WlKeyboard, ()> for WindowState<T> {
}

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() {
Expand Down Expand Up @@ -751,6 +772,12 @@ impl<T> Dispatch<wl_keyboard::WlKeyboard, ()> for WindowState<T> {
&& 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);
}
}
}
}
Expand Down Expand Up @@ -779,6 +806,12 @@ impl<T> Dispatch<wl_keyboard::WlKeyboard, ()> for WindowState<T> {
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);
Expand Down

0 comments on commit 0cb7a19

Please sign in to comment.