qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Rainer Müller" <raimue@codingfarm.de>
To: qemu-devel@nongnu.org
Cc: "Gerd Hoffmann" <kraxel@redhat.com>,
	"Rainer Müller" <raimue@codingfarm.de>
Subject: [PATCH 1/2] input-linux: Delay grab toggle if keys are pressed
Date: Sat,  1 May 2021 21:06:21 +0200	[thread overview]
Message-ID: <20210501190622.153901-2-raimue@codingfarm.de> (raw)
In-Reply-To: <20210501190622.153901-1-raimue@codingfarm.de>

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 <raimue@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	other threads:[~2021-05-01 19:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01 19:06 [PATCH 0/2] input-linux: Allow to toggle grab from QMP Rainer Müller
2021-05-01 19:06 ` Rainer Müller [this message]
2021-05-04  9:14   ` [PATCH 1/2] input-linux: Delay grab toggle if keys are pressed Gerd Hoffmann
2021-05-09 11:43     ` Rainer Müller
2021-05-10  7:30       ` Gerd Hoffmann
2021-05-01 19:06 ` [PATCH 2/2] input-linux: Allow to toggle grab from QMP Rainer Müller
2021-05-04  9:17   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210501190622.153901-2-raimue@codingfarm.de \
    --to=raimue@codingfarm.de \
    --cc=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).