diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2014-01-07 10:41:50 -0800 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2014-01-07 10:42:41 -0800 |
commit | 966e3ed24770ebe3da9d88907cd404ab61b90fb7 (patch) | |
tree | f64605969a8bf77528e75ab1d4f64f5298ad21bb | |
parent | 917711bd59b089b915a349615d79cbbb2c4ff717 (diff) |
editor: Add missing touch-to-activate for the entries
Closes: https://bugs.freedesktop.org/show_bug.cgi?id=72996
-rw-r--r-- | clients/editor.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/clients/editor.c b/clients/editor.c index b34aafa9..76e2346a 100644 --- a/clients/editor.c +++ b/clients/editor.c @@ -115,6 +115,9 @@ static void text_entry_button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, enum wl_pointer_button_state state, void *data); +static void text_entry_touch_handler(struct widget *widget, struct input *input, + uint32_t serial, uint32_t time, int32_t id, + float tx, float ty, void *data); static int text_entry_motion_handler(struct widget *widget, struct input *input, uint32_t time, float x, float y, void *data); @@ -516,6 +519,7 @@ text_entry_create(struct editor *editor, const char *text) widget_set_redraw_handler(entry->widget, text_entry_redraw_handler); widget_set_button_handler(entry->widget, text_entry_button_handler); widget_set_motion_handler(entry->widget, text_entry_motion_handler); + widget_set_touch_down_handler(entry->widget, text_entry_touch_handler); return entry; } @@ -1078,6 +1082,29 @@ text_entry_button_handler(struct widget *widget, } static void +text_entry_touch_handler(struct widget *widget, struct input *input, + uint32_t serial, uint32_t time, int32_t id, + float tx, float ty, void *data) +{ + struct text_entry *entry = data; + struct wl_seat *seat = input_get_seat(input); + struct rectangle allocation; + struct editor *editor; + int32_t x, y; + + widget_get_allocation(entry->widget, &allocation); + + x = tx - (allocation.x + text_offset_left); + y = ty - (allocation.y + text_offset_left); + + editor = window_get_user_data(entry->window); + text_entry_activate(entry, seat); + editor->active_entry = entry; + + text_entry_set_cursor_position(entry, x, y, true); +} + +static void editor_button_handler(struct widget *widget, struct input *input, uint32_t time, uint32_t button, @@ -1098,6 +1125,19 @@ editor_button_handler(struct widget *widget, } } +static void +editor_touch_handler(struct widget *widget, struct input *input, + uint32_t serial, uint32_t time, int32_t id, + float tx, float ty, void *data) +{ + struct editor *editor = data; + + struct wl_seat *seat = input_get_seat(input); + + text_entry_deactivate(editor->entry, seat); + text_entry_deactivate(editor->editor, seat); + editor->active_entry = NULL; +} static void keyboard_focus_handler(struct window *window, @@ -1250,6 +1290,7 @@ main(int argc, char *argv[]) widget_set_redraw_handler(editor.widget, redraw_handler); widget_set_resize_handler(editor.widget, resize_handler); widget_set_button_handler(editor.widget, editor_button_handler); + widget_set_touch_down_handler(editor.widget, editor_touch_handler); window_schedule_resize(editor.window, 500, 400); |