From: Jan Kiszka <jan.kiszka@siemens.com>
To: Anthony Liguori <aliguori@amazon.com>
Cc: qemu-devel <qemu-devel@nongnu.org>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH] gtk: Add mouse wheel support
Date: Tue, 11 Mar 2014 17:26:44 +0100 [thread overview]
Message-ID: <531F3944.2060101@siemens.com> (raw)
Hook into scroll-event to properly forward mouse wheel movements to the
guest, just like we already do in SDL.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
ui/gtk.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/ui/gtk.c b/ui/gtk.c
index 992f7d7..016804d 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -683,6 +683,27 @@ static gboolean gd_button_event(GtkWidget *widget, GdkEventButton *button,
return TRUE;
}
+static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll,
+ void *opaque)
+{
+ GtkDisplayState *s = opaque;
+ InputButton btn;
+
+ if (scroll->direction == GDK_SCROLL_UP) {
+ btn = INPUT_BUTTON_WHEEL_UP;
+ } else if (scroll->direction == GDK_SCROLL_DOWN) {
+ btn = INPUT_BUTTON_WHEEL_DOWN;
+ } else {
+ return TRUE;
+ }
+
+ qemu_input_queue_btn(s->dcl.con, btn, true);
+ qemu_input_event_sync();
+ qemu_input_queue_btn(s->dcl.con, btn, false);
+ qemu_input_event_sync();
+ return TRUE;
+}
+
static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, void *opaque)
{
GtkDisplayState *s = opaque;
@@ -1229,6 +1250,8 @@ static void gd_connect_signals(GtkDisplayState *s)
G_CALLBACK(gd_button_event), s);
g_signal_connect(s->drawing_area, "button-release-event",
G_CALLBACK(gd_button_event), s);
+ g_signal_connect(s->drawing_area, "scroll-event",
+ G_CALLBACK(gd_scroll_event), s);
g_signal_connect(s->drawing_area, "key-press-event",
G_CALLBACK(gd_key_event), s);
g_signal_connect(s->drawing_area, "key-release-event",
--
1.8.1.1.298.ge7eed54
next reply other threads:[~2014-03-11 16:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-11 16:26 Jan Kiszka [this message]
2014-03-12 7:21 ` [Qemu-devel] [PATCH] gtk: Add mouse wheel support 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=531F3944.2060101@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=aliguori@amazon.com \
--cc=kraxel@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 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.