Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NkBvy-0004S9-Qo for qemu-devel@nongnu.org; Wed, 24 Feb 2010 02:45:26 -0500 Received: from [199.232.76.173] (port=59420 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NkBvy-0004Rt-3I for qemu-devel@nongnu.org; Wed, 24 Feb 2010 02:45:26 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NkBvw-0001GZ-Ce for qemu-devel@nongnu.org; Wed, 24 Feb 2010 02:45:25 -0500 Received: from mx20.gnu.org ([199.232.41.8]:60753) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NkBvv-0001Fu-Va for qemu-devel@nongnu.org; Wed, 24 Feb 2010 02:45:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NkBvu-0006ex-Gd for qemu-devel@nongnu.org; Wed, 24 Feb 2010 02:45:22 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH] Let mouse_button monitor command accept coordinates References: <20091209110750.GA12885@linux2go.dk> <20100223214746.GE24081@volta.aurel32.net> Date: Wed, 24 Feb 2010 08:45:04 +0100 In-Reply-To: <20100223214746.GE24081@volta.aurel32.net> (Aurelien Jarno's message of "Tue, 23 Feb 2010 22:47:46 +0100") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-devel@nongnu.org, Soren Hansen Aurelien Jarno writes: > On Wed, Dec 09, 2009 at 12:07:50PM +0100, Soren Hansen wrote: >> The mouse_button monitor command currently results in a call like this: >> >> kbd_mouse_event(0, 0, 0, mouse_button_status); >> >> For a pointer in relative mode, this means a button gets pressed (or >> or released) and nothing else. However, if the pointer currently being >> controlled is in absolute mode (such as -usbtablet), it means that the >> pointer will warp to (0, 0), effectively limiting clicking to the top >> left corner of the desktop in the guest. >> >> To work around this, I propose (thanks to Daniel Berrange for the >> suggestion) to let the mouse_button monitor command optionally accept >> coordinates. > > The patch basically looks good, but some minor changes are needed. > Please find my comments below. > >> Signed-off-by: Soren Hansen >> --- >> monitor.c | 16 +++++++++++++++- >> qemu-monitor.hx | 6 +++--- >> 2 files changed, 18 insertions(+), 4 deletions(-) >> >> diff --git a/monitor.c b/monitor.c >> index e161f7d..8b879cc 100644 >> --- a/monitor.c >> +++ b/monitor.c >> @@ -1336,8 +1336,22 @@ static void do_mouse_move(Monitor *mon, const QDict *qdict) >> static void do_mouse_button(Monitor *mon, const QDict *qdict) >> { >> int button_state = qdict_get_int(qdict, "button_state"); >> + int dx, dy, dz; >> + const char *dx_str = qdict_get_try_str(qdict, "dx_str"); >> + const char *dy_str = qdict_get_try_str(qdict, "dy_str"); >> + const char *dz_str = qdict_get_try_str(qdict, "dz_str"); >> + >> + dx = dy = dz = 0; >> + >> + if (dx_str && dy_str) { >> + dx = strtol(dx_str, NULL, 0); >> + dy = strtol(dy_str, NULL, 0); > > I am not sure you should do the conversion here. qdict can directly get > int values. Yes, this is inappropriate for QMP. It's copied from do_mouse_move(), where it's just as inappropriate. There it should look like int dx = (int)qdict_get_int(qdict, "dx_str"); int dy = (int)qdict_get_int(qdict, "dy_str"); int dz = (int)qdict_get_try_int(qdict, "dz_str", 0); >> + if (dz_str) >> + dz = strtol(dz_str, NULL, 0); [...]