From 459a6bb24c880c21f71c37e99f04e801d117705d Mon Sep 17 00:00:00 2001
From: Emmanuele Bassi <ebassi@linux.intel.com>
Date: Thu, 19 Aug 2010 12:10:43 +0100
Subject: [PATCH] click-action: Add a method to force a release

It can be useful to be able to forcibly break the grab set up by the
ClickAction. The newly added release() method provides a mechanism to
release the grab and unset the :held state of the ClickAction.
---
 clutter/clutter-click-action.c             | 30 ++++++++++++++++++++++
 clutter/clutter-click-action.h             |  3 ++-
 doc/reference/clutter/clutter-sections.txt |  1 +
 3 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/clutter/clutter-click-action.c b/clutter/clutter-click-action.c
index 019df8d3f..4cde0fc32 100644
--- a/clutter/clutter-click-action.c
+++ b/clutter/clutter-click-action.c
@@ -302,3 +302,33 @@ clutter_click_action_new (void)
 {
   return g_object_new (CLUTTER_TYPE_CLICK_ACTION, NULL);
 }
+
+/**
+ * clutter_click_action_release:
+ * @action: a #ClutterClickAction
+ *
+ * Emulates a release of the pointer button, which ungrabs the pointer
+ * and unsets the #ClutterClickAction:pressed state.
+ *
+ * This function is useful to break a grab, for instance after a certain
+ * amount of time has passed.
+ *
+ * Since: 1.4
+ */
+void
+clutter_click_action_force_release (ClutterClickAction *action)
+{
+  ClutterClickActionPrivate *priv;
+
+  g_return_if_fail (CLUTTER_IS_CLICK_ACTION (action));
+
+  priv = action->priv;
+
+  if (!priv->is_held)
+    return;
+
+  priv->is_held = FALSE;
+  clutter_ungrab_pointer ();
+
+  click_action_set_pressed (action, FALSE);
+}
diff --git a/clutter/clutter-click-action.h b/clutter/clutter-click-action.h
index e09ed03bb..1735bf711 100644
--- a/clutter/clutter-click-action.h
+++ b/clutter/clutter-click-action.h
@@ -93,7 +93,8 @@ struct _ClutterClickActionClass
 
 GType clutter_click_action_get_type (void) G_GNUC_CONST;
 
-ClutterAction *clutter_click_action_new (void);
+ClutterAction *clutter_click_action_new     (void);
+void           clutter_click_action_release (ClutterClickAction *action);
 
 G_END_DECLS
 
diff --git a/doc/reference/clutter/clutter-sections.txt b/doc/reference/clutter/clutter-sections.txt
index e7859011c..1de42ca16 100644
--- a/doc/reference/clutter/clutter-sections.txt
+++ b/doc/reference/clutter/clutter-sections.txt
@@ -2346,6 +2346,7 @@ ClutterStatePrivate
 ClutterClickAction
 ClutterClickActionClass
 clutter_click_action_new
+clutter_click_action_release
 
 <SUBSECTION Standard>
 CLUTTER_TYPE_CLICK_ACTION