input: comments

This commit is contained in:
Daniel Eklöf 2020-01-11 18:59:46 +01:00
parent fed0e5c853
commit 53a437007e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

26
input.c
View file

@ -363,11 +363,9 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
"effective=0x%08x, repeats=%d", "effective=0x%08x, repeats=%d",
sym, mods, consumed, significant, effective_mods, should_repeat); sym, mods, consumed, significant, effective_mods, should_repeat);
enum modifier keymap_mods = MOD_NONE; /*
keymap_mods |= wayl->kbd.shift ? MOD_SHIFT : MOD_NONE; * Builtin shortcuts
keymap_mods |= wayl->kbd.alt ? MOD_ALT : MOD_NONE; */
keymap_mods |= wayl->kbd.ctrl ? MOD_CTRL : MOD_NONE;
keymap_mods |= wayl->kbd.meta ? MOD_META : MOD_NONE;
if (effective_mods == shift) { if (effective_mods == shift) {
if (sym == XKB_KEY_Page_Up) { if (sym == XKB_KEY_Page_Up) {
@ -404,6 +402,16 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
} }
} }
/*
* Keys generating escape sequences
*/
enum modifier keymap_mods = MOD_NONE;
keymap_mods |= wayl->kbd.shift ? MOD_SHIFT : MOD_NONE;
keymap_mods |= wayl->kbd.alt ? MOD_ALT : MOD_NONE;
keymap_mods |= wayl->kbd.ctrl ? MOD_CTRL : MOD_NONE;
keymap_mods |= wayl->kbd.meta ? MOD_META : MOD_NONE;
const struct key_data *keymap = keymap_lookup(term, sym, keymap_mods); const struct key_data *keymap = keymap_lookup(term, sym, keymap_mods);
if (keymap != NULL) { if (keymap != NULL) {
term_to_slave(term, keymap->seq, strlen(keymap->seq)); term_to_slave(term, keymap->seq, strlen(keymap->seq));
@ -413,6 +421,10 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
goto maybe_repeat; goto maybe_repeat;
} }
/*
* Compose, and maybe emit "normal" character
*/
uint8_t buf[64] = {0}; uint8_t buf[64] = {0};
int count = 0; int count = 0;
@ -427,7 +439,8 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
wayl->kbd.xkb_state, key, (char *)buf, sizeof(buf)); wayl->kbd.xkb_state, key, (char *)buf, sizeof(buf));
} }
if (count > 0) { if (count == 0)
goto maybe_repeat;
#define is_control_key(x) ((x) >= 0x40 && (x) <= 0x7f) #define is_control_key(x) ((x) >= 0x40 && (x) <= 0x7f)
#define IS_CTRL(x) ((x) < 0x20 || ((x) >= 0x7f && (x) <= 0x9f)) #define IS_CTRL(x) ((x) < 0x20 || ((x) >= 0x7f && (x) <= 0x9f))
@ -475,7 +488,6 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
term->wl->presentation_clock_id, &term->render.input_time); term->wl->presentation_clock_id, &term->render.input_time);
term_reset_view(term); term_reset_view(term);
selection_cancel(term); selection_cancel(term);
}
maybe_repeat: maybe_repeat:
if (should_repeat) if (should_repeat)