[Spice-commits] src/spice-gtk-session.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 10 10:24:22 UTC 2019

 src/spice-gtk-session.c |    8 ++++++++
 1 file changed, 8 insertions(+)

New commits:
commit 15e06eadd0a399a4ddb0c5e1abd0fe0e2af8d096
Author: Olivier Fourdan <ofourdan at redhat.com>
Date:   Mon Apr 8 13:31:57 2019 +0200

    gtk-session: do not sync modifiers when focused
    Spice gtk-session would try to synchronize the modifiers state whenever
    the keymap changes, but doing so is inherently racy.
    While the there is a keyboard grab in effect, all key events are
    forwarded to the guest, hence all modifiers key press get processed by
    the kernel on the guest.
    Trying to synchronize the modifiers will generate additional key press/
    release events which will result in the opposite effect and effectively
    desynchronize the modifier states in the guest.
    Synchronizing modifiers from the host should therefore be limited to
    focus change, as actual press/release events might have occurred without
    the guest knowing. Otherwise, no need to synchronize the modifiers.
    Signed-off-by: Benjamin Tissoires <benjamin.tissoires at redhat.com>
    Signed-off-by: Olivier Fourdan <ofourdan at redhat.com>
    Acked-by: Victor Toso <victortoso at redhat.com>

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index b48f92a..60399d0 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -163,6 +163,14 @@ static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data)
     SpiceGtkSession *self = data;
+    /* set_key_locks() is inherently racy, but no need to sync modifiers
+     * if we have focus as the regular keypress/keyrelease will have set
+     * the expected modifiers state in the guest.
+     */
+    if (self->priv->keyboard_has_focus) {
+        return;
+    }

More information about the Spice-commits mailing list