Skip to content

Commit

Permalink
linux: Fix crash when NoKeymap event is received on Wayland (#24379)
Browse files Browse the repository at this point in the history
Closes #24139

For weird reasons, Sway on few linux distoros sends `NoKeymap` event when
switching windows. Zed crashes due to assertion on this event to be `XkbV1`.

To fix this, we ignore `NoKeymap` event instead crashing Zed.

Release Notes:

- Fixed a crash in Wayland-based compositors like Sway when switching windows via the keyboard.
  • Loading branch information
0xtimsb authored Feb 7, 2025
1 parent 5ffacb9 commit 6534e0b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions crates/gpui/src/platform/linux/wayland/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,11 +1132,10 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientStatePtr {
size,
..
} => {
assert_eq!(
format,
wl_keyboard::KeymapFormat::XkbV1,
"Unsupported keymap format"
);
if format != wl_keyboard::KeymapFormat::XkbV1 {
log::error!("Received keymap format {:?}, expected XkbV1", format);
return;
}
let xkb_context = xkb::Context::new(xkb::CONTEXT_NO_FLAGS);
let keymap = unsafe {
xkb::Keymap::new_from_fd(
Expand Down

0 comments on commit 6534e0b

Please sign in to comment.