[clutter] click-action: add touch event support
- From: Emanuele Aina <emaaa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] click-action: add touch event support
- Date: Thu, 13 Sep 2012 11:15:36 +0000 (UTC)
commit e6fcdb0644d5b5ea73e646aec43967c9a50b39cf
Author: Emanuele Aina <emanuele aina collabora com>
Date: Thu Sep 13 11:20:00 2012 +0200
click-action: add touch event support
Allow for touch events to trigger the "clicked" event on
ClickAction without introducing API changes.
https://bugzilla.gnome.org/show_bug.cgi?id=683936
clutter/clutter-click-action.c | 21 +++++++++++++++++----
1 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/clutter/clutter-click-action.c b/clutter/clutter-click-action.c
index 1692067..3fe164c 100644
--- a/clutter/clutter-click-action.c
+++ b/clutter/clutter-click-action.c
@@ -116,6 +116,8 @@ struct _ClutterClickActionPrivate
gint drag_threshold;
guint press_button;
+ gint press_device_id;
+ ClutterEventSequence *press_sequence;
ClutterModifierType modifier_state;
gfloat press_x;
gfloat press_y;
@@ -277,14 +279,17 @@ on_event (ClutterActor *actor,
ClutterClickAction *action)
{
ClutterClickActionPrivate *priv = action->priv;
+ gboolean has_button = TRUE;
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (action)))
return CLUTTER_EVENT_PROPAGATE;
switch (clutter_event_type (event))
{
+ case CLUTTER_TOUCH_BEGIN:
+ has_button = FALSE;
case CLUTTER_BUTTON_PRESS:
- if (clutter_event_get_click_count (event) != 1)
+ if (has_button && clutter_event_get_click_count (event) != 1)
return CLUTTER_EVENT_PROPAGATE;
if (priv->is_held)
@@ -293,7 +298,9 @@ on_event (ClutterActor *actor,
if (!clutter_actor_contains (actor, clutter_event_get_source (event)))
return CLUTTER_EVENT_PROPAGATE;
- priv->press_button = clutter_event_get_button (event);
+ priv->press_button = has_button ? clutter_event_get_button (event) : 0;
+ priv->press_device_id = clutter_event_get_device_id (event);
+ priv->press_sequence = clutter_event_get_event_sequence (event);
priv->modifier_state = clutter_event_get_state (event);
clutter_event_get_coords (event, &priv->press_x, &priv->press_y);
@@ -344,17 +351,22 @@ on_captured_event (ClutterActor *stage,
ClutterClickActionPrivate *priv = action->priv;
ClutterActor *actor;
ClutterModifierType modifier_state;
+ gboolean has_button = TRUE;
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
switch (clutter_event_type (event))
{
+ case CLUTTER_TOUCH_END:
+ has_button = FALSE;
case CLUTTER_BUTTON_RELEASE:
if (!priv->is_held)
return CLUTTER_EVENT_STOP;
- if (clutter_event_get_button (event) != priv->press_button ||
- clutter_event_get_click_count (event) != 1)
+ if ((has_button && clutter_event_get_button (event) != priv->press_button) ||
+ (has_button && clutter_event_get_click_count (event) != 1) ||
+ clutter_event_get_device_id (event) != priv->press_device_id ||
+ clutter_event_get_event_sequence (event) != priv->press_sequence)
return CLUTTER_EVENT_PROPAGATE;
click_action_set_held (action, FALSE);
@@ -397,6 +409,7 @@ on_captured_event (ClutterActor *stage,
break;
case CLUTTER_MOTION:
+ case CLUTTER_TOUCH_UPDATE:
{
gfloat motion_x, motion_y;
gfloat delta_x, delta_y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]