From patchwork Thu Jan 22 11:32:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 431778 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 0542A14029C for ; Thu, 22 Jan 2015 22:33:44 +1100 (AEDT) Received: from localhost ([::1]:52489 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEG17-0004dZ-LC for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 06:33:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEG0U-0003ey-NO for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:33:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEG0Q-0005p9-Ll for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:33:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40955) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEG0Q-0005oE-Eh for qemu-devel@nongnu.org; Thu, 22 Jan 2015 06:32:58 -0500 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 t0MBWviG019929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 22 Jan 2015 06:32:57 -0500 Received: from nilsson.home.kraxel.org (ovpn-116-36.ams2.redhat.com [10.36.116.36]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MBWunF008923; Thu, 22 Jan 2015 06:32:57 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 99741808AD; Thu, 22 Jan 2015 12:32:55 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 12:32:52 +0100 Message-Id: <1421926373-3734-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1421926373-3734-1-git-send-email-kraxel@redhat.com> References: <1421926373-3734-1-git-send-email-kraxel@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: Gerd Hoffmann , "Dr. David Alan Gilbert" Subject: [Qemu-devel] [PULL 2/3] hid: handle full ptr queues in post_load 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 Cc: Dr. David Alan Gilbert Signed-off-by: Gerd Hoffmann Tested-by: Gonglei Reviewed-by: Gonglei --- hw/input/hid.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/hw/input/hid.c b/hw/input/hid.c index 148c003..ad18555 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -514,6 +514,27 @@ static int hid_post_load(void *opaque, int version_id) HIDState *s = opaque; hid_set_next_idle(s); + + if (s->n == QUEUE_LENGTH && (s->kind == HID_TABLET || + s->kind == HID_MOUSE)) { + /* + * Handle ptr device migration from old qemu with full queue. + * + * Throw away everything but the last event, so we propagate + * at least the current button state to the guest. Also keep + * current position for the tablet, signal "no motion" for the + * mouse. + */ + HIDPointerEvent evt; + evt = s->ptr.queue[(s->head+s->n) & QUEUE_MASK]; + if (s->kind == HID_MOUSE) { + evt.xdx = 0; + evt.ydy = 0; + } + s->ptr.queue[0] = evt; + s->head = 0; + s->n = 1; + } return 0; }