Dont send events for modifier keys unless in all key mode

This commit is contained in:
Kovid Goyal
2021-01-14 04:31:55 +05:30
parent 6b2ffc774f
commit 39f41faf9f
3 changed files with 10 additions and 1 deletions

View File

@@ -31,6 +31,10 @@ typedef struct {
KeyAction action;
} EncodingData;
static inline bool
is_modifier_key(uint32_t key) {
return GLFW_FKEY_LEFT_SHIFT <= key && key <= GLFW_FKEY_RIGHT_SUPER;
}
static inline void
convert_glfw_mods(int mods, KeyEvent *ev) {
@@ -344,6 +348,7 @@ encode_glfw_key_event(const GLFWkeyevent *e, const bool cursor_key_mode, const u
.report_text = key_encoding_flags & 8,
.embed_text = key_encoding_flags & 16
};
if (!ev.report_text && is_modifier_key(e->key)) return 0;
ev.has_text = e->text && !is_ascii_control_char(e->text[0]);
bool send_text_standalone = !ev.report_text;
if (!ev.disambiguate && GLFW_FKEY_KP_0 <= ev.key && ev.key <= GLFW_FKEY_KP_DELETE) {