Ignore the lock modifiers in legacy mode
This commit is contained in:
parent
111c123435
commit
a4db27a807
@ -48,7 +48,8 @@ is_modifier_key(const uint32_t key) {
|
||||
}
|
||||
|
||||
static inline void
|
||||
convert_glfw_mods(int mods, KeyEvent *ev) {
|
||||
convert_glfw_mods(int mods, KeyEvent *ev, const unsigned key_encoding_flags) {
|
||||
if (!key_encoding_flags) mods &= ~LOCK_MASK;
|
||||
ev->mods.alt = (mods & GLFW_MOD_ALT) > 0, ev->mods.ctrl = (mods & GLFW_MOD_CONTROL) > 0, ev->mods.shift = (mods & GLFW_MOD_SHIFT) > 0, ev->mods.super = (mods & GLFW_MOD_SUPER) > 0, ev->mods.hyper = (mods & GLFW_MOD_HYPER) > 0, ev->mods.meta = (mods & GLFW_MOD_META) > 0;
|
||||
ev->mods.numlock = (mods & GLFW_MOD_NUM_LOCK) > 0, ev->mods.capslock = (mods & GLFW_MOD_CAPS_LOCK) > 0;
|
||||
ev->mods.value = ev->mods.shift ? SHIFT : 0;
|
||||
@ -166,9 +167,8 @@ encode_function_key(const KeyEvent *ev, char *output) {
|
||||
char csi_trailer = 'u';
|
||||
uint32_t key_number = ev->key;
|
||||
bool legacy_mode = !ev->report_all_event_types && !ev->disambiguate;
|
||||
bool has_no_unlocked_mods = !(ev->mods.value & ~LOCK_MASK);
|
||||
|
||||
if (ev->cursor_key_mode && legacy_mode && has_no_unlocked_mods) {
|
||||
if (ev->cursor_key_mode && legacy_mode && !ev->mods.value) {
|
||||
switch(key_number) {
|
||||
case GLFW_FKEY_UP: SIMPLE("\x1bOA");
|
||||
case GLFW_FKEY_DOWN: SIMPLE("\x1bOB");
|
||||
@ -184,7 +184,7 @@ encode_function_key(const KeyEvent *ev, char *output) {
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
if (has_no_unlocked_mods) {
|
||||
if (!ev->mods.value) {
|
||||
if (!ev->disambiguate && !ev->report_text && key_number == GLFW_FKEY_ESCAPE) SIMPLE("\x1b");
|
||||
if (!ev->report_text) {
|
||||
switch(key_number) {
|
||||
@ -298,7 +298,7 @@ ctrled_key(const char key) { // {{{
|
||||
|
||||
static int
|
||||
encode_printable_ascii_key_legacy(const KeyEvent *ev, char *output) {
|
||||
unsigned mods = ev->mods.value & ~LOCK_MASK;
|
||||
unsigned mods = ev->mods.value;
|
||||
if (!mods) return snprintf(output, KEY_BUFFER_SIZE, "%c", (char)ev->key);
|
||||
|
||||
char key = ev->key;
|
||||
@ -389,7 +389,7 @@ encode_key(const KeyEvent *ev, char *output) {
|
||||
int ret = encode_printable_ascii_key_legacy(ev, output);
|
||||
if (ret > 0) return ret;
|
||||
}
|
||||
unsigned mods = ev->mods.value & ~LOCK_MASK;
|
||||
unsigned mods = ev->mods.value;
|
||||
if ((mods == CTRL || mods == ALT || mods == (CTRL | ALT)) && ev->alternate_key && !is_legacy_ascii_key(ev->key) && is_legacy_ascii_key(ev->alternate_key)) {
|
||||
KeyEvent alternate = *ev;
|
||||
alternate.key = ev->alternate_key;
|
||||
@ -443,6 +443,6 @@ encode_glfw_key_event(const GLFWkeyevent *e, const bool cursor_key_mode, const u
|
||||
case GLFW_RELEASE: ev.action = RELEASE; break;
|
||||
}
|
||||
if (send_text_standalone && ev.has_text && (ev.action == PRESS || ev.action == REPEAT)) return SEND_TEXT_TO_CHILD;
|
||||
convert_glfw_mods(e->mods, &ev);
|
||||
convert_glfw_mods(e->mods, &ev, key_encoding_flags);
|
||||
return encode_key(&ev, output);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user