From a84687174ced9bd5b2149ef893ee85514c2c7c40 Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Wed, 7 Nov 2012 17:51:35 +1100 Subject: [PATCH] Terminal: Handle keypad symbols XKB provides keypad symbols in a separate namespace. We don't care about the distinction, so map them to normal symbols before starting processing. Signed-off-by: Daniel Stone --- clients/terminal.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/clients/terminal.c b/clients/terminal.c index 4718a40..1887829 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -2126,6 +2126,69 @@ key_handler(struct window *window, struct input *input, uint32_t time, handle_bound_key(terminal, input, sym, time)) return; + /* Map keypad symbols to 'normal' equivalents before processing */ + switch (sym) { + case XKB_KEY_KP_Space: + sym = XKB_KEY_space; + break; + case XKB_KEY_KP_Tab: + sym = XKB_KEY_Tab; + break; + case XKB_KEY_KP_Enter: + sym = XKB_KEY_Return; + break; + case XKB_KEY_KP_Left: + sym = XKB_KEY_Left; + break; + case XKB_KEY_KP_Up: + sym = XKB_KEY_Up; + break; + case XKB_KEY_KP_Right: + sym = XKB_KEY_Right; + break; + case XKB_KEY_KP_Down: + sym = XKB_KEY_Down; + break; + case XKB_KEY_KP_Equal: + sym = XKB_KEY_equal; + break; + case XKB_KEY_KP_Multiply: + sym = XKB_KEY_asterisk; + break; + case XKB_KEY_KP_Add: + sym = XKB_KEY_plus; + break; + case XKB_KEY_KP_Separator: + /* Note this is actually locale-dependent and should mostly be + * a comma. But leave it as period until we one day start + * doing the right thing. */ + sym = XKB_KEY_period; + break; + case XKB_KEY_KP_Subtract: + sym = XKB_KEY_minus; + break; + case XKB_KEY_KP_Decimal: + sym = XKB_KEY_period; + break; + case XKB_KEY_KP_Divide: + sym = XKB_KEY_slash; + break; + case XKB_KEY_KP_0: + case XKB_KEY_KP_1: + case XKB_KEY_KP_2: + case XKB_KEY_KP_3: + case XKB_KEY_KP_4: + case XKB_KEY_KP_5: + case XKB_KEY_KP_6: + case XKB_KEY_KP_7: + case XKB_KEY_KP_8: + case XKB_KEY_KP_9: + sym = (sym - XKB_KEY_KP_0) + XKB_KEY_0; + break; + default: + break; + } + switch (sym) { case XKB_KEY_BackSpace: if (modifiers & MOD_ALT_MASK) -- 2.7.4