diff options
author | 2022-08-05 11:13:31 -0700 | |
---|---|---|
committer | 2022-08-08 14:09:20 -0700 | |
commit | aa9e9d25f15c100e7da87f6465ba50b45f7bf552 (patch) | |
tree | 839caf6cfcbdfaa5c490afb006bf82ea05c007e9 /include/input/KeyCharacterMap.h | |
parent | f29711cf60a1561306a23622a6f16b2cee414376 (diff) |
Use std::list to store Behavior objects
There's a bug about behavior being null. It's not clear how it gets
there, but before this CL, there was a custom implementation of linked
list to store the behaviours. Instead of implementing a
custom linked list, let's switch over to std::list to remove the
possibility of this bug.
Bug: 238626341
Test: atest libinput_tests inputflinger_tests KeyCharacterMapTest
Change-Id: I98e20de7d40b74e4af085cdafb68f867e6ebfe19
Diffstat (limited to 'include/input/KeyCharacterMap.h')
-rw-r--r-- | include/input/KeyCharacterMap.h | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/include/input/KeyCharacterMap.h b/include/input/KeyCharacterMap.h index 585ea3c315..1c9a5eaac1 100644 --- a/include/input/KeyCharacterMap.h +++ b/include/input/KeyCharacterMap.h @@ -18,6 +18,7 @@ #define _LIBINPUT_KEY_CHARACTER_MAP_H #include <stdint.h> +#include <list> #ifdef __linux__ #include <binder/IBinder.h> @@ -152,29 +153,22 @@ public: private: struct Behavior { - Behavior(); - Behavior(const Behavior& other); - - /* The next behavior in the list, or NULL if none. */ - Behavior* next; - /* The meta key modifiers for this behavior. */ - int32_t metaState; + int32_t metaState = 0; /* The character to insert. */ - char16_t character; + char16_t character = 0; /* The fallback keycode if the key is not handled. */ - int32_t fallbackKeyCode; + int32_t fallbackKeyCode = 0; /* The replacement keycode if the key has to be replaced outright. */ - int32_t replacementKeyCode; + int32_t replacementKeyCode = 0; }; struct Key { Key(); Key(const Key& other); - ~Key(); /* The single character label printed on the key, or 0 if none. */ char16_t label; @@ -184,7 +178,7 @@ private: /* The list of key behaviors sorted from most specific to least specific * meta key binding. */ - Behavior* firstBehavior; + std::list<Behavior> behaviors; }; class Parser { |