[PATCH 2/3] editor: add support for invoke_action
Pekka Vuorela
pvuorela at iki.fi
Tue Dec 4 12:34:37 PST 2012
On 04.12.2012 00:10, Jan Arne Petersen wrote:
> From: Jan Arne Petersen <jpetersen at openismus.com>
>
> Call invoke_action request when a currently composed word is clicked.
>
> Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
> ---
> clients/editor.c | 52 +++++++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 41 insertions(+), 11 deletions(-)
>
> diff --git a/clients/editor.c b/clients/editor.c
> index e32a639..76847e2 100644
> --- a/clients/editor.c
> +++ b/clients/editor.c
> @@ -633,6 +633,36 @@ text_entry_set_preedit(struct text_entry *entry,
> widget_schedule_redraw(entry->widget);
> }
>
> +static uint32_t
> +text_entry_try_invoke_preedit_action(struct text_entry *entry,
> + int32_t x, int32_t y,
> + uint32_t button,
> + enum wl_pointer_button_state state)
> +{
> + int index, trailing;
> + uint32_t cursor;
> +
> + if (!entry->preedit.text)
> + return 0;
> +
> + pango_layout_xy_to_index(entry->layout,
> + x * PANGO_SCALE, y * PANGO_SCALE,
> + &index, &trailing);
> + cursor = index + trailing;
> +
> + if (cursor < entry->cursor ||
> + cursor > entry->cursor + strlen(entry->preedit.text)) {
> + return 0;
> + }
> +
> + if (state == WL_POINTER_BUTTON_STATE_PRESSED)
> + text_model_invoke_action(entry->model,
> + button,
> + cursor - entry->cursor);
> +
Click would be mouse release, no? That's usually when actions are done
(though normally not for moving cursor).
More information about the wayland-devel
mailing list