clutter: Pass anchor position to ClutterInputFocus
Some implementations may need this (namely, the one that drives the Wayland protocol), so pass this along from the IM events. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2517>
This commit is contained in:
parent
190301f66b
commit
ffac294520
5 changed files with 16 additions and 9 deletions
|
@ -35,6 +35,7 @@ void clutter_input_focus_request_surrounding (ClutterInputFocus *focus);
|
|||
|
||||
void clutter_input_focus_set_preedit_text (ClutterInputFocus *focus,
|
||||
const gchar *preedit,
|
||||
guint cursor);
|
||||
unsigned int cursor,
|
||||
unsigned int anchor);
|
||||
|
||||
#endif /* __CLUTTER_INPUT_FOCUS_PRIVATE_H__ */
|
||||
|
|
|
@ -108,7 +108,7 @@ clutter_input_focus_reset (ClutterInputFocus *focus)
|
|||
if (priv->mode == CLUTTER_PREEDIT_RESET_COMMIT)
|
||||
clutter_input_focus_commit (focus, priv->preedit);
|
||||
|
||||
clutter_input_focus_set_preedit_text (focus, NULL, 0);
|
||||
clutter_input_focus_set_preedit_text (focus, NULL, 0, 0);
|
||||
g_clear_pointer (&priv->preedit, g_free);
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,8 @@ clutter_input_focus_filter_event (ClutterInputFocus *focus,
|
|||
priv->preedit = g_strdup (event->im.text);
|
||||
priv->mode = event->im.mode;
|
||||
clutter_input_focus_set_preedit_text (focus, event->im.text,
|
||||
event->im.offset);
|
||||
event->im.offset,
|
||||
event->im.anchor);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -290,9 +291,11 @@ clutter_input_focus_request_surrounding (ClutterInputFocus *focus)
|
|||
void
|
||||
clutter_input_focus_set_preedit_text (ClutterInputFocus *focus,
|
||||
const gchar *preedit,
|
||||
guint cursor)
|
||||
unsigned int cursor,
|
||||
unsigned int anchor)
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_INPUT_FOCUS (focus));
|
||||
|
||||
CLUTTER_INPUT_FOCUS_GET_CLASS (focus)->set_preedit_text (focus, preedit, cursor);
|
||||
CLUTTER_INPUT_FOCUS_GET_CLASS (focus)->set_preedit_text (focus, preedit,
|
||||
cursor, anchor);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,8 @@ struct _ClutterInputFocusClass
|
|||
|
||||
void (* set_preedit_text) (ClutterInputFocus *focus,
|
||||
const gchar *preedit,
|
||||
guint cursor);
|
||||
guint cursor,
|
||||
guint anchor);
|
||||
};
|
||||
|
||||
CLUTTER_EXPORT
|
||||
|
|
|
@ -398,7 +398,8 @@ clutter_text_input_focus_commit_text (ClutterInputFocus *focus,
|
|||
static void
|
||||
clutter_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
|
||||
const gchar *preedit_text,
|
||||
guint cursor_pos)
|
||||
unsigned int cursor_pos,
|
||||
unsigned int anchor_pos)
|
||||
{
|
||||
ClutterText *clutter_text = CLUTTER_TEXT_INPUT_FOCUS (focus)->text;
|
||||
|
||||
|
|
|
@ -248,7 +248,8 @@ meta_wayland_text_input_focus_commit_text (ClutterInputFocus *focus,
|
|||
static void
|
||||
meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
|
||||
const gchar *text,
|
||||
guint cursor)
|
||||
unsigned int cursor,
|
||||
unsigned int anchor)
|
||||
{
|
||||
MetaWaylandTextInput *text_input;
|
||||
gsize pos = 0;
|
||||
|
@ -265,7 +266,7 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
|
|||
pos = g_utf8_offset_to_pointer (text, cursor) - text;
|
||||
|
||||
text_input->preedit.cursor = pos;
|
||||
text_input->preedit.anchor = pos;
|
||||
text_input->preedit.anchor = anchor;
|
||||
text_input->preedit.changed = TRUE;
|
||||
|
||||
meta_wayland_text_input_focus_defer_done (focus);
|
||||
|
|
Loading…
Reference in a new issue