wayland: Minor refactor

We use the input_method on both branches, but only check for its existence
when enabling the text_input. The case of focusing out shouldn't happen in
practice as we couldn't have focused in ever before, but still make the
check one level above so it's clearer that the text_input's IM focus cannot
be enabled without an IM implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/432
This commit is contained in:
Carlos Garnacho 2019-02-25 19:39:14 +01:00 committed by Carlos Garnacho
parent eabb789381
commit 3e472faf5c

View File

@ -472,31 +472,24 @@ text_input_commit_state (struct wl_client *client,
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource);
ClutterInputFocus *focus = text_input->input_focus; ClutterInputFocus *focus = text_input->input_focus;
gboolean enable_panel = FALSE; gboolean enable_panel = FALSE;
ClutterInputMethod *input_method;
increment_serial (text_input, resource); increment_serial (text_input, resource);
if (text_input->surface == NULL) if (text_input->surface == NULL)
return; return;
if (text_input->pending_state & META_WAYLAND_PENDING_STATE_ENABLED) input_method = clutter_backend_get_input_method (clutter_get_default_backend ());
if (input_method &&
text_input->pending_state & META_WAYLAND_PENDING_STATE_ENABLED)
{ {
ClutterInputMethod *input_method;
input_method = clutter_backend_get_input_method (clutter_get_default_backend ());
if (text_input->enabled) if (text_input->enabled)
{ {
if (!clutter_input_focus_is_focused (focus)) if (!clutter_input_focus_is_focused (focus))
{ clutter_input_method_focus_in (input_method, focus);
if (input_method)
clutter_input_method_focus_in (input_method, focus);
else
return;
}
else else
{ enable_panel = TRUE;
enable_panel = TRUE;
}
clutter_input_focus_set_can_show_preedit (focus, TRUE); clutter_input_focus_set_can_show_preedit (focus, TRUE);
} }