From: Peter Maydell <peter.maydell@linaro.org>
To: Programmingkid <programmingkidx@gmail.com>
Cc: qemu-devel qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck key situation
Date: Wed, 23 Sep 2015 17:34:57 -0700 [thread overview]
Message-ID: <CAFEAcA_uMarFaJC7BBpN6YNgRnjPErKiXRjPVoiDqJg4WEFRmw@mail.gmail.com> (raw)
In-Reply-To: <C64A20B7-2FCA-4CF0-913F-37B485F230E6@gmail.com>
On 23 September 2015 at 17:17, Programmingkid <programmingkidx@gmail.com> wrote:
> When the user puts QEMU in the background while holding
> down a key, QEMU will not receive the keyup event when
> the user lets go of the key. When the user goes back to
> QEMU, QEMU will think the key is still down causing
> stuck key symptoms. This patch fixes this problem by
> releasing all down keys when QEMU goes into the
> background.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
>
> ---
> Removed the modifiers_state global variable.
> Added a raiseAllKeys method.
>
> ui/cocoa.m | 26 ++++++++++++++++++++++++++
> 1 files changed, 26 insertions(+), 0 deletions(-)
>
> diff --git a/ui/cocoa.m b/ui/cocoa.m
> index 334e6f6..4d15553 100644
> --- a/ui/cocoa.m
> +++ b/ui/cocoa.m
> @@ -304,6 +304,7 @@ static void handleAnyDeviceErrors(Error * err)
> - (float) cdx;
> - (float) cdy;
> - (QEMUScreen) gscreen;
> +- (void) raiseAllKeys;
> @end
>
> QemuCocoaView *cocoaView;
> @@ -798,6 +799,23 @@ QemuCocoaView *cocoaView;
> - (float) cdx {return cdx;}
> - (float) cdy {return cdy;}
> - (QEMUScreen) gscreen {return screen;}
> +
> +/*
> + * Makes the target think all down keys are being released.
> + * This prevents a stuck key problem.
", since we will not see key up events for those keys after we
have lost focus."
> + */
> +- (void) raiseAllKeys
> +{
> + int index;
> + const int max_index = 220; /* This is the highest value key */
No, you need to use ARRAY_SIZE.
> +
> + for (index = 0; index <= max_index; index++) {
> + if (modifiers_state[index]) {
> + modifiers_state[index] = 0;
> + qemu_input_event_send_key_number(dcl->con, index, false);
> + }
> + }
-- PMM
next prev parent reply other threads:[~2015-09-24 0:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-24 0:17 [Qemu-devel] [PATCH v2] ui/cocoa.m: prevent stuck key situation Programmingkid
2015-09-24 0:34 ` Peter Maydell [this message]
2015-09-24 0:44 ` Programmingkid
2015-09-24 0:46 ` Peter Maydell
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=CAFEAcA_uMarFaJC7BBpN6YNgRnjPErKiXRjPVoiDqJg4WEFRmw@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=programmingkidx@gmail.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).