clutter: Add ClutterInputDeviceTool:id property

This commit is contained in:
Carlos Garnacho 2016-05-12 17:53:36 +02:00
parent a59170c09f
commit 2e6bfa8bae
2 changed files with 38 additions and 0 deletions

View File

@ -34,12 +34,14 @@ struct _ClutterInputDeviceToolPrivate
{ {
ClutterInputDeviceToolType type; ClutterInputDeviceToolType type;
guint64 serial; guint64 serial;
guint64 id;
}; };
enum { enum {
PROP_0, PROP_0,
PROP_TYPE, PROP_TYPE,
PROP_SERIAL, PROP_SERIAL,
PROP_ID,
PROP_LAST PROP_LAST
}; };
@ -66,6 +68,9 @@ clutter_input_device_tool_set_property (GObject *object,
case PROP_SERIAL: case PROP_SERIAL:
priv->serial = g_value_get_uint64 (value); priv->serial = g_value_get_uint64 (value);
break; break;
case PROP_ID:
priv->id = g_value_get_uint64 (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
} }
@ -90,6 +95,9 @@ clutter_input_device_tool_get_property (GObject *object,
case PROP_SERIAL: case PROP_SERIAL:
g_value_set_uint64 (value, priv->serial); g_value_set_uint64 (value, priv->serial);
break; break;
case PROP_ID:
g_value_set_uint64 (value, priv->id);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
} }
@ -116,6 +124,12 @@ clutter_input_device_tool_class_init (ClutterInputDeviceToolClass *klass)
P_("Tool serial"), P_("Tool serial"),
0, G_MAXUINT64, 0, 0, G_MAXUINT64, 0,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY); CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
props[PROP_ID] =
g_param_spec_uint64 ("id",
P_("Tool ID"),
P_("Tool ID"),
0, G_MAXUINT64, 0,
CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (gobject_class, PROP_LAST, props); g_object_class_install_properties (gobject_class, PROP_LAST, props);
} }
@ -170,3 +184,24 @@ clutter_input_device_tool_get_tool_type (ClutterInputDeviceTool *tool)
return priv->type; return priv->type;
} }
/**
* clutter_input_device_tool_get_id:
* @tool: a #ClutterInputDeviceTool
*
* Gets the ID of this tool, this value can be used to identify a
* physical tool (eg. a tablet pen) across program executions.
*
* Returns: The tool ID for this tool
**/
guint64
clutter_input_device_tool_get_id (ClutterInputDeviceTool *tool)
{
ClutterInputDeviceToolPrivate *priv;
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE_TOOL (tool), 0);
priv = clutter_input_device_tool_get_instance_private (tool);
return priv->id;
}

View File

@ -61,6 +61,9 @@ guint64 clutter_input_device_tool_get_serial (ClutterInput
CLUTTER_AVAILABLE_IN_ALL CLUTTER_AVAILABLE_IN_ALL
ClutterInputDeviceToolType clutter_input_device_tool_get_tool_type (ClutterInputDeviceTool *tool); ClutterInputDeviceToolType clutter_input_device_tool_get_tool_type (ClutterInputDeviceTool *tool);
CLUTTER_AVAILABLE_IN_ALL
guint64 clutter_input_device_tool_get_id (ClutterInputDeviceTool *tool);
G_END_DECLS G_END_DECLS
#endif /* __CLUTTER_INPUT_DEVICE_TOOL_H__ */ #endif /* __CLUTTER_INPUT_DEVICE_TOOL_H__ */