Skip to content

Commit 81b8690

Browse files
Make new_keymap not being null in update_keymap a precondition
1 parent 4e60cff commit 81b8690

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/server/frontend_wayland/keyboard_state_tracker.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ uint32_t constexpr to_xkb_scan_code(uint32_t evdev_scan_code)
3939
void mf::KeyboardStateTracker::XkbKeyState::update_keymap(
4040
std::shared_ptr<mir::input::Keymap> const& new_keymap, xkb_context* context)
4141
{
42-
if (!new_keymap || (current_keymap && current_keymap->matches(*new_keymap)))
42+
if (!new_keymap)
43+
mir::fatal_error("KeyboardStateTracker: received null keymap");
44+
45+
if (current_keymap && current_keymap->matches(*new_keymap))
4346
return;
4447

4548
current_keymap = new_keymap;
@@ -49,15 +52,12 @@ void mf::KeyboardStateTracker::XkbKeyState::update_keymap(
4952

5053
void mf::KeyboardStateTracker::XkbKeyState::update_key(uint32_t xkb_keycode, MirKeyboardAction action)
5154
{
52-
if (state)
53-
xkb_state_update_key(state.get(), xkb_keycode, action == mir_keyboard_action_down ? XKB_KEY_DOWN : XKB_KEY_UP);
55+
xkb_state_update_key(state.get(), xkb_keycode, action == mir_keyboard_action_down ? XKB_KEY_DOWN : XKB_KEY_UP);
5456
}
5557

5658
void mf::KeyboardStateTracker::XkbKeyState::rederive_keysyms_from_scancodes(
5759
std::unordered_map<uint32_t, xkb_keysym_t>& scancode_to_keysym) const
5860
{
59-
if (!state)
60-
return;
6161

6262
for (auto& [sc, ks] : scancode_to_keysym)
6363
{

src/server/frontend_wayland/keyboard_state_tracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class KeyboardStateTracker
6666
struct XkbKeyState
6767
{
6868
/// Update the compiled keymap and XKB state when a new keymap arrives.
69-
/// \param new_keymap The keymap carried on the incoming event.
69+
/// \param new_keymap The keymap carried on the incoming event. Must not be null.
7070
/// \param context The shared XKB context owned by the tracker.
7171
void update_keymap(std::shared_ptr<mir::input::Keymap> const& new_keymap, xkb_context* context);
7272

0 commit comments

Comments
 (0)