From 23c03ad9816ed43844408216d3a406ecf02913ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 19 Jan 2011 14:41:20 -0500 Subject: [PATCH] Use libxkbcommon #defines for modifiers --- clients/terminal.c | 16 ++++++++-------- clients/window.c | 2 +- clients/window.h | 9 +-------- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/clients/terminal.c b/clients/terminal.c index ab9bdb3d..20974008 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -273,9 +273,9 @@ function_key_response(char escape, int num, uint32_t modifiers, int mod_num = 0; int len; - if (modifiers & WINDOW_MODIFIER_SHIFT) mod_num |= 1; - if (modifiers & WINDOW_MODIFIER_ALT) mod_num |= 2; - if (modifiers & WINDOW_MODIFIER_CONTROL) mod_num |= 4; + if (modifiers & XKB_COMMON_SHIFT_MASK) mod_num |= 1; + if (modifiers & XKB_COMMON_MOD1_MASK) mod_num |= 2; + if (modifiers & XKB_COMMON_CONTROL_MASK) mod_num |= 4; if (mod_num != 0) len = snprintf(response, MAX_RESPONSE, "\e[%d;%d%c", @@ -1969,8 +1969,8 @@ key_handler(struct window *window, struct input *input, uint32_t time, int len = 0; modifiers = input_get_modifiers(input); - if ((modifiers & WINDOW_MODIFIER_CONTROL) && - (modifiers & WINDOW_MODIFIER_SHIFT) && + if ((modifiers & XKB_COMMON_CONTROL_MASK) && + (modifiers & XKB_COMMON_SHIFT_MASK) && state && handle_bound_key(terminal, input, sym, 0)) return; @@ -2065,7 +2065,7 @@ key_handler(struct window *window, struct input *input, uint32_t time, len = apply_key_map(terminal->key_mode, sym, modifiers, ch); if (len != 0) break; - if (modifiers & WINDOW_MODIFIER_CONTROL) { + if (modifiers & XKB_COMMON_CONTROL_MASK) { if (sym >= '3' && sym <= '7') sym = (sym & 0x1f) + 8; @@ -2076,10 +2076,10 @@ key_handler(struct window *window, struct input *input, uint32_t time, else if (sym == '/') sym = 0x1F; else if (sym == '8' || sym == '?') sym = 0x7F; } else if ((terminal->mode & MODE_ALT_SENDS_ESC) && - (modifiers & WINDOW_MODIFIER_ALT)) + (modifiers & XKB_COMMON_MOD1_MASK)) { ch[len++] = 0x1b; - } else if (modifiers & WINDOW_MODIFIER_ALT) { + } else if (modifiers & XKB_COMMON_MOD1_MASK) { sym = sym | 0x80; } diff --git a/clients/window.c b/clients/window.c index bd7d3929..6ddedaa6 100644 --- a/clients/window.c +++ b/clients/window.c @@ -911,7 +911,7 @@ window_handle_key(void *data, struct wl_input_device *input_device, return; level = 0; - if (input->modifiers & WINDOW_MODIFIER_SHIFT && + if (input->modifiers & XKB_COMMON_SHIFT_MASK && XkbKeyGroupWidth(d->xkb, code, 0) > 1) level = 1; diff --git a/clients/window.h b/clients/window.h index d67aeda9..a333f772 100644 --- a/clients/window.h +++ b/clients/window.h @@ -23,6 +23,7 @@ #ifndef _WINDOW_H_ #define _WINDOW_H_ +#include #include #include @@ -85,14 +86,6 @@ display_flush_cairo_device(struct display *display); void display_run(struct display *d); -enum { - WINDOW_MODIFIER_SHIFT = 0x01, - WINDOW_MODIFIER_LOCK = 0x02, - WINDOW_MODIFIER_CONTROL = 0x04, - WINDOW_MODIFIER_ALT = 0x08, - WINDOW_MODIFIER_MOD2 = 0x10, -}; - enum pointer_type { POINTER_BOTTOM_LEFT, POINTER_BOTTOM_RIGHT,