qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] gtk: Add mouse wheel support
@ 2014-03-11 16:26 Jan Kiszka
  2014-03-12  7:21 ` Gerd Hoffmann
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2014-03-11 16:26 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Gerd Hoffmann

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] gtk: Add mouse wheel support
  2014-03-11 16:26 [Qemu-devel] [PATCH] gtk: Add mouse wheel support Jan Kiszka
@ 2014-03-12  7:21 ` Gerd Hoffmann
  0 siblings, 0 replies; 2+ messages in thread
From: Gerd Hoffmann @ 2014-03-12  7:21 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: qemu-devel, Anthony Liguori

On Di, 2014-03-11 at 17:26 +0100, Jan Kiszka wrote:
> Hook into scroll-event to properly forward mouse wheel movements to
> the
> guest, just like we already do in SDL.

Added to input queue.

thanks,
  Gerd

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-03-12  7:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 16:26 [Qemu-devel] [PATCH] gtk: Add mouse wheel support Jan Kiszka
2014-03-12  7:21 ` Gerd Hoffmann

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).