summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clients/keyboard.c30
-rw-r--r--clients/window.c22
-rw-r--r--clients/window.h3
3 files changed, 46 insertions, 9 deletions
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 9ee4a848..e08a5fa6 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -625,11 +625,9 @@ 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)
+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;
@@ -648,20 +646,35 @@ touch_down_handler(struct widget *widget, struct input *input,
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
@@ -882,7 +895,6 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
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);
diff --git a/clients/window.c b/clients/window.c
index d586244e..be89b641 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -289,6 +289,7 @@ struct widget {
struct touch_point {
int32_t id;
+ float x, y;
struct widget *widget;
struct wl_list link;
};
@@ -3019,6 +3020,8 @@ touch_handle_down(void *data, struct wl_touch *wl_touch,
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)
@@ -3078,6 +3081,8 @@ touch_handle_motion(void *data, struct wl_touch *wl_touch,
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,
@@ -3195,6 +3200,23 @@ input_get_position(struct input *input, int32_t *x, int32_t *y)
*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)
{
diff --git a/clients/window.h b/clients/window.h
index cf8fc6cf..57ff87bf 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -521,6 +521,9 @@ input_set_pointer_image(struct input *input, int pointer);
void
input_get_position(struct input *input, int32_t *x, int32_t *y);
+int
+input_get_touch(struct input *input, int32_t id, float *x, float *y);
+
#define MOD_SHIFT_MASK 0x01
#define MOD_ALT_MASK 0x02
#define MOD_CONTROL_MASK 0x04