mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 19:42:05 +00:00
event: Add accessor for the axes field
CLUTTER_BUTTON_* and CLUTTER_MOTION event types have axes data attached to them, so we want to expose a common ClutterEvent method for extracting that data.
This commit is contained in:
parent
431200f40d
commit
d805237c31
@ -989,3 +989,60 @@ _clutter_event_set_source_device (ClutterEvent *event,
|
||||
real_event = (ClutterEventPrivate *) event;
|
||||
real_event->source_device = device;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_event_get_axes:
|
||||
* @event: a #ClutterEvent
|
||||
* @n_axes: (out): return location for the number of axes returned
|
||||
*
|
||||
* Retrieves the array of axes values attached to the event.
|
||||
*
|
||||
* Return value: (transfer none): an array of axis values
|
||||
*
|
||||
* Since: 1.6
|
||||
*/
|
||||
gdouble *
|
||||
clutter_event_get_axes (const ClutterEvent *event,
|
||||
guint *n_axes)
|
||||
{
|
||||
gdouble *retval = NULL;
|
||||
guint len = 0;
|
||||
|
||||
switch (event->type)
|
||||
{
|
||||
case CLUTTER_NOTHING:
|
||||
case CLUTTER_STAGE_STATE:
|
||||
case CLUTTER_DESTROY_NOTIFY:
|
||||
case CLUTTER_CLIENT_MESSAGE:
|
||||
case CLUTTER_DELETE:
|
||||
case CLUTTER_ENTER:
|
||||
case CLUTTER_LEAVE:
|
||||
case CLUTTER_SCROLL:
|
||||
case CLUTTER_KEY_PRESS:
|
||||
case CLUTTER_KEY_RELEASE:
|
||||
break;
|
||||
|
||||
case CLUTTER_BUTTON_PRESS:
|
||||
case CLUTTER_BUTTON_RELEASE:
|
||||
retval = event->button.axes;
|
||||
break;
|
||||
|
||||
case CLUTTER_MOTION:
|
||||
retval = event->motion.axes;
|
||||
break;
|
||||
}
|
||||
|
||||
if (retval != NULL)
|
||||
{
|
||||
ClutterInputDevice *device;
|
||||
|
||||
device = clutter_event_get_device (event);
|
||||
if (device != NULL)
|
||||
len = clutter_input_device_get_n_axes (device);
|
||||
}
|
||||
|
||||
if (n_axes)
|
||||
*n_axes = len;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -410,6 +410,8 @@ ClutterStage * clutter_event_get_stage (const ClutterEvent
|
||||
void clutter_event_get_coords (const ClutterEvent *event,
|
||||
gfloat *x,
|
||||
gfloat *y);
|
||||
gdouble * clutter_event_get_axes (const ClutterEvent *event,
|
||||
guint *n_axes);
|
||||
|
||||
guint clutter_event_get_key_symbol (const ClutterEvent *event);
|
||||
guint16 clutter_event_get_key_code (const ClutterEvent *event);
|
||||
|
Loading…
Reference in New Issue
Block a user