aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-01-11 17:40:27 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-01-11 17:40:27 +0000
commitfed0e5c853dd0060412e11a4ee912cefc05250b5 (patch)
treeee3560d97147f3a1b8a753591f203c6f0eb18a32 /input.c
parentkeymap: remove keymap table (diff)
input: keymap_lookup: only do lookup, don't sent to client
Diffstat (limited to 'input.c')
-rw-r--r--input.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/input.c b/input.c
index 21fd1f11..c429984f 100644
--- a/input.c
+++ b/input.c
@@ -167,7 +167,7 @@ keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
}
static const struct key_data *
-keymap_data(xkb_keysym_t sym, size_t *count)
+keymap_data_for_sym(xkb_keysym_t sym, size_t *count)
{
#define ALEN(a) (sizeof(a) / sizeof(a[0]))
switch (sym) {
@@ -254,14 +254,14 @@ keymap_data(xkb_keysym_t sym, size_t *count)
return NULL;
}
-static bool
+static const struct key_data *
keymap_lookup(struct terminal *term, xkb_keysym_t sym, enum modifier mods)
{
size_t count;
- const struct key_data *info = keymap_data(sym, &count);
+ const struct key_data *info = keymap_data_for_sym(sym, &count);
if (info == NULL)
- return false;
+ return NULL;
for (size_t j = 0; j < count; j++) {
if (info[j].modifiers != MOD_ANY && info[j].modifiers != mods)
@@ -275,14 +275,10 @@ keymap_lookup(struct terminal *term, xkb_keysym_t sym, enum modifier mods)
info[j].keypad_keys_mode != term->keypad_keys_mode)
continue;
- term_to_slave(term, info[j].seq, strlen(info[j].seq));
-
- term_reset_view(term);
- selection_cancel(term);
- return true;
+ return &info[j];
}
- return false;
+ return NULL;
}
static void
@@ -408,9 +404,14 @@ keyboard_key(void *data, struct wl_keyboard *wl_keyboard, uint32_t serial,
}
}
+ const struct key_data *keymap = keymap_lookup(term, sym, keymap_mods);
+ if (keymap != NULL) {
+ term_to_slave(term, keymap->seq, strlen(keymap->seq));
- if (keymap_lookup(term, sym, keymap_mods))
+ term_reset_view(term);
+ selection_cancel(term);
goto maybe_repeat;
+ }
uint8_t buf[64] = {0};
int count = 0;