From patchwork Fri Oct 8 10:30:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 67168 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 04B4BB70A5 for ; Fri, 8 Oct 2010 21:58:33 +1100 (EST) Received: from localhost ([127.0.0.1]:45168 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P4ALD-0005vA-SI for incoming@patchwork.ozlabs.org; Fri, 08 Oct 2010 06:38:19 -0400 Received: from [140.186.70.92] (port=45188 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P4AE2-00044G-Jv for qemu-devel@nongnu.org; Fri, 08 Oct 2010 06:33:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P4ADc-0007PQ-4X for qemu-devel@nongnu.org; Fri, 08 Oct 2010 06:30:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29253) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P4ADb-0007P7-UJ for qemu-devel@nongnu.org; Fri, 08 Oct 2010 06:30:28 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o98AUQSF032767 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Oct 2010 06:30:27 -0400 Received: from rincewind.home.kraxel.org (vpn1-5-233.ams2.redhat.com [10.36.5.233]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o98AUMPF016976; Fri, 8 Oct 2010 06:30:24 -0400 Received: by rincewind.home.kraxel.org (Postfix, from userid 500) id 7950C45560; Fri, 8 Oct 2010 12:30:14 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 8 Oct 2010 12:30:13 +0200 Message-Id: <1286533814-1012-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1286533814-1012-1-git-send-email-kraxel@redhat.com> References: <1286533814-1012-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: hdegoede@redhat.com, Gerd Hoffmann Subject: [Qemu-devel] [PATCH 1/2] vmmouse: adapt to mouse handler changes. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch updates the vmmouse handler registration and activation. Old behavior: vmmouse_read_id, vmmouse_request_relative and vmmouse_request_absolute unregister the handler and re-register it. New behavior: vmmouse_request_relative and vmmouse_request_absolute will unregister the handler in case the mode did change. Then register and active the handler with current mode if needed. Note that the old code never ever *activates* the handler, so the vmmouse doesn't receive events. This trips up Fedora 14 for example: Boot a default install without usb tablet, watch the X-Server activating the vmmouse then, enjoy a non-functional mouse. Signed-off-by: Gerd Hoffmann --- hw/vmmouse.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-) diff --git a/hw/vmmouse.c b/hw/vmmouse.c index f359304..2097119 100644 --- a/hw/vmmouse.c +++ b/hw/vmmouse.c @@ -100,16 +100,29 @@ static void vmmouse_mouse_event(void *opaque, int x, int y, int dz, int buttons_ i8042_isa_mouse_fake_event(s->ps2_mouse); } -static void vmmouse_update_handler(VMMouseState *s) +static void vmmouse_remove_handler(VMMouseState *s) { if (s->entry) { qemu_remove_mouse_event_handler(s->entry); s->entry = NULL; } - if (s->status == 0) +} + +static void vmmouse_update_handler(VMMouseState *s, int absolute) +{ + if (s->status != 0) { + return; + } + if (s->absolute != absolute) { + s->absolute = absolute; + vmmouse_remove_handler(s); + } + if (s->entry == NULL) { s->entry = qemu_add_mouse_event_handler(vmmouse_mouse_event, s, s->absolute, "vmmouse"); + qemu_activate_mouse_event_handler(s->entry); + } } static void vmmouse_read_id(VMMouseState *s) @@ -121,28 +134,25 @@ static void vmmouse_read_id(VMMouseState *s) s->queue[s->nb_queue++] = VMMOUSE_VERSION; s->status = 0; - vmmouse_update_handler(s); } static void vmmouse_request_relative(VMMouseState *s) { DPRINTF("vmmouse_request_relative()\n"); - s->absolute = 0; - vmmouse_update_handler(s); + vmmouse_update_handler(s, 0); } static void vmmouse_request_absolute(VMMouseState *s) { DPRINTF("vmmouse_request_absolute()\n"); - s->absolute = 1; - vmmouse_update_handler(s); + vmmouse_update_handler(s, 1); } static void vmmouse_disable(VMMouseState *s) { DPRINTF("vmmouse_disable()\n"); s->status = 0xffff; - vmmouse_update_handler(s); + vmmouse_remove_handler(s); } static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size) @@ -154,7 +164,7 @@ static void vmmouse_data(VMMouseState *s, uint32_t *data, uint32_t size) if (size == 0 || size > 6 || size > s->nb_queue) { printf("vmmouse: driver requested too much data %d\n", size); s->status = 0xffff; - vmmouse_update_handler(s); + vmmouse_remove_handler(s); return; } @@ -239,7 +249,8 @@ static int vmmouse_post_load(void *opaque, int version_id) { VMMouseState *s = opaque; - vmmouse_update_handler(s); + vmmouse_remove_handler(s); + vmmouse_update_handler(s, s->absolute); return 0; }