diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2014-04-04 12:40:36 +0200 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2014-04-15 15:51:00 +0200 |
commit | 3d8deef5f365be5078654bfdb916aba2d0025342 (patch) | |
tree | 93ac3a1f69d31226815fe61e8df60b60040b5b16 | |
parent | d961e53da9eee07a4d52301a8330f485843900ce (diff) |
gtk-session: always sync modifiers for client events
The channel state is not synchronous.
It may happen that we want to set and unset quickly a modifier, but the
guest modifier state hasn't been updated yet, and will still be seen as
unset, preventing the last unset change.
-rw-r--r-- | gtk/spice-gtk-session.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c index a83d648..6dc7c93 100644 --- a/gtk/spice-gtk-session.c +++ b/gtk/spice-gtk-session.c @@ -157,32 +157,35 @@ static guint32 get_keyboard_lock_modifiers(void) } static void spice_gtk_session_sync_keyboard_modifiers_for_channel(SpiceGtkSession *self, - SpiceInputsChannel* inputs) + SpiceInputsChannel* inputs, + gboolean force) { gint guest_modifiers = 0, client_modifiers = 0; g_return_if_fail(SPICE_IS_INPUTS_CHANNEL(inputs)); g_object_get(inputs, "key-modifiers", &guest_modifiers, NULL); - client_modifiers = get_keyboard_lock_modifiers(); - CHANNEL_DEBUG(inputs, "client_modifiers:0x%x, guest_modifiers:0x%x", - client_modifiers, guest_modifiers); - if (client_modifiers != guest_modifiers) + if (force || client_modifiers != guest_modifiers) { + CHANNEL_DEBUG(inputs, "client_modifiers:0x%x, guest_modifiers:0x%x", + client_modifiers, guest_modifiers); spice_inputs_set_key_locks(inputs, client_modifiers); + } } static void keymap_modifiers_changed(GdkKeymap *keymap, gpointer data) { SpiceGtkSession *self = data; + spice_gtk_session_sync_keyboard_modifiers(self); } static void guest_modifiers_changed(SpiceInputsChannel *inputs, gpointer data) { SpiceGtkSession *self = data; - spice_gtk_session_sync_keyboard_modifiers_for_channel(self, inputs); + + spice_gtk_session_sync_keyboard_modifiers_for_channel(self, inputs, FALSE); } static void spice_gtk_session_init(SpiceGtkSession *self) @@ -966,7 +969,7 @@ static void channel_new(SpiceSession *session, SpiceChannel *channel, if (SPICE_IS_INPUTS_CHANNEL(channel)) { spice_g_signal_connect_object(channel, "inputs-modifiers", G_CALLBACK(guest_modifiers_changed), self, 0); - spice_gtk_session_sync_keyboard_modifiers_for_channel(self, SPICE_INPUTS_CHANNEL(channel)); + spice_gtk_session_sync_keyboard_modifiers_for_channel(self, SPICE_INPUTS_CHANNEL(channel), TRUE); } } @@ -1133,7 +1136,7 @@ void spice_gtk_session_sync_keyboard_modifiers(SpiceGtkSession *self) for (l = channels; l != NULL; l = l->next) { if (SPICE_IS_INPUTS_CHANNEL(l->data)) { SpiceInputsChannel *inputs = SPICE_INPUTS_CHANNEL(l->data); - spice_gtk_session_sync_keyboard_modifiers_for_channel(self, inputs); + spice_gtk_session_sync_keyboard_modifiers_for_channel(self, inputs, TRUE); } } } |