From: Dmitry Petrov <dpetroff@gmail.com>
To: qemu-devel@nongnu.org
Cc: Dmitry Petrov <dpetroff@gmail.com>
Subject: [PATCH v2 3/5] ui/gtk: pass horizontal scroll information to the device code
Date: Wed, 22 Dec 2021 02:06:45 +0100 [thread overview]
Message-ID: <20211222010647.1332479-3-dpetroff@gmail.com> (raw)
In-Reply-To: <20211222010647.1332479-1-dpetroff@gmail.com>
Signed-off-by: Dmitry Petrov <dpetroff@gmail.com>
---
ui/gtk.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 42 insertions(+), 12 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 428f02f2df..b52eec6fe9 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -963,33 +963,63 @@ static gboolean gd_scroll_event(GtkWidget *widget, GdkEventScroll *scroll,
void *opaque)
{
VirtualConsole *vc = opaque;
- InputButton btn;
+ InputButton btn_vertical;
+ InputButton btn_horizontal;
+ bool has_vertical = false;
+ bool has_horizontal = false;
if (scroll->direction == GDK_SCROLL_UP) {
- btn = INPUT_BUTTON_WHEEL_UP;
+ btn_vertical = INPUT_BUTTON_WHEEL_UP;
+ has_vertical = true;
} else if (scroll->direction == GDK_SCROLL_DOWN) {
- btn = INPUT_BUTTON_WHEEL_DOWN;
+ btn_vertical = INPUT_BUTTON_WHEEL_DOWN;
+ has_vertical = true;
+ } else if (scroll->direction == GDK_SCROLL_LEFT) {
+ btn_horizontal = INPUT_BUTTON_WHEEL_LEFT;
+ has_horizontal = true;
+ } else if (scroll->direction == GDK_SCROLL_RIGHT) {
+ btn_horizontal = INPUT_BUTTON_WHEEL_RIGHT;
+ has_horizontal = true;
} else if (scroll->direction == GDK_SCROLL_SMOOTH) {
gdouble delta_x, delta_y;
if (!gdk_event_get_scroll_deltas((GdkEvent *)scroll,
&delta_x, &delta_y)) {
return TRUE;
}
- if (delta_y == 0) {
- return TRUE;
- } else if (delta_y > 0) {
- btn = INPUT_BUTTON_WHEEL_DOWN;
+
+ if (delta_y > 0) {
+ btn_vertical = INPUT_BUTTON_WHEEL_DOWN;
+ has_vertical = true;
+ } else if (delta_y < 0) {
+ btn_vertical = INPUT_BUTTON_WHEEL_UP;
+ has_vertical = true;
+ } else if (delta_x > 0) {
+ btn_horizontal = INPUT_BUTTON_WHEEL_RIGHT;
+ has_horizontal = true;
+ } else if (delta_x < 0) {
+ btn_horizontal = INPUT_BUTTON_WHEEL_LEFT;
+ has_horizontal = true;
} else {
- btn = INPUT_BUTTON_WHEEL_UP;
+ return TRUE;
}
} else {
return TRUE;
}
- qemu_input_queue_btn(vc->gfx.dcl.con, btn, true);
- qemu_input_event_sync();
- qemu_input_queue_btn(vc->gfx.dcl.con, btn, false);
- qemu_input_event_sync();
+ if (has_vertical) {
+ qemu_input_queue_btn(vc->gfx.dcl.con, btn_vertical, true);
+ qemu_input_event_sync();
+ qemu_input_queue_btn(vc->gfx.dcl.con, btn_vertical, false);
+ qemu_input_event_sync();
+ }
+
+ if (has_horizontal) {
+ qemu_input_queue_btn(vc->gfx.dcl.con, btn_horizontal, true);
+ qemu_input_event_sync();
+ qemu_input_queue_btn(vc->gfx.dcl.con, btn_horizontal, false);
+ qemu_input_event_sync();
+ }
+
return TRUE;
}
--
2.32.0
next prev parent reply other threads:[~2021-12-22 1:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-22 1:06 [PATCH v2 1/5] ps2: Initial horizontal scroll support Dmitry Petrov
2021-12-22 1:06 ` [PATCH v2 2/5] ui/cocoa: pass horizontal scroll information to the device code Dmitry Petrov
2021-12-22 1:06 ` Dmitry Petrov [this message]
2021-12-22 1:06 ` [PATCH v2 4/5] ui/sdl2: " Dmitry Petrov
2021-12-22 1:06 ` [PATCH v2 5/5] ui/input-legacy: pass horizontal scroll information Dmitry Petrov
2021-12-22 13:10 ` Marc-André Lureau
2021-12-22 13:59 ` [PATCH v2 1/5] ps2: Initial horizontal scroll support Marc-André Lureau
2021-12-22 15:10 ` Dmitry Petrov
2021-12-22 19:50 ` Marc-André Lureau
2022-01-04 13:30 ` Daniel P. Berrangé
2022-01-08 15:42 ` Dmitry Petrov
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=20211222010647.1332479-3-dpetroff@gmail.com \
--to=dpetroff@gmail.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.