[spice-gtk] gtk-session: do not sync modifiers when focused

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Olivier Fourdan <ofourdan@xxxxxxxxxx>

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@xxxxxxxxxx>
Signed-off-by: Olivier Fourdan <ofourdan@xxxxxxxxxx>
---

Merge request spice-gtk!6 or
    https://gitlab.freedesktop.org/spice/spice-gtk/merge_requests/6

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

diff --git a/src/spice-gtk-session.c b/src/spice-gtk-session.c
index b48f92a..65442b2 100644
--- a/src/spice-gtk-session.c
+++ b/src/spice-gtk-session.c
@@ -163,6 +163,13 @@ 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;
+
     spice_gtk_session_sync_keyboard_modifiers(self);
 }
 
-- 
2.20.1

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




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]