[Spice-commits] src/spice-widget.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Wed Jul 27 10:25:26 UTC 2016


 src/spice-widget.c |   29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

New commits:
commit 9b82e92a69bbd00424f395abdb02a13875ca4849
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Mon Jul 25 21:58:47 2016 +0100

    Handle pause key correctly
    
    Windows does not like Pause key sent with same scancodes as Break.
    Although is the same physical key the two functions send two completely
    different set of codes. On key press a E1 1D 45 sequence is generated
    while on key release a E1 9D C5 is generated. Also some hardware
    keyboards send press+release at the same time on key press (nothing on
    release).
    Tested with Linux and Windows clients.
    Tested with Linux, Windows and DOS guests.
    On Windows guest VK_PAUSE was not arriving correctly.
    
    An additional send_pause function was added to avoid to change the
    normal flow too much. This as the keymap table (generated from
    src/keymaps.csv) can hold only one scancode while this key generate two
    scancodes (ie E1-1D and 45) for each event.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/src/spice-widget.c b/src/spice-widget.c
index c7dd553..9020b07 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1286,6 +1286,25 @@ static gboolean key_press_delayed(gpointer data)
     return FALSE;
 }
 
+static bool send_pause(SpiceDisplay *display, GdkEventType type)
+{
+    SpiceInputsChannel *inputs = display->priv->inputs;
+
+    /* Send proper scancodes. This will send same scancodes
+     * as hardware.
+     * The 0x21d is a sort of Third-Ctrl while
+     * 0x45 is the NumLock.
+     */
+    if (type == GDK_KEY_PRESS) {
+        spice_inputs_key_press(inputs, 0x21d);
+        spice_inputs_key_press(inputs, 0x45);
+    } else {
+        spice_inputs_key_release(inputs, 0x21d);
+        spice_inputs_key_release(inputs, 0x45);
+    }
+    return true;
+}
+
 static void send_key(SpiceDisplay *display, int scancode, SendKeyType type, gboolean press_delayed)
 {
     SpiceDisplayPrivate *d = display->priv;
@@ -1479,6 +1498,16 @@ static gboolean key_event(GtkWidget *widget, GdkEventKey *key)
     if (!d->inputs)
         return true;
 
+    if (key->keyval == GDK_KEY_Pause
+#ifdef G_OS_WIN32
+        /* for some reason GDK does not fill keyval for VK_PAUSE 
+         * See https://bugzilla.gnome.org/show_bug.cgi?id=769214
+         */
+        || key->hardware_keycode == VK_PAUSE
+#endif
+        ) {
+        return send_pause(display, key->type);
+    }
     if (!scancode)
         scancode = vnc_display_keymap_gdk2xtkbd(d->keycode_map, d->keycode_maplen,
                                                 key->hardware_keycode);


More information about the Spice-commits mailing list