[gtk+] gdk: Add delta_x/y to scroll events
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: Add delta_x/y to scroll events
- Date: Thu, 1 Mar 2012 21:32:55 +0000 (UTC)
commit 0efbbc6435a5be7790bfc170e250832507298630
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.
docs/reference/gdk/gdk3-sections.txt | 1 +
gdk/gdk.symbols | 1 +
gdk/gdkevents.c | 48 ++++++++++++++++++++++++++++++++++
gdk/gdkevents.h | 7 +++++
4 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 2e064fe..b46e17e 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -788,6 +788,7 @@ gdk_event_get_keycode
gdk_event_get_keyval
gdk_event_get_root_coords
gdk_event_get_scroll_direction
+gdk_event_get_scroll_deltas
gdk_event_get_state
gdk_event_get_time
GdkEventSequence
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 9552f3e..dff7e34 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -165,6 +165,7 @@ gdk_event_get_keyval
gdk_event_get_root_coords
gdk_event_get_screen
gdk_event_get_scroll_direction
+gdk_event_get_scroll_deltas
gdk_event_get_source_device
gdk_event_get_state
gdk_event_get_time
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 688fec2..7abd956 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -471,6 +471,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:
@@ -1208,6 +1210,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 6aa593a..4c42678 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -759,6 +759,8 @@ struct _GdkEventScroll
GdkScrollDirection direction;
GdkDevice *device;
gdouble x_root, y_root;
+ gdouble delta_x;
+ gdouble delta_y;
};
/**
@@ -1203,6 +1205,11 @@ gboolean gdk_event_get_keycode (const GdkEvent *event,
GDK_AVAILABLE_IN_3_2
gboolean gdk_event_get_scroll_direction (const GdkEvent *event,
GdkScrollDirection *direction);
+GDK_AVAILABLE_IN_3_4
+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]