qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
	"Brad Hards" <bradh@frogmouth.net>,
	"Luiz Capitulino" <lcapitulino@redhat.com>,
	"Gerd Hoffmann" <kraxel@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Ludwig Nussel" <lnussel@suse.de>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PATCH RFC 6/8] monitor: Eliminate global mouse buttons state for mouse_move
Date: Sun, 16 Jun 2013 05:40:03 +0200	[thread overview]
Message-ID: <1371354005-26873-7-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1371354005-26873-1-git-send-email-afaerber@suse.de>

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 <afaerber@suse.de>
---
 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)) {
-- 
1.8.1.4

  parent reply	other threads:[~2013-06-16  3:40 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-16  3:39 [Qemu-devel] [PATCH RFC 0/8] monitor: Fix mouse_button and improve mouse_move commands Andreas Färber
2013-06-16  3:39 ` [Qemu-devel] [PATCH RFC 1/8] ui/input: Clean up QEMUPutMouseEntry struct Andreas Färber
2013-06-17  7:17   ` Gerd Hoffmann
2013-06-16  3:39 ` [Qemu-devel] [PATCH RFC 2/8] ui/input: Simplify kbd_mouse_event() Andreas Färber
2013-06-17  7:17   ` Gerd Hoffmann
2013-06-16  3:40 ` [Qemu-devel] [PATCH RFC 3/8] ui/input: Use bool for qemu_add_mouse_event_handler() Andreas Färber
2013-06-16  3:40 ` [Qemu-devel] [PATCH RFC 4/8] ui/input: Introduce MouseOps " Andreas Färber
2013-06-17  7:20   ` Gerd Hoffmann
2013-06-16  3:40 ` [Qemu-devel] [PATCH RFC 5/8] ui/input: Introduce MouseOps::get_buttons_state() Andreas Färber
2013-06-16  3:40 ` Andreas Färber [this message]
2013-06-16  3:40 ` [Qemu-devel] [PATCH RFC 7/8] ui/input: Introduce MouseOps::get_position() Andreas Färber
2013-06-16  3:40 ` [Qemu-devel] [PATCH RFC 8/8] monitor: Fix mouse_button command for absolute coordinates Andreas Färber
2013-06-17  7:16 ` [Qemu-devel] [PATCH RFC 0/8] monitor: Fix mouse_button and improve mouse_move commands Gerd Hoffmann

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=1371354005-26873-7-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=aliguori@us.ibm.com \
    --cc=bradh@frogmouth.net \
    --cc=kraxel@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=lnussel@suse.de \
    --cc=pbonzini@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).