From d06b256710cf91aec1275785d8cd65283581f544 Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Mon, 31 Mar 2014 11:07:53 -0500 Subject: Use GdkKeymap to listen for keyboard modifier changes Connect to the GdkKeymap::state-changed signal to detect when the client keyboard modifiers have changed. This keeps the client and the guest in sync even when the SpiceDisplay widget isn't focused. New values are only sent down to the guest if the new value is different than the current value. --- gtk/spice-gtk-session.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c index f0f7edf..fe77f47 100644 --- a/gtk/spice-gtk-session.c +++ b/gtk/spice-gtk-session.c @@ -171,6 +171,12 @@ static void spice_gtk_session_sync_keyboard_modifiers_for_channel(SpiceGtkSessio 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; @@ -180,6 +186,7 @@ static void guest_modifiers_changed(SpiceInputsChannel *inputs, gpointer data) static void spice_gtk_session_init(SpiceGtkSession *self) { SpiceGtkSessionPrivate *s; + GdkKeymap *keymap = gdk_keymap_get_default(); s = self->priv = SPICE_GTK_SESSION_GET_PRIVATE(self); @@ -189,6 +196,8 @@ static void spice_gtk_session_init(SpiceGtkSession *self) s->clipboard_primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY); g_signal_connect(G_OBJECT(s->clipboard_primary), "owner-change", G_CALLBACK(clipboard_owner_change), self); + spice_g_signal_connect_object(keymap, "state-changed", + G_CALLBACK(keymap_modifiers_changed), self, 0); } static GObject * -- cgit v1.2.3