All of lore.kernel.org
 help / color / mirror / Atom feed
From: Soren Hansen <soren@ubuntu.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Let mouse_button monitor command accept coordinates
Date: Wed, 9 Dec 2009 12:07:50 +0100	[thread overview]
Message-ID: <20091209110750.GA12885@linux2go.dk> (raw)

[-- Attachment #1: Type: text/plain, Size: 2588 bytes --]

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.

Signed-off-by: Soren Hansen <soren@canonical.com>
---
 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);
+        if (dz_str)
+            dz = strtol(dz_str, NULL, 0);
+    }
+
     mouse_button_state = button_state;
-    kbd_mouse_event(0, 0, 0, mouse_button_state);
+    kbd_mouse_event(dx, dy, dz, mouse_button_state);
 }
 
 static void do_ioport_read(Monitor *mon, const QDict *qdict)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 2b14802..b42b461 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -595,9 +595,9 @@ ETEXI
 
     {
         .name       = "mouse_button",
-        .args_type  = "button_state:i",
-        .params     = "state",
-        .help       = "change mouse button state (1=L, 2=M, 4=R)",
+        .args_type  = "button_state:i,dx_str:s?,dy_str:s?,dz_str:s?",
+        .params     = "state [dx dy [dz]]",
+        .help       = "change mouse button state (1=L, 2=M, 4=R), optionally specifying coordinates as well (useful for pointers in absolute mode)",
         .mhandler.cmd = do_mouse_button,
     },
 
-- 
1.6.5

-- 
Soren Hansen                 | 
Lead virtualisation engineer | Ubuntu Server Team
Canonical Ltd.               | http://www.ubuntu.com/

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

             reply	other threads:[~2009-12-09 11:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-09 11:07 Soren Hansen [this message]
2010-02-23 21:47 ` [Qemu-devel] [PATCH] Let mouse_button monitor command accept coordinates Aurelien Jarno
2010-02-24  7:45   ` Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091209110750.GA12885@linux2go.dk \
    --to=soren@ubuntu.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.