From 3e472faf5c34211a482b576e4083a640dc8a8d32 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 25 Feb 2019 19:39:14 +0100 Subject: [PATCH] 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 --- src/wayland/meta-wayland-text-input.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c index c65c063a6..d9e1e36b1 100644 --- a/src/wayland/meta-wayland-text-input.c +++ b/src/wayland/meta-wayland-text-input.c @@ -472,31 +472,24 @@ text_input_commit_state (struct wl_client *client, MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); ClutterInputFocus *focus = text_input->input_focus; gboolean enable_panel = FALSE; + ClutterInputMethod *input_method; increment_serial (text_input, resource); if (text_input->surface == NULL) 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 (!clutter_input_focus_is_focused (focus)) - { - if (input_method) - clutter_input_method_focus_in (input_method, focus); - else - return; - } + clutter_input_method_focus_in (input_method, focus); else - { - enable_panel = TRUE; - } + enable_panel = TRUE; clutter_input_focus_set_can_show_preedit (focus, TRUE); }