Skip to content

Commit

Permalink
Merge pull request #3055 from MirServer/pacify-valgrind
Browse files Browse the repository at this point in the history
Avoid undefined behavior
  • Loading branch information
Saviq authored Oct 3, 2023
2 parents 6e2dc72 + 850d34b commit 85bc5b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/common/input/xkb_mapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/include/common/mir/input/xkb_mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <xkbcommon/xkbcommon.h>
#include <xkbcommon/xkbcommon-compose.h>
#include <mutex>
#include <optional>
#include <unordered_map>
#include <unordered_set>

Expand Down Expand Up @@ -111,7 +112,7 @@ class XKBMapper : public KeyMapper
std::shared_ptr<xkb_keymap> default_compiled_keymap;
XKBComposeTablePtr compose_table;
MirXkbModifiers xkb_modifiers_;
MirInputDeviceId last_device_id;
std::optional<MirInputDeviceId> last_device_id;

mir::optional_value<MirInputEventModifiers> modifier_state;
std::unordered_map<MirInputDeviceId, std::unique_ptr<XkbMappingState>> device_mapping;
Expand Down

0 comments on commit 85bc5b0

Please sign in to comment.