From 87a800510bcdacfa70fb9cdbdd48558ef3fe8802 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 17 Feb 2023 11:49:33 -0800 Subject: [PATCH] lib: use GDK_SCROLL_SMOOTH to enumlate wheel scroll It's really annoying when a touchpad doesn't work at all in a MKS session. So instead of doing nothing, at least try to send a wheel event so that some amount of scroll may occur. Eventually, we need a real touchpad D-Bus interface to deliver events. --- lib/mks-display-picture.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/mks-display-picture.c b/lib/mks-display-picture.c index 06d7049..e4a2f3d 100644 --- a/lib/mks-display-picture.c +++ b/lib/mks-display-picture.c @@ -355,9 +355,33 @@ mks_display_picture_legacy_event_cb (MksDisplayPicture *self, button = MKS_MOUSE_BUTTON_WHEEL_DOWN; break; + case GDK_SCROLL_SMOOTH: + { + double delta_x; + double delta_y; + + /* + * Currently there is no touchpad D-Bus interface to communicate + * with Qemu. That is something we would very much want to have + * in the future so that we can do this properly. + * + * For now, we just "emulate" scroll events by looking at direction + * and sending that across as wheel events. It's enough to be useful + * but far from what we would really want in the long run. + */ + + gdk_scroll_event_get_deltas (event, &delta_x, &delta_y); + + if (delta_y < 0) + button = MKS_MOUSE_BUTTON_WHEEL_DOWN; + else if (delta_y > 0) + button = MKS_MOUSE_BUTTON_WHEEL_UP; + + break; + } + case GDK_SCROLL_LEFT: case GDK_SCROLL_RIGHT: - case GDK_SCROLL_SMOOTH: default: break; }