clutter: Refactor ClutterText IM focus in into separate function

A just focused ClutterInputFocus must set itself up correctly on
all situations. Refactor this into a function, so it can be used
for the case where a ClutterText gets editable while focused.
This commit is contained in:
Carlos Garnacho 2018-08-15 16:33:05 +02:00 committed by Florian Müllner
parent e741adb82e
commit fa8930817e

View File

@ -2815,21 +2815,30 @@ clutter_text_has_overlaps (ClutterActor *self)
} }
static void static void
clutter_text_key_focus_in (ClutterActor *actor) clutter_text_im_focus (ClutterText *text)
{ {
ClutterTextPrivate *priv = CLUTTER_TEXT (actor)->priv; ClutterTextPrivate *priv = text->priv;
ClutterBackend *backend = clutter_get_default_backend (); ClutterBackend *backend = clutter_get_default_backend ();
ClutterInputMethod *method = clutter_backend_get_input_method (backend); ClutterInputMethod *method = clutter_backend_get_input_method (backend);
if (method && priv->editable) if (!method)
{ return;
clutter_input_method_focus_in (method, priv->input_focus); clutter_input_method_focus_in (method, priv->input_focus);
clutter_input_focus_set_content_purpose (priv->input_focus, clutter_input_focus_set_content_purpose (priv->input_focus,
priv->input_purpose); priv->input_purpose);
clutter_input_focus_set_content_hints (priv->input_focus, clutter_input_focus_set_content_hints (priv->input_focus,
priv->input_hints); priv->input_hints);
update_cursor_location (CLUTTER_TEXT (actor)); update_cursor_location (text);
} }
static void
clutter_text_key_focus_in (ClutterActor *actor)
{
ClutterTextPrivate *priv = CLUTTER_TEXT (actor)->priv;
if (priv->editable)
clutter_text_im_focus (CLUTTER_TEXT (actor));
priv->has_focus = TRUE; priv->has_focus = TRUE;
@ -4689,7 +4698,7 @@ clutter_text_set_editable (ClutterText *self,
if (!priv->editable && clutter_input_focus_is_focused (priv->input_focus)) if (!priv->editable && clutter_input_focus_is_focused (priv->input_focus))
clutter_input_method_focus_out (method); clutter_input_method_focus_out (method);
else if (priv->has_focus) else if (priv->has_focus)
clutter_input_method_focus_in (method, priv->input_focus); clutter_text_im_focus (self);
} }
clutter_text_queue_redraw (CLUTTER_ACTOR (self)); clutter_text_queue_redraw (CLUTTER_ACTOR (self));