[Spice-devel] [spice-gtk v2] Handle pause key correctly
Frediano Ziglio
fziglio at redhat.com
Tue Jul 26 12:32:55 UTC 2016
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.
Tested with Linux and Windows clients.
Tested with Linux, Windows and DOS guests.
On Windows guest VK_PAUSE was not arriving correctly.
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
src/spice-widget.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
Changes from v1:
- fixed typo in commit message;
- separate press from release, seems that some HW keyboard
send them separately.
diff --git a/src/spice-widget.c b/src/spice-widget.c
index c7dd553..6c00563 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,14 @@ 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 */
+ || 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);
--
2.7.4
More information about the Spice-devel
mailing list