[gtk+/smooth-scrolling: 2/16] gdk: Add delta_x/y to scroll events
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/smooth-scrolling: 2/16] gdk: Add delta_x/y to scroll events
- Date: Tue, 24 Jan 2012 11:26:09 +0000 (UTC)
commit ba0e69f5d80047cf88d1121a59c646dc499a754b
Author: Michael Natterer <mitch lanedo com>
Date: Mon Jan 23 23:37:44 2012 +0100
gdk: Add delta_x/y to scroll events
gdk_event_get_scroll_deltas() can be used to retrieve those
values on smooth scroll events.
gdk/gdkevents.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkevents.h | 6 ++++++
2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 4a5394d..8eee7c6 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -467,6 +467,8 @@ gdk_event_new (GdkEventType type)
new_event->scroll.y = 0.;
new_event->scroll.x_root = 0.;
new_event->scroll.y_root = 0.;
+ new_event->scroll.delta_x = 0.;
+ new_event->scroll.delta_y = 0.;
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
@@ -1220,6 +1222,52 @@ gdk_event_get_scroll_direction (const GdkEvent *event,
}
/**
+ * gdk_event_get_scroll_deltas:
+ * @event: a #GdkEvent
+ * @delta_x: return location for X delta
+ * @delta_y: return location for Y delta
+ *
+ * Retrieves the scroll deltas from a #GdkEvent
+ *
+ * Returns: %TRUE if the event contains smooth scroll information
+ *
+ * Since: 3.4
+ **/
+gboolean
+gdk_event_get_scroll_deltas (const GdkEvent *event,
+ gdouble *delta_x,
+ gdouble *delta_y)
+{
+ gboolean fetched = TRUE;
+ gdouble dx = 0.0;
+ gdouble dy = 0.0;
+
+ switch (event->type)
+ {
+ case GDK_SCROLL:
+ if (event->scroll.direction == GDK_SCROLL_SMOOTH)
+ {
+ dx = event->scroll.delta_x;
+ dy = event->scroll.delta_y;
+ }
+ else
+ fetched = FALSE;
+ break;
+ default:
+ fetched = FALSE;
+ break;
+ }
+
+ if (delta_x)
+ *delta_x = dx;
+
+ if (delta_y)
+ *delta_y = dy;
+
+ return fetched;
+}
+
+/**
* gdk_event_get_axis:
* @event: a #GdkEvent
* @axis_use: the axis use to look for
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index 2f3e9a4..cdce112 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -750,6 +750,8 @@ struct _GdkEventScroll
GdkScrollDirection direction;
GdkDevice *device;
gdouble x_root, y_root;
+ gdouble delta_x;
+ gdouble delta_y;
};
/**
@@ -1189,6 +1191,10 @@ gboolean gdk_event_get_keycode (const GdkEvent *event,
guint16 *keycode);
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
GdkScrollDirection *direction);
+gboolean gdk_event_get_scroll_deltas (const GdkEvent *event,
+ gdouble *delta_x,
+ gdouble *delta_y);
+
gboolean gdk_event_get_axis (const GdkEvent *event,
GdkAxisUse axis_use,
gdouble *value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]