[Spice-devel] [PATCH v2 2/2] Use GdkKeymap to listen for keyboard modifier changes

Marc-André Lureau mlureau at redhat.com
Wed Apr 2 15:38:24 PDT 2014


ack

----- Original Message -----
> 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 *
> --
> 1.9.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list