From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uo3pF-0003Uw-5W for qemu-devel@nongnu.org; Sat, 15 Jun 2013 23:40:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uo3pD-0005NI-Ny for qemu-devel@nongnu.org; Sat, 15 Jun 2013 23:40:21 -0400 Received: from cantor2.suse.de ([195.135.220.15]:44056 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uo3pD-0005N4-El for qemu-devel@nongnu.org; Sat, 15 Jun 2013 23:40:19 -0400 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sun, 16 Jun 2013 05:40:05 +0200 Message-Id: <1371354005-26873-9-git-send-email-afaerber@suse.de> 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH RFC 8/8] monitor: Fix mouse_button command for absolute coordinates List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Brad Hards , Luiz Capitulino , Gerd Hoffmann , Paolo Bonzini , Ludwig Nussel , =?UTF-8?q?Andreas=20F=C3=A4rber?= When using a virtual mouse device with absolute coordinates (tablet) the mouse_button command would raise a mouse event at coordinates (0,0,0), breaking openQA among others. Use a new kbd_mouse_button_event() to obtain the current position with the new MouseOps::get_position() callback when in absolute mode. This allows both switching mice via mouse_set and mixing mouse_move with interactive GUI/VNC mouse movements. Addresses LP#752476 / BNC#813642. Reported-by: Brad Hards Reported-by: Ludwig Nussel Signed-off-by: Andreas F=C3=A4rber --- include/ui/console.h | 1 + monitor.c | 2 +- ui/input.c | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/ui/console.h b/include/ui/console.h index d41dd1d..f912ad6 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -64,6 +64,7 @@ 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); +void kbd_mouse_button_event(int buttons_state); =20 /* Does the current mouse generate absolute events */ bool kbd_mouse_is_absolute(void); diff --git a/monitor.c b/monitor.c index 6816e82..97ca8a8 100644 --- a/monitor.c +++ b/monitor.c @@ -1284,7 +1284,7 @@ static void do_mouse_move(Monitor *mon, const QDict= *qdict) static void do_mouse_button(Monitor *mon, const QDict *qdict) { int button_state =3D qdict_get_int(qdict, "button_state"); - kbd_mouse_event(0, 0, 0, button_state); + kbd_mouse_button_event(button_state); } =20 static void do_ioport_read(Monitor *mon, const QDict *qdict) diff --git a/ui/input.c b/ui/input.c index 366f3c0..a02160d 100644 --- a/ui/input.c +++ b/ui/input.c @@ -491,6 +491,23 @@ void kbd_mouse_move_event(int dx, int dy, int dz) kbd_mouse_event(dx, dy, dz, buttons_state); } =20 +void kbd_mouse_button_event(int buttons_state) +{ + QEMUPutMouseEntry *mouse; + int dx =3D 0, dy =3D 0; + + if (QTAILQ_EMPTY(&mouse_handlers)) { + return; + } + + mouse =3D QTAILQ_FIRST(&mouse_handlers); + if (mouse->absolute && mouse->ops->get_position !=3D NULL) { + mouse->ops->get_position(mouse->opaque, &dx, &dy); + } + + kbd_mouse_event(dx, dy, 0, buttons_state); +} + bool kbd_mouse_is_absolute(void) { if (QTAILQ_EMPTY(&mouse_handlers)) { --=20 1.8.1.4