From 54e2657cb0265c70f82249c83962901a6492d863 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Wed, 12 Feb 2014 17:36:43 +0100 Subject: [PATCH] GestureActions: Set threshold-trigger-edge at right time It was set during the _init(), and swiftly overridden with the default value in construct. Do it in constructed() instead. https://bugzilla.gnome.org/show_bug.cgi?id=724242 --- clutter/clutter-pan-action.c | 15 ++++++++++----- clutter/clutter-rotate-action.c | 14 +++++++++++++- clutter/clutter-swipe-action.c | 14 +++++++++++--- clutter/clutter-tap-action.c | 13 +++++++++++-- clutter/clutter-zoom-action.c | 11 ++++++++++- 5 files changed, 55 insertions(+), 12 deletions(-) diff --git a/clutter/clutter-pan-action.c b/clutter/clutter-pan-action.c index 63c311874..a1f61240d 100644 --- a/clutter/clutter-pan-action.c +++ b/clutter/clutter-pan-action.c @@ -386,6 +386,15 @@ clutter_pan_action_get_property (GObject *gobject, } } +static void +clutter_pan_action_constructed (GObject *gobject) +{ + ClutterGestureAction *gesture; + + gesture = CLUTTER_GESTURE_ACTION (gobject); + clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_AFTER); +} + static void clutter_pan_action_dispose (GObject *gobject) { @@ -498,6 +507,7 @@ clutter_pan_action_class_init (ClutterPanActionClass *klass) 1.0, G_MAXDOUBLE, default_acceleration_factor, CLUTTER_PARAM_READWRITE); + gobject_class->constructed = clutter_pan_action_constructed; gobject_class->set_property = clutter_pan_action_set_property; gobject_class->get_property = clutter_pan_action_get_property; gobject_class->dispose = clutter_pan_action_dispose; @@ -557,15 +567,10 @@ clutter_pan_action_class_init (ClutterPanActionClass *klass) static void clutter_pan_action_init (ClutterPanAction *self) { - ClutterGestureAction *gesture; - self->priv = clutter_pan_action_get_instance_private (self); self->priv->deceleration_rate = default_deceleration_rate; self->priv->acceleration_factor = default_acceleration_factor; self->priv->state = PAN_STATE_INACTIVE; - - gesture = CLUTTER_GESTURE_ACTION (self); - clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_AFTER); } /** diff --git a/clutter/clutter-rotate-action.c b/clutter/clutter-rotate-action.c index d46d4ffef..7286c2b08 100644 --- a/clutter/clutter-rotate-action.c +++ b/clutter/clutter-rotate-action.c @@ -172,14 +172,27 @@ clutter_rotate_action_gesture_cancel (ClutterGestureAction *action, &retval); } +static void +clutter_rotate_action_constructed (GObject *gobject) +{ + ClutterGestureAction *gesture; + + gesture = CLUTTER_GESTURE_ACTION (gobject); + clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_NONE); +} + static void clutter_rotate_action_class_init (ClutterRotateActionClass *klass) { ClutterGestureActionClass *gesture_class = CLUTTER_GESTURE_ACTION_CLASS (klass); + GObjectClass *object_class = + G_OBJECT_CLASS (klass); klass->rotate = clutter_rotate_action_real_rotate; + object_class->constructed = clutter_rotate_action_constructed; + gesture_class->gesture_begin = clutter_rotate_action_gesture_begin; gesture_class->gesture_progress = clutter_rotate_action_gesture_progress; gesture_class->gesture_cancel = clutter_rotate_action_gesture_cancel; @@ -221,7 +234,6 @@ clutter_rotate_action_init (ClutterRotateAction *self) gesture = CLUTTER_GESTURE_ACTION (self); clutter_gesture_action_set_n_touch_points (gesture, 2); - clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_NONE); } /** diff --git a/clutter/clutter-swipe-action.c b/clutter/clutter-swipe-action.c index da1aab3d6..cac619929 100644 --- a/clutter/clutter-swipe-action.c +++ b/clutter/clutter-swipe-action.c @@ -178,11 +178,22 @@ clutter_swipe_action_real_swipe (ClutterSwipeAction *action, return TRUE; } +static void +clutter_swipe_action_constructed (GObject *object) +{ + clutter_gesture_action_set_threshold_trigger_edge (CLUTTER_GESTURE_ACTION (object), + CLUTTER_GESTURE_TRIGGER_EDGE_AFTER); +} + static void clutter_swipe_action_class_init (ClutterSwipeActionClass *klass) { ClutterGestureActionClass *gesture_class = CLUTTER_GESTURE_ACTION_CLASS (klass); + GObjectClass *object_class = + G_OBJECT_CLASS (klass); + + object_class->constructed = clutter_swipe_action_constructed; gesture_class->gesture_begin = gesture_begin; gesture_class->gesture_progress = gesture_progress; @@ -246,9 +257,6 @@ static void clutter_swipe_action_init (ClutterSwipeAction *self) { self->priv = clutter_swipe_action_get_instance_private (self); - - clutter_gesture_action_set_threshold_trigger_edge (CLUTTER_GESTURE_ACTION (self), - CLUTTER_GESTURE_TRIGGER_EDGE_AFTER); } /** diff --git a/clutter/clutter-tap-action.c b/clutter/clutter-tap-action.c index d67698096..4d30eb129 100644 --- a/clutter/clutter-tap-action.c +++ b/clutter/clutter-tap-action.c @@ -91,11 +91,22 @@ gesture_end (ClutterGestureAction *gesture, emit_tap (CLUTTER_TAP_ACTION (gesture), actor); } +static void +clutter_tap_action_constructed (GObject *object) +{ + clutter_gesture_action_set_threshold_trigger_edge (CLUTTER_GESTURE_ACTION (object), + CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE); +} + static void clutter_tap_action_class_init (ClutterTapActionClass *klass) { ClutterGestureActionClass *gesture_class = CLUTTER_GESTURE_ACTION_CLASS (klass); + GObjectClass *object_class = + G_OBJECT_CLASS (klass); + + object_class->constructed = clutter_tap_action_constructed; gesture_class->gesture_end = gesture_end; @@ -122,8 +133,6 @@ clutter_tap_action_class_init (ClutterTapActionClass *klass) static void clutter_tap_action_init (ClutterTapAction *self) { - clutter_gesture_action_set_threshold_trigger_edge (CLUTTER_GESTURE_ACTION (self), - CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE); } /** diff --git a/clutter/clutter-zoom-action.c b/clutter/clutter-zoom-action.c index 36d2de0b1..4e844a95a 100644 --- a/clutter/clutter-zoom-action.c +++ b/clutter/clutter-zoom-action.c @@ -326,6 +326,15 @@ clutter_zoom_action_dispose (GObject *gobject) G_OBJECT_CLASS (clutter_zoom_action_parent_class)->dispose (gobject); } +static void +clutter_zoom_action_constructed (GObject *gobject) +{ + ClutterGestureAction *gesture; + + gesture = CLUTTER_GESTURE_ACTION (gobject); + clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_NONE); +} + static void clutter_zoom_action_class_init (ClutterZoomActionClass *klass) { @@ -333,6 +342,7 @@ clutter_zoom_action_class_init (ClutterZoomActionClass *klass) CLUTTER_GESTURE_ACTION_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + gobject_class->constructed = clutter_zoom_action_constructed; gobject_class->set_property = clutter_zoom_action_set_property; gobject_class->get_property = clutter_zoom_action_get_property; gobject_class->dispose = clutter_zoom_action_dispose; @@ -406,7 +416,6 @@ clutter_zoom_action_init (ClutterZoomAction *self) gesture = CLUTTER_GESTURE_ACTION (self); clutter_gesture_action_set_n_touch_points (gesture, 2); - clutter_gesture_action_set_threshold_trigger_edge (gesture, CLUTTER_GESTURE_TRIGGER_EDGE_NONE); } /**