Re: [spice-gtk][PATCH] session: Get the lock modifiers from GdkKeymap

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

 



Hi

----- Original Message -----
> A cleaner way to get the lock modifiers, without depend on the
> platform/backend used (as X or Wayland), is get them through GdkKeymap
> (and its _get{caps,num,scroll}_lock_state() functions).
> Unfortunately, get_scroll_lock_state() will only be present for Gtk+
> 3.18.0 and when it becomes the minimal required version we can easily
> drop the old code.
> ---
> Depends on https://bugzilla.gnome.org/show_bug.cgi?id=747844

looks good to me, when the gdk bug is accepted, ack

> ---
>  gtk/spice-gtk-session.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
> index de01358..0937434 100644
> --- a/gtk/spice-gtk-session.c
> +++ b/gtk/spice-gtk-session.c
> @@ -122,6 +122,21 @@ enum {
>  static guint32 get_keyboard_lock_modifiers(void)
>  {
>      guint32 modifiers = 0;
> +#if GTK_CHECK_VERSION(3,18,0)
> +    GdkKeymap *keyboard = gdk_keymap_get_default();
> +
> +    if (gdk_keymap_get_caps_lock_state(keyboard)) {
> +        modifiers |= SPICE_INPUTS_CAPS_LOCK;
> +    }
> +
> +    if (gdk_keymap_get_num_lock_state(keyboard)) {
> +        modifiers |= SPICE_INPUTS_NUM_LOCK;
> +    }
> +
> +    if (gdk_keymap_get_scroll_lock_state(keyboard)) {
> +        modifiers |= SPICE_INPUTS_SCROLL_LOCK;
> +    }
> +#else
>  #if HAVE_X11_XKBLIB_H
>      Display *x_display = NULL;
>      XKeyboardState keyboard_state;
> @@ -157,6 +172,7 @@ static guint32 get_keyboard_lock_modifiers(void)
>  #else
>      g_warning("get_keyboard_lock_modifiers not implemented");
>  #endif // HAVE_X11_XKBLIB_H
> +#endif // GTK_CHECK_VERSION(3,18,0)
>      return modifiers;
>  }
>  
> --
> 2.3.5
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
> 
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





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