From 67cac8a565c3e03567372666c7e83796c6a23114 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 19 Jan 2011 14:20:33 -0500 Subject: [PATCH] Pass input device and time in key_handler callback Move the modifiers to a input device getter function. --- clients/resizor.c | 4 ++-- clients/terminal.c | 12 ++++++++++-- clients/view.c | 4 ++-- clients/window.c | 10 ++++++++-- clients/window.h | 8 ++++++-- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/clients/resizor.c b/clients/resizor.c index cd9bfdc..46d9cbf 100644 --- a/clients/resizor.c +++ b/clients/resizor.c @@ -128,8 +128,8 @@ keyboard_focus_handler(struct window *window, } static void -key_handler(struct window *window, uint32_t key, uint32_t sym, - uint32_t state, uint32_t modifiers, void *data) +key_handler(struct window *window, struct input *input, uint32_t time, + uint32_t key, uint32_t sym, uint32_t state, void *data) { struct resizor *resizor = data; diff --git a/clients/terminal.c b/clients/terminal.c index d3d7a0b..a89a5bf 100644 --- a/clients/terminal.c +++ b/clients/terminal.c @@ -1872,13 +1872,21 @@ terminal_data(struct terminal *terminal, const char *data, size_t length) } static void -key_handler(struct window *window, uint32_t key, uint32_t sym, - uint32_t state, uint32_t modifiers, void *data) +static void +key_handler(struct window *window, struct input *input, uint32_t time, + uint32_t key, uint32_t sym, uint32_t state, void *data) { struct terminal *terminal = data; char ch[MAX_RESPONSE]; + uint32_t modifiers; int len = 0; + modifiers = input_get_modifiers(input); + if ((modifiers & WINDOW_MODIFIER_CONTROL) && + (modifiers & WINDOW_MODIFIER_SHIFT) && + state && handle_bound_key(terminal, input, sym, 0)) + return; + switch (sym) { case XK_F11: if (!state) diff --git a/clients/view.c b/clients/view.c index 5b81c45..db94dca 100644 --- a/clients/view.c +++ b/clients/view.c @@ -110,8 +110,8 @@ redraw_handler(struct window *window, void *data) } static void -key_handler(struct window *window, uint32_t key, uint32_t unicode, - uint32_t state, uint32_t modifiers, void *data) +key_handler(struct window *window, struct input *input, uint32_t time, + uint32_t key, uint32_t unicode, uint32_t state, void *data) { struct view *view = data; diff --git a/clients/window.c b/clients/window.c index 13d7ece..f05405e 100644 --- a/clients/window.c +++ b/clients/window.c @@ -922,8 +922,8 @@ window_handle_key(void *data, struct wl_input_device *input_device, input->modifiers &= ~d->xkb->map->modmap[code]; if (window->key_handler) - (*window->key_handler)(window, key, sym, state, - input->modifiers, window->user_data); + (*window->key_handler)(window, input, time, key, sym, state, + window->user_data); } static void @@ -1014,6 +1014,12 @@ input_get_input_device(struct input *input) return input->input_device; } +uint32_t +input_get_modifiers(struct input *input) +{ + return input->modifiers; +} + struct wl_drag * window_create_drag(struct window *window) { diff --git a/clients/window.h b/clients/window.h index b4457bc..9d6a22a 100644 --- a/clients/window.h +++ b/clients/window.h @@ -110,8 +110,9 @@ typedef void (*window_resize_handler_t)(struct window *window, void *data); typedef void (*window_redraw_handler_t)(struct window *window, void *data); typedef void (*window_frame_handler_t)(struct window *window, uint32_t frame, uint32_t timestamp, void *data); -typedef void (*window_key_handler_t)(struct window *window, uint32_t key, uint32_t unicode, - uint32_t state, uint32_t modifiers, void *data); +typedef void (*window_key_handler_t)(struct window *window, struct input *input, + uint32_t time, uint32_t key, uint32_t unicode, + uint32_t state, void *data); typedef void (*window_keyboard_focus_handler_t)(struct window *window, struct input *device, void *data); @@ -236,6 +237,9 @@ window_activate_drag(struct wl_drag *drag, struct window *window, void input_get_position(struct input *input, int32_t *x, int32_t *y); +uint32_t +input_get_modifiers(struct input *input); + struct wl_input_device * input_get_input_device(struct input *input); -- 2.7.4