input: keyboard_key: don't start repeater unless we generated output

I.e. what we're effectively doing is *not* repeating modifier
keys.

Besides being the "right" thing to do, this also works around another
Sway 1.2 bug, where being in a focused foot window and then switching
to a vt and back would cause us to be stuck in an endless key repeat
loop that would only stop when unfocusing, focusing back and then
unfocusing once again.
This commit is contained in:
Daniel Eklöf 2019-11-22 22:02:50 +01:00
parent 9d24e68e62
commit fd82ffdf52
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

17
input.c
View file

@ -256,7 +256,12 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
} }
} }
for (size_t i = 0; i < sizeof(key_map) / sizeof(key_map[0]) && !found_map; i++) { if (found_map) {
start_repeater(wayl, key - 8);
return;
}
for (size_t i = 0; i < sizeof(key_map) / sizeof(key_map[0]); i++) {
const struct key_map *k = &key_map[i]; const struct key_map *k = &key_map[i];
if (k->sym != sym) if (k->sym != sym)
continue; continue;
@ -275,15 +280,14 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
continue; continue;
term_to_slave(term, info->seq, strlen(info->seq)); term_to_slave(term, info->seq, strlen(info->seq));
found_map = true;
term_reset_view(term); term_reset_view(term);
selection_cancel(term); selection_cancel(term);
break; start_repeater(wayl, key - 8);
return;
} }
} }
if (!found_map) {
uint8_t buf[64] = {0}; uint8_t buf[64] = {0};
int count = 0; int count = 0;
@ -342,10 +346,9 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
term_reset_view(term); term_reset_view(term);
selection_cancel(term); selection_cancel(term);
}
}
start_repeater(wayl, key - 8); start_repeater(wayl, key - 8);
return;
}
} }
static void static void