From patchwork Fri Sep 26 08:45:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 393570 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 37F69140143 for ; Fri, 26 Sep 2014 18:46:23 +1000 (EST) Received: from localhost ([::1]:45884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXRAR-0002mo-DS for incoming@patchwork.ozlabs.org; Fri, 26 Sep 2014 04:46:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXRA6-0002U8-BF for qemu-devel@nongnu.org; Fri, 26 Sep 2014 04:46:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XXRA1-0004hV-7B for qemu-devel@nongnu.org; Fri, 26 Sep 2014 04:45:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XXRA0-0004hG-VB for qemu-devel@nongnu.org; Fri, 26 Sep 2014 04:45:53 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8Q8jjYP000514 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 26 Sep 2014 04:45:45 -0400 Received: from air.nay.redhat.com (vpn1-112-225.nay.redhat.com [10.66.112.225]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8Q8jfFT000430; Fri, 26 Sep 2014 04:45:42 -0400 From: Amos Kong To: qemu-devel@nongnu.org Date: Fri, 26 Sep 2014 16:45:41 +0800 Message-Id: <1411721141-7665-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kraxel@redhat.com, aliguori@amazon.com, lcapitulino@redhat.com Subject: [Qemu-devel] [PATCH] ui/input: fix event emitting of repeated combined keys X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Currently we emit press events of combined keys first, then emit release events by reverse order. But it doesn't match with physical keyboard if the keys contain continued & repeated keys. For example, (qemu) sendkey a-b-b Current emited events: (actually the second 'presse b' and 'release b' can't be identified by guest, the interval is too short) press a press b press b release b release b release a Correct events order of physical keyboard: press a press b release b press b release b release a This patch fixed the event order if keys contain continued & repeated keys. This patch based on another sendkey fix: http://lists.nongnu.org/archive/html/qemu-devel/2014-09/msg05149.html Signed-off-by: Amos Kong --- ui/input-legacy.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ui/input-legacy.c b/ui/input-legacy.c index 1e1f14c..e6ea7a2 100644 --- a/ui/input-legacy.c +++ b/ui/input-legacy.c @@ -95,6 +95,14 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time, for (p = keys; p != NULL; p = p->next) { qemu_input_event_send_key(NULL, copy_key_value(p->value), true); qemu_input_event_send_key_delay(hold_time); + + /* release event will be emitted immediately if next key is repeated */ + if (p->next && p->value->kind == p->next->value->kind && + p->value->qcode == p->next->value->qcode) { + qemu_input_event_send_key(NULL, copy_key_value(p->value), false); + qemu_input_event_send_key_delay(hold_time); + } + count++; } while (count--) { @@ -102,8 +110,11 @@ void qmp_send_key(KeyValueList *keys, bool has_hold_time, int64_t hold_time, for (p = keys; p != NULL && i < count; p = p->next) { i++; } - qemu_input_event_send_key(NULL, copy_key_value(p->value), false); - qemu_input_event_send_key_delay(hold_time); + if (!(p->next && p->value->kind == p->next->value->kind && + p->value->qcode == p->next->value->qcode)) { + qemu_input_event_send_key(NULL, copy_key_value(p->value), false); + qemu_input_event_send_key_delay(hold_time); + } } }