keyboard: Handle touch up event

This fixes arrow keys which trigger on button up.

Closes: https://bugs.freedesktop.org/show_bug.cgi?id=73169
dev
Kristian Høgsberg 11 years ago
parent 966e3ed247
commit ef9c8eb2db
  1. 30
      clients/keyboard.c
  2. 22
      clients/window.c
  3. 3
      clients/window.h

@ -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);

@ -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)
{

@ -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

Loading…
Cancel
Save