events: Add gdk_event_[gs]et_device_tool()
This getter/setter will manage the tool pointer in GdkEventPrivate. The setter should be most notably used by backends.
This commit is contained in:
@@ -849,6 +849,8 @@ gdk_event_get_device
|
||||
gdk_event_set_device
|
||||
gdk_event_get_source_device
|
||||
gdk_event_set_source_device
|
||||
gdk_event_get_device_tool
|
||||
gdk_event_set_device_tool
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_setting_get
|
||||
|
||||
@@ -642,6 +642,7 @@ gdk_event_copy (const GdkEvent *event)
|
||||
new_private->screen = private->screen;
|
||||
new_private->device = private->device;
|
||||
new_private->source_device = private->source_device;
|
||||
new_private->tool = private->tool;
|
||||
}
|
||||
|
||||
switch (event->any.type)
|
||||
@@ -2262,3 +2263,54 @@ gdk_event_get_event_type (const GdkEvent *event)
|
||||
|
||||
return event->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_get_device_tool:
|
||||
* @event: a #GdkEvent
|
||||
*
|
||||
* If the event was generated by a device that supports
|
||||
* different tools (eg. a tablet), this function will
|
||||
* return a #GdkDeviceTool representing the tool that
|
||||
* caused the event. Otherwise, %NULL will be returned.
|
||||
*
|
||||
* Note: the #GdkDeviceTool<!-- -->s will be constant during
|
||||
* the application lifetime, if settings must be stored
|
||||
* persistently across runs, see gdk_device_tool_get_serial()
|
||||
*
|
||||
* Returns: The current device tool, or %NULL
|
||||
*
|
||||
* Since: 3.16
|
||||
**/
|
||||
GdkDeviceTool *
|
||||
gdk_event_get_device_tool (const GdkEvent *event)
|
||||
{
|
||||
GdkEventPrivate *private;
|
||||
|
||||
if (!gdk_event_is_allocated (event))
|
||||
return NULL;
|
||||
|
||||
private = (GdkEventPrivate *) event;
|
||||
return private->tool;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_event_set_device_tool:
|
||||
* @event: a #GdkEvent
|
||||
* @tool: (nullable): tool to set on the event, or %NULL
|
||||
*
|
||||
* Sets the device tool for this event, should be rarely used.
|
||||
*
|
||||
* Since: 3.16
|
||||
**/
|
||||
void
|
||||
gdk_event_set_device_tool (GdkEvent *event,
|
||||
GdkDeviceTool *tool)
|
||||
{
|
||||
GdkEventPrivate *private;
|
||||
|
||||
if (!gdk_event_is_allocated (event))
|
||||
return;
|
||||
|
||||
private = (GdkEventPrivate *) event;
|
||||
private->tool = tool;
|
||||
}
|
||||
|
||||
@@ -1309,6 +1309,13 @@ GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_setting_get (const gchar *name,
|
||||
GValue *value);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
GdkDeviceTool *gdk_event_get_device_tool (const GdkEvent *event);
|
||||
|
||||
GDK_AVAILABLE_IN_3_16
|
||||
void gdk_event_set_device_tool (GdkEvent *event,
|
||||
GdkDeviceTool *tool);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GDK_EVENTS_H__ */
|
||||
|
||||
@@ -184,6 +184,7 @@ struct _GdkEventPrivate
|
||||
gpointer windowing_data;
|
||||
GdkDevice *device;
|
||||
GdkDevice *source_device;
|
||||
GdkDeviceTool *tool;
|
||||
};
|
||||
|
||||
typedef struct _GdkWindowPaint GdkWindowPaint;
|
||||
|
||||
Reference in New Issue
Block a user