[gtk+/wip/wayland-tablet: 536/555] events: Add gdk_event_[gs]et_device_tool()



commit 978193c30288115a1a9e9a5832d04831575a1455
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 5f5136a..a2757c7 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -888,6 +888,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 2eb249e..0c47bdb 100644
--- a/gdk/gdkevents.c
+++ b/gdk/gdkevents.c
@@ -650,6 +650,7 @@ gdk_event_copy (const GdkEvent *event)
       new_private->device = private->device ? g_object_ref (private->device) : NULL;
       new_private->source_device = private->source_device ? g_object_ref (private->source_device) : NULL;
       new_private->seat = private->seat;
+      new_private->tool = private->tool;
     }
 
   switch (event->any.type)
@@ -2412,3 +2413,54 @@ gdk_event_set_seat (GdkEvent *event,
       priv->seat = seat;
     }
 }
+
+/**
+ * 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.22
+ **/
+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.22
+ **/
+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 a502b27..2588095 100644
--- a/gdk/gdkevents.h
+++ b/gdk/gdkevents.h
@@ -1443,6 +1443,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 2edc204..f68cd99 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -189,6 +189,7 @@ struct _GdkEventPrivate
   GdkDevice *device;
   GdkDevice *source_device;
   GdkSeat   *seat;
+  GdkDeviceTool *tool;
 };
 
 typedef struct _GdkWindowPaint GdkWindowPaint;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]