When multiple keyboards are passed to the guest with input-linux, there
could still be keys pressed on the other keyboard when toggling grab.
Delay toggling grab on the other keyboard until all keys are released,
otherwise keys could be stuck on host without a key up event.

Signed-off-by: Rainer Müller <rai...@codingfarm.de>
---
 ui/input-linux.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ui/input-linux.c b/ui/input-linux.c
index 05c0c98819..47d489d738 100644
--- a/ui/input-linux.c
+++ b/ui/input-linux.c
@@ -89,7 +89,12 @@ static void input_linux_toggle_grab(InputLinux *il)
             continue;
         }
         if (item->grab_active != il->grab_active) {
-            input_linux_toggle_grab(item);
+            if (item->keycount) {
+                /* delay grab until all keys are released */
+                item->grab_request = true;
+            } else {
+                input_linux_toggle_grab(item);
+            }
         }
     }
 }
-- 
2.25.1


Reply via email to