[clutter/wip/evdev-tablet-support: 31/38] event: Add ClutterInputDeviceTool information to clutter events



commit abb82a6124bc7960b3f2f2be7d6922f1c3fdc327
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Feb 4 16:59:22 2015 +0100

    event: Add ClutterInputDeviceTool information to clutter events
    
    These can be used to determine the tool that's being in use for a given event

 clutter/clutter-event.c            |   49 ++++++++++++++++++++++++++++++++++++
 clutter/clutter-event.h            |    7 +++++
 doc/reference/clutter-sections.txt |    2 +
 3 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c
index 2d331f8..0aea9ab 100644
--- a/clutter/clutter-event.c
+++ b/clutter/clutter-event.c
@@ -54,6 +54,8 @@ typedef struct _ClutterEventPrivate {
   gdouble delta_x;
   gdouble delta_y;
 
+  ClutterInputDeviceTool *tool;
+
   gpointer platform_data;
 
   ClutterModifierType button_state;
@@ -1207,6 +1209,52 @@ clutter_event_get_device (const ClutterEvent *event)
 }
 
 /**
+ * clutter_event_set_device_tool:
+ * @event: a #ClutterEvent
+ * @tool: (nullable): a #ClutterInputDeviceTool
+ *
+ * Sets the tool in use for this event
+ *
+ * Since: 1.22
+ **/
+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
+ **/
+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 +1317,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);
diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h
index b04d322..50472b8 100644
--- a/clutter/clutter-event.h
+++ b/clutter/clutter-event.h
@@ -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_1_26
+void                    clutter_event_set_device_tool           (ClutterEvent           *event,
+                                                                 ClutterInputDeviceTool *tool);
+CLUTTER_AVAILABLE_IN_1_26
+ClutterInputDeviceTool *clutter_event_get_device_tool           (const ClutterEvent     *event);
+
 CLUTTER_AVAILABLE_IN_1_8
 void                    clutter_event_set_source                (ClutterEvent           *event,
                                                                  ClutterActor           *actor);
diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt
index 53982e7..5ee4a0a 100644
--- a/doc/reference/clutter-sections.txt
+++ b/doc/reference/clutter-sections.txt
@@ -1144,6 +1144,8 @@ clutter_event_get_gesture_phase
 clutter_event_get_gesture_motion_delta
 clutter_event_get_scroll_source
 clutter_event_get_scroll_finish_flags
+clutter_event_set_device_tool
+clutter_event_get_device_tool
 
 <SUBSECTION>
 clutter_event_get


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