From 49fea735aa6e8ca70927c69c15bc9615d8f0f3b2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
Date: Tue, 23 Oct 2018 14:13:33 +0200
Subject: [PATCH] wayland/text-input: Ignore text-input state commit when not
 focused

We might unset focus, or already be out of focus (e.g. an X11 client or
clutter text entry is focused) when a text-input state is committed by
the client. We handled this before, except when text input was
explicitly disabled by the client, the Wayland text-input was in focus
by the input method, and it focused itself out.

Simplify the logic a bit by just dropping the state on the floor in all
cases where after any potential focus changes were done, we are not
focused.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/353
---
 src/wayland/meta-wayland-text-input.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/wayland/meta-wayland-text-input.c b/src/wayland/meta-wayland-text-input.c
index 8681430217..5bf06e2e08 100644
--- a/src/wayland/meta-wayland-text-input.c
+++ b/src/wayland/meta-wayland-text-input.c
@@ -503,7 +503,8 @@ text_input_commit_state (struct wl_client   *client,
           clutter_input_method_focus_out (input_method);
         }
     }
-  else if (!clutter_input_focus_is_focused (focus))
+
+  if (!clutter_input_focus_is_focused (focus))
     return;
 
   if (text_input->pending_state & META_WAYLAND_PENDING_STATE_CONTENT_TYPE)
-- 
2.19.1

