summaryrefslogtreecommitdiff
path: root/clients/keyboard.c
diff options
context:
space:
mode:
authorBrian J Lovin <brian.j.lovin@intel.com>2013-08-27 10:49:42 -0700
committerKristian Høgsberg <krh@bitplanet.net>2013-09-03 22:49:16 -0700
commita8e627f4f2890f2903963f9e297cca151c860200 (patch)
treed91906478b36dc085ab553fe90cfb6cae351cdf1 /clients/keyboard.c
parent1f7ce6e3d55ce255187a2a1f07adc778a9108a5f (diff)
keyboard: Add rudimentary touch support to keyboard.
At this time there is no way to have a key be activated when touch_up is called, so all this patch does is activate they key on touch_down. Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
Diffstat (limited to 'clients/keyboard.c')
-rw-r--r--clients/keyboard.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/clients/keyboard.c b/clients/keyboard.c
index a6f7010a..9ee4a848 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -625,6 +625,46 @@ button_handler(struct widget *widget,
}
static void
+touch_down_handler(struct widget *widget, struct input *input,
+ uint32_t serial, uint32_t time, int32_t id,
+ float x, float y, void *data)
+{
+
+ struct keyboard *keyboard = data;
+ struct rectangle allocation;
+ int row, col;
+ unsigned int i;
+ const struct layout *layout;
+
+ layout = get_current_layout(keyboard->keyboard);
+
+ widget_get_allocation(keyboard->widget, &allocation);
+
+ x -= allocation.x;
+ y -= allocation.y;
+
+ row = (int)y / key_height;
+ col = (int)x / key_width + row * layout->columns;
+ for (i = 0; i < layout->count; ++i) {
+ col -= layout->keys[i].width;
+ if (col < 0) {
+ keyboard_handle_key(keyboard, time, &layout->keys[i], input, WL_POINTER_BUTTON_STATE_PRESSED);
+ break;
+ }
+ }
+
+ widget_schedule_redraw(widget);
+}
+
+static void
+touch_up_handler(struct widget *widget, struct input *input,
+ uint32_t serial, uint32_t time, int32_t id,
+ void *data)
+{
+
+}
+
+static void
handle_surrounding_text(void *data,
struct wl_input_method_context *context,
const char *text,
@@ -839,6 +879,9 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
widget_set_redraw_handler(keyboard->widget, redraw_handler);
widget_set_resize_handler(keyboard->widget, resize_handler);
widget_set_button_handler(keyboard->widget, button_handler);
+ widget_set_touch_down_handler(keyboard->widget, touch_down_handler);
+ widget_set_touch_up_handler(keyboard->widget, touch_up_handler);
+
window_schedule_resize(keyboard->window,
layout->columns * key_width,