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>
dev
Brian J Lovin 11 years ago committed by Kristian Høgsberg
parent 1f7ce6e3d5
commit a8e627f4f2
  1. 43
      clients/keyboard.c

@ -624,6 +624,46 @@ button_handler(struct widget *widget,
widget_schedule_redraw(widget); widget_schedule_redraw(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 static void
handle_surrounding_text(void *data, handle_surrounding_text(void *data,
struct wl_input_method_context *context, struct wl_input_method_context *context,
@ -839,6 +879,9 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
widget_set_redraw_handler(keyboard->widget, redraw_handler); widget_set_redraw_handler(keyboard->widget, redraw_handler);
widget_set_resize_handler(keyboard->widget, resize_handler); widget_set_resize_handler(keyboard->widget, resize_handler);
widget_set_button_handler(keyboard->widget, button_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, window_schedule_resize(keyboard->window,
layout->columns * key_width, layout->columns * key_width,

Loading…
Cancel
Save