diff --git a/src/common/input/xkb_mapper.cpp b/src/common/input/xkb_mapper.cpp index a2dc541c585..ff64b529f14 100644 --- a/src/common/input/xkb_mapper.cpp +++ b/src/common/input/xkb_mapper.cpp @@ -153,7 +153,7 @@ void mircv::XKBMapper::update_modifier() xkb_modifiers_.depressed |= device_xkb_modifiers.depressed; xkb_modifiers_.latched |= device_xkb_modifiers.latched; xkb_modifiers_.locked |= device_xkb_modifiers.locked; - if (mapping_state.first == last_device_id) + if (last_device_id && mapping_state.first == last_device_id.value()) { xkb_modifiers_.effective_layout = device_xkb_modifiers.effective_layout; } diff --git a/src/include/common/mir/input/xkb_mapper.h b/src/include/common/mir/input/xkb_mapper.h index b7555677fe6..78971ff8fc1 100644 --- a/src/include/common/mir/input/xkb_mapper.h +++ b/src/include/common/mir/input/xkb_mapper.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -111,7 +112,7 @@ class XKBMapper : public KeyMapper std::shared_ptr default_compiled_keymap; XKBComposeTablePtr compose_table; MirXkbModifiers xkb_modifiers_; - MirInputDeviceId last_device_id; + std::optional last_device_id; mir::optional_value modifier_state; std::unordered_map> device_mapping;