From patchwork Sun Jun 16 03:40:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 251652 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 087FA2C0097 for ; Sun, 16 Jun 2013 13:42:38 +1000 (EST) Received: from localhost ([::1]:47478 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uo3rP-0006iZ-SF for incoming@patchwork.ozlabs.org; Sat, 15 Jun 2013 23:42:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33809) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uo3pD-0003Ql-Hg for qemu-devel@nongnu.org; Sat, 15 Jun 2013 23:40:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uo3pC-0005Me-05 for qemu-devel@nongnu.org; Sat, 15 Jun 2013 23:40:19 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44049 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uo3pB-0005MZ-Nm for qemu-devel@nongnu.org; Sat, 15 Jun 2013 23:40:17 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 3B51BA51B7; Sun, 16 Jun 2013 05:40:17 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sun, 16 Jun 2013 05:40:03 +0200 Message-Id: <1371354005-26873-7-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371354005-26873-1-git-send-email-afaerber@suse.de> References: <1371354005-26873-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Anthony Liguori , Brad Hards , Luiz Capitulino , Gerd Hoffmann , Paolo Bonzini , Ludwig Nussel , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH RFC 6/8] monitor: Eliminate global mouse buttons state for mouse_move 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 mouse_button command would save buttons state globally so that move_move command could reuse it for kbd_mouse_event(). Introduce kbd_mouse_move_event() to allow to use new MouseOps::get_buttons_state() to obtain buttons state from the respective mouse. This means that mouse_set will now affect which buttons state is used on mouse_move. Signed-off-by: Andreas Färber --- include/ui/console.h | 1 + monitor.c | 10 ++++------ ui/input.c | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 2ac6403..132591a 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -60,6 +60,7 @@ void qemu_remove_led_event_handler(QEMUPutLEDEntry *entry); void kbd_put_keycode(int keycode); void kbd_put_ledstate(int ledstate); void kbd_mouse_event(int dx, int dy, int dz, int buttons_state); +void kbd_mouse_move_event(int dx, int dy, int dz); /* Does the current mouse generate absolute events */ bool kbd_mouse_is_absolute(void); diff --git a/monitor.c b/monitor.c index 70ae8f5..6816e82 100644 --- a/monitor.c +++ b/monitor.c @@ -1266,8 +1266,6 @@ static void do_sum(Monitor *mon, const QDict *qdict) monitor_printf(mon, "%05d\n", sum); } -static int mouse_button_state; - static void do_mouse_move(Monitor *mon, const QDict *qdict) { int dx, dy, dz; @@ -1277,16 +1275,16 @@ static void do_mouse_move(Monitor *mon, const QDict *qdict) dx = strtol(dx_str, NULL, 0); dy = strtol(dy_str, NULL, 0); dz = 0; - if (dz_str) + if (dz_str) { dz = strtol(dz_str, NULL, 0); - kbd_mouse_event(dx, dy, dz, mouse_button_state); + } + kbd_mouse_move_event(dx, dy, dz); } static void do_mouse_button(Monitor *mon, const QDict *qdict) { int button_state = qdict_get_int(qdict, "button_state"); - mouse_button_state = button_state; - kbd_mouse_event(0, 0, 0, mouse_button_state); + kbd_mouse_event(0, 0, 0, button_state); } static void do_ioport_read(Monitor *mon, const QDict *qdict) diff --git a/ui/input.c b/ui/input.c index 7f1248b..366f3c0 100644 --- a/ui/input.c +++ b/ui/input.c @@ -477,6 +477,20 @@ void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) } } +void kbd_mouse_move_event(int dx, int dy, int dz) +{ + QEMUPutMouseEntry *mouse; + int buttons_state; + + if (QTAILQ_EMPTY(&mouse_handlers)) { + return; + } + mouse = QTAILQ_FIRST(&mouse_handlers); + + buttons_state = mouse->ops->get_buttons_state(mouse->opaque); + kbd_mouse_event(dx, dy, dz, buttons_state); +} + bool kbd_mouse_is_absolute(void) { if (QTAILQ_EMPTY(&mouse_handlers)) {