From 6534e0bafda9d119a0a28fcda8dbe76afb7016a4 Mon Sep 17 00:00:00 2001 From: smit <0xtimsb@gmail.com> Date: Fri, 7 Feb 2025 07:01:46 +0000 Subject: [PATCH] linux: Fix crash when NoKeymap event is received on Wayland (#24379) 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. --- crates/gpui/src/platform/linux/wayland/client.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 624114b089bcf2..5c5ab5a3929ab5 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -1132,11 +1132,10 @@ impl Dispatch 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(