}
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)
+touch_handler(struct input *input, uint32_t time,
+ float x, float y, uint32_t state, void *data)
{
-
struct keyboard *keyboard = data;
struct rectangle allocation;
int row, col;
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);
+ keyboard_handle_key(keyboard, time,
+ &layout->keys[i], input, state);
break;
}
}
- widget_schedule_redraw(widget);
+ widget_schedule_redraw(keyboard->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)
+{
+ touch_handler(input, time, x, y,
+ WL_POINTER_BUTTON_STATE_PRESSED, data);
}
static void
touch_up_handler(struct widget *widget, struct input *input,
- uint32_t serial, uint32_t time, int32_t id,
- void *data)
+ uint32_t serial, uint32_t time, int32_t id,
+ void *data)
{
+ float x, y;
+
+ input_get_touch(input, id, &x, &y);
+ touch_handler(input, time, x, y,
+ WL_POINTER_BUTTON_STATE_RELEASED, data);
}
static void
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,
layout->rows * key_height);
struct touch_point {
int32_t id;
+ float x, y;
struct widget *widget;
struct wl_list link;
};
if (tp) {
tp->id = id;
tp->widget = widget;
+ tp->x = sx;
+ tp->y = sy;
wl_list_insert(&input->touch_point_list, &tp->link);
if (widget->touch_down_handler)
if (tp->id != id)
continue;
+ tp->x = sx;
+ tp->y = sy;
if (tp->widget->touch_motion_handler)
(*tp->widget->touch_motion_handler)(tp->widget, input, time,
id, sx, sy,
*y = input->sy;
}
+int
+input_get_touch(struct input *input, int32_t id, float *x, float *y)
+{
+ struct touch_point *tp;
+
+ wl_list_for_each(tp, &input->touch_point_list, link) {
+ if (tp->id != id)
+ continue;
+
+ *x = tp->x;
+ *y = tp->y;
+ return 0;
+ }
+
+ return -1;
+}
+
struct display *
input_get_display(struct input *input)
{