Skip to content

Commit

Permalink
Revert "fix(detect): update sctk dependency to fix crash (espanso#1769)"
Browse files Browse the repository at this point in the history
This reverts commit 655ebb1.
  • Loading branch information
AucaCoyan committed Feb 13, 2024
1 parent 03c3919 commit 686a321
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
47 changes: 24 additions & 23 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion espanso-detect/Cargo.toml
Expand Up @@ -24,7 +24,7 @@ widestring = "0.4.3"
[target.'cfg(target_os="linux")'.dependencies]
libc = "0.2.85"
scopeguard = "1.1.0"
sctk = { package = "smithay-client-toolkit", version = "0.16.1", optional = true }
sctk = { package = "smithay-client-toolkit", version = "0.15.4", optional = true }

[build-dependencies]
cc = "1.0.73"
Expand Down
16 changes: 10 additions & 6 deletions espanso-detect/src/evdev/sync/wayland.rs
Expand Up @@ -67,7 +67,10 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
* Keyboard initialization
*/

let mut seats = Vec::<(String, Option<wl_keyboard::WlKeyboard>)>::new();
let mut seats = Vec::<(
String,
Option<(wl_keyboard::WlKeyboard, calloop::RegistrationToken)>,
)>::new();

// first process already existing seats
for seat in env.get_all_seats() {
Expand All @@ -86,8 +89,8 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
RepeatKind::System,
move |event, _, _| keyboard_event_handler(event, &result_clone),
) {
Ok(kbd) => {
seats.push((name, Some(kbd)));
Ok((kbd, repeat_source)) => {
seats.push((name, Some((kbd, repeat_source))));
}
Err(e) => {
error!("Failed to map keyboard on seat {} : {:?}.", name, e);
Expand Down Expand Up @@ -124,8 +127,8 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
RepeatKind::System,
move |event, _, _| keyboard_event_handler(event, &result_clone),
) {
Ok(kbd) => {
*opt_kbd = Some(kbd);
Ok((kbd, repeat_source)) => {
*opt_kbd = Some((kbd, repeat_source));
}
Err(e) => {
eprintln!(
Expand All @@ -135,9 +138,10 @@ pub fn get_modifiers_state() -> Result<Option<super::ModifiersState>> {
}
}
}
} else if let Some(kbd) = opt_kbd.take() {
} else if let Some((kbd, source)) = opt_kbd.take() {
// the keyboard has been removed, cleanup
kbd.release();
loop_handle.remove(source);
}
});

Expand Down

0 comments on commit 686a321

Please sign in to comment.