This patch changes the "do we have focus?" tracking, to keeping a counter with
how many widgets have focus. The reason for this is that sometimes multiple
spice-widgets can have focus at the same time, yes really! Sometimes (rarely,
hard to reproduce) the focus in event for one window arrives before the
focus out of the other windows.

Signed-off-by: Hans de Goede <hdego...@redhat.com>
---
 gtk/spice-gtk-session.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 130cbc9..1d8c888 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -39,7 +39,7 @@ struct _SpiceGtkSessionPrivate {
     gboolean                clipboard_by_guest[CLIPBOARD_LAST];
     /* auto-usbredir related */
     gboolean                auto_usbredir_enable;
-    gboolean                keyboard_focus;
+    int                     keyboard_focus;
 };
 
 /**
@@ -845,7 +845,16 @@ void 
spice_gtk_session_update_keyboard_focus(SpiceGtkSession *self,
     SpiceGtkSessionPrivate *s = self->priv;
     SpiceUsbDeviceManager *manager;
 
-    s->keyboard_focus = state;
+    if (state) {
+        s->keyboard_focus++;
+        if (s->keyboard_focus != 1)
+            return;
+    } else {
+        g_return_if_fail(s->keyboard_focus > 0);
+        s->keyboard_focus--;
+        if (s->keyboard_focus != 0)
+            return;
+    }
 
     if (!s->auto_usbredir_enable)
         return;
-- 
1.7.10.4

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to