From a93f2460560a934e8e75cd2822721748da61b645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Dapena=20Paz?= Date: Fri, 13 Jul 2012 16:29:25 +0200 Subject: [PATCH] wayland: implementation of pointer_handle_axis. We translate wayland pointer axis events to GDK smooth scroll events, to implement pointer_handle_axis events. https://bugzilla.gnome.org/show_bug.cgi?id=679986 Signed-off-by: Rob Bradford --- gdk/wayland/gdkdevice-wayland.c | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 82ddb25abc..f1698b3996 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1112,6 +1112,41 @@ pointer_handle_axis (void *data, uint32_t axis, wl_fixed_t value) { + GdkWaylandDevice *device = data; + GdkWaylandDisplay *display = GDK_WAYLAND_DISPLAY (device->display); + GdkEvent *event; + gdouble delta_x, delta_y; + + switch (axis) { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + delta_x = 0; + delta_y = -wl_fixed_to_double (value); + break; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + delta_x = -wl_fixed_to_double (value); + delta_y = 0; + default: + g_return_if_reached (); + } + + device->time = time; + event = gdk_event_new (GDK_SCROLL); + event->scroll.window = g_object_ref (device->pointer_focus); + gdk_event_set_device (event, device->pointer); + event->scroll.time = time; + event->scroll.x = (gdouble) device->surface_x; + event->scroll.y = (gdouble) device->surface_y; + event->scroll.direction = GDK_SCROLL_SMOOTH; + event->scroll.delta_x = delta_x; + event->scroll.delta_y = delta_y; + event->button.state = device->modifiers; + gdk_event_set_screen (event, display->screen); + + GDK_NOTE (EVENTS, + g_message ("scroll %f %f", + event->scroll.delta_x, event->scroll.delta_y)); + + _gdk_wayland_display_deliver_event (device->display, event); } static void