forked from AuroraMiddleware/gtk
gdk: Add delta_x/y to scroll events
gdk_event_get_scroll_deltas() can be used to retrieve those values on smooth scroll events.
This commit is contained in:
parent
7b48a3c0bd
commit
0efbbc6435
@ -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
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
@ -1207,6 +1209,52 @@ gdk_event_get_scroll_direction (const GdkEvent *event,
|
||||
return fetched;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user