517441d
From 66138b4e5f308cb0a9e93faa8aebf893a30f35ec Mon Sep 17 00:00:00 2001
517441d
From: Adam Williamson <awilliam@redhat.com>
517441d
Date: Fri, 5 Jul 2019 15:06:55 -0700
517441d
Subject: [PATCH] VNC: reverse key order when sending key up events
517441d
517441d
When map_and_send_key maps an input to multiple key presses -
517441d
e.g. a ':' requires a press of shift and a press of ';', or
517441d
when dealing with any input like "ctrl-t" - it gets an array,
517441d
sends a 'down' event for each key in the array, then sends an
517441d
'up' event for each key in the array. So for our ctrl-t example
517441d
it does this:
517441d
517441d
ctrl down
517441d
t down
517441d
ctrl up
517441d
t up
517441d
517441d
This is a bit odd and not how humans normally type. Humans
517441d
would normally hold the modifier key, press and release any
517441d
modified keys they want to press, then release the modifier.
517441d
I've run into one issue previously where this caused a problem,
517441d
which was ultimately fixed in qemu so that os-autoinst's unusual
517441d
key event order worked OK. Now I've run into another:
517441d
517441d
https://bugzilla.redhat.com/show_bug.cgi?id=1727388
517441d
517441d
All the details of that bug are still not worked out, but today
517441d
I *did* work out that changing this key press order avoids that
517441d
bug. By simply reversing the array for the key up events, so we
517441d
do this instead:
517441d
517441d
ctrl down
517441d
t down
517441d
t up
517441d
ctrl up
517441d
517441d
The bug stops happening. Since it's triggered two bugs now, and
517441d
as I said it does not map to how humans type, I think we should
517441d
really go ahead and change this.
517441d
517441d
Signed-off-by: Adam Williamson <awilliam@redhat.com>
517441d
---
517441d
 consoles/VNC.pm | 2 +-
517441d
 1 file changed, 1 insertion(+), 1 deletion(-)
517441d
517441d
diff --git a/consoles/VNC.pm b/consoles/VNC.pm
517441d
index 8eaefe0a..2dfc7a38 100644
517441d
--- a/consoles/VNC.pm
517441d
+++ b/consoles/VNC.pm
517441d
@@ -759,7 +759,7 @@ sub map_and_send_key {
517441d
     }
517441d
     usleep(2_000);
517441d
     if (!defined $down_flag || $down_flag == 0) {
517441d
-        for my $key (@events) {
517441d
+        for my $key (reverse @events) {
517441d
             $self->send_key_event_up($key);
517441d
         }
517441d
     }
517441d
-- 
517441d
2.22.0
517441d