diff options
author | Jonathon Jongsma <jjongsma@redhat.com> | 2014-03-31 11:07:53 -0500 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@redhat.com> | 2014-04-03 16:07:25 -0500 |
commit | d06b256710cf91aec1275785d8cd65283581f544 (patch) | |
tree | 72d0c6fb20546774efb250661bca02d234f98977 | |
parent | 9c75c7ee33d8567fef88594ae7844b9121c6291f (diff) |
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.
-rw-r--r-- | gtk/spice-gtk-session.c | 9 |
1 files changed, 9 insertions, 0 deletions
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 * |