[gtk+] wayland: implementation of pointer_handle_axis.



commit a93f2460560a934e8e75cd2822721748da61b645
Author: Josà Dapena Paz <jdapena igalia com>
Date:   Fri Jul 13 16:29:25 2012 +0200

    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 <rob linux intel com>

 gdk/wayland/gdkdevice-wayland.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 82ddb25..f1698b3 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]