[gtk+/wip/wayland-tablet: 5/23] events: Add gdk_event_[gs]et_device_tool()
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/wayland-tablet: 5/23] events: Add gdk_event_[gs]et_device_tool()
- Date: Mon, 22 Jun 2015 17:15:18 +0000 (UTC)
commit 797e1152b1edfb0990d272c5be98c838d2e688b7
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Jan 6 14:52:42 2015 +0100
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.
docs/reference/gdk/gdk3-sections.txt | 2 +
gdk/gdkevents.c | 52 ++++++++++++++++++++++++++++++++++
gdk/gdkevents.h | 7 ++++
gdk/gdkinternals.h | 1 +
4 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 607a10c..b835756 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -853,6 +853,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
diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c
index 3d8d7bc..285f80b 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -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.18
+ **/
+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.18
+ **/
+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;
+}
diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h
index d681de7..b98fae9 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -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__ */
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index e5ec4b2..a3c64eb 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -184,6 +184,7 @@ struct _GdkEventPrivate
gpointer windowing_data;
GdkDevice *device;
GdkDevice *source_device;
+ GdkDeviceTool *tool;
};
typedef struct _GdkWindowPaint GdkWindowPaint;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]