[Spice-devel] [PATCH spice-gtk] win32: implement sync_keyboard_lock_modifiers()

Christophe Fergeau cfergeau at redhat.com
Wed Oct 17 02:20:07 PDT 2012


Looks good, ACK
On Mon, Oct 15, 2012 at 08:57:38PM +0200, Marc-André Lureau wrote:
> Fix numlock numerical keypad being broken:
> https://bugzilla.redhat.com/show_bug.cgi?id=856538
> ---
>  gtk/spice-widget.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/gtk/spice-widget.c b/gtk/spice-widget.c
> index 13d7111..1e1cdb0 100644
> --- a/gtk/spice-widget.c
> +++ b/gtk/spice-widget.c
> @@ -2456,6 +2456,41 @@ static void spice_set_keyboard_lock_modifiers(SpiceDisplay *display, uint32_t mo
>      set_keyboard_led(x_display, NUM_LOCK_LED, !!(modifiers & SPICE_INPUTS_NUM_LOCK));
>      set_keyboard_led(x_display, SCROLL_LOCK_LED, !!(modifiers & SPICE_INPUTS_SCROLL_LOCK));
>  }
> +#elif defined (WIN32)
> +static guint32 get_keyboard_lock_modifiers(void)
> +{
> +    guint32 modifiers = 0;
> +
> +    if (GetKeyState(VK_CAPITAL) & 1) {
> +        modifiers |= SPICE_INPUTS_CAPS_LOCK;
> +    }
> +    if (GetKeyState(VK_NUMLOCK) & 1) {
> +        modifiers |= SPICE_INPUTS_NUM_LOCK;
> +    }
> +    if (GetKeyState(VK_SCROLL) & 1) {
> +        modifiers |= SPICE_INPUTS_SCROLL_LOCK;
> +    }
> +
> +    return modifiers;
> +}
> +
> +static void sync_keyboard_lock_modifiers(SpiceDisplay *display)
> +{
> +    SpiceDisplayPrivate *d = SPICE_DISPLAY_GET_PRIVATE(display);
> +    guint32 modifiers;
> +    GdkWindow *w;
> +
> +    if (d->disable_inputs)
> +        return;
> +
> +    w = gtk_widget_get_parent_window(GTK_WIDGET(display));
> +    if (w == NULL) /* it can happen if the display is not yet shown */
> +        return;
> +
> +    modifiers = get_keyboard_lock_modifiers();
> +    if (d->inputs)
> +        spice_inputs_set_key_locks(d->inputs, modifiers);
> +}
>  #else
>  static void sync_keyboard_lock_modifiers(SpiceDisplay *display)
>  {
> -- 
> 1.7.11.7
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20121017/d3755d1a/attachment.pgp>


More information about the Spice-devel mailing list