event: Add ClutterInputDeviceTool information to clutter events

These can be used to determine the tool that's being in use for a given event
This commit is contained in:
Carlos Garnacho 2015-02-04 16:59:22 +01:00
parent 8b2c888368
commit 3602b49a30
2 changed files with 58 additions and 0 deletions

View File

@ -54,6 +54,8 @@ typedef struct _ClutterEventPrivate {
gdouble delta_x;
gdouble delta_y;
ClutterInputDeviceTool *tool;
gpointer platform_data;
ClutterModifierType button_state;
@ -1206,6 +1208,54 @@ clutter_event_get_device (const ClutterEvent *event)
return device;
}
/**
* clutter_event_set_device_tool:
* @event: a #ClutterEvent
* @tool: (nullable): a #ClutterInputDeviceTool
*
* Sets the tool in use for this event
*
* Since: 1.28
**/
void
clutter_event_set_device_tool (ClutterEvent *event,
ClutterInputDeviceTool *tool)
{
g_return_if_fail (event != NULL);
if (is_event_allocated (event))
{
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
real_event->tool = tool;
}
}
/**
* clutter_event_get_device_tool:
* @event: a #ClutterEvent
*
* Returns the device tool that originated this event
*
* Returns: (transfer none): The tool of this event
*
* Since: 1.28
**/
ClutterInputDeviceTool *
clutter_event_get_device_tool (const ClutterEvent *event)
{
g_return_val_if_fail (event != NULL, NULL);
if (is_event_allocated (event))
{
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
return real_event->tool;
}
return NULL;
}
/**
* clutter_event_new:
* @type: The type of event.
@ -1269,6 +1319,7 @@ clutter_event_copy (const ClutterEvent *event)
new_real_event->button_state = real_event->button_state;
new_real_event->latched_state = real_event->latched_state;
new_real_event->locked_state = real_event->locked_state;
new_real_event->tool = real_event->tool;
}
device = clutter_event_get_device (event);

View File

@ -575,6 +575,13 @@ void clutter_event_set_source_device (ClutterEvent
CLUTTER_AVAILABLE_IN_1_6
ClutterInputDevice * clutter_event_get_source_device (const ClutterEvent *event);
CLUTTER_AVAILABLE_IN_ALL
void clutter_event_set_device_tool (ClutterEvent *event,
ClutterInputDeviceTool *tool);
CLUTTER_AVAILABLE_IN_ALL
ClutterInputDeviceTool *clutter_event_get_device_tool (const ClutterEvent *event);
CLUTTER_AVAILABLE_IN_1_8
void clutter_event_set_source (ClutterEvent *event,
ClutterActor *actor);