After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 685028 - Let users and subclasses set a custom threshold on GestureAction
Let users and subclasses set a custom threshold on GestureAction
Status: RESOLVED FIXED
Product: clutter
Classification: Platform
Component: ClutterAction
git master
Other All
: Normal enhancement
: ---
Assigned To: clutter-maint
clutter-maint
Depends on:
Blocks: 683948
 
 
Reported: 2012-09-28 08:36 UTC by Emanuele Aina
Modified: 2012-10-19 09:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
version: Add 1.14 version macros (1.08 KB, patch)
2012-09-28 08:36 UTC, Emanuele Aina
none Details | Review
Add the GestureAction:threshold property (8.87 KB, patch)
2012-09-28 08:36 UTC, Emanuele Aina
none Details | Review
Add the GestureAction:threshold property (11.60 KB, patch)
2012-10-01 14:41 UTC, Emanuele Aina
none Details | Review
Add the GestureAction:threshold property (12.05 KB, patch)
2012-10-01 15:20 UTC, Emanuele Aina
none Details | Review
Add the GestureAction:threshold property (12.15 KB, patch)
2012-10-05 11:09 UTC, Emanuele Aina
rejected Details | Review
version: Add 1.14 version macros (1.74 KB, patch)
2012-10-09 15:12 UTC, Emanuele Aina
committed Details | Review
gesture-action: Let subclasses override the GestureTriggerEdge handling (11.92 KB, patch)
2012-10-16 08:00 UTC, Emanuele Aina
committed Details | Review
gesture-action: Let subclasses override the GestureTriggerEdge handling (11.92 KB, patch)
2012-10-19 09:32 UTC, Emanuele Aina
committed Details | Review

Description Emanuele Aina 2012-09-28 08:36:37 UTC
The usefulness of having an overridable :threshold property in
GestureAction would be twofold:
• users like examples/pan-action may set it to zero to be more
  responsive;
• an hypothetical Tap gesture may override the property and use it
  as the max distance before cancelling the gesture, while setting
  the original GestureAction property to zero.

The patch attached adds the ClutterGestureAction:threshold property
and falls back to ClutterSettings:dnd-drag-threshold if set to -1.

For convenience I've assumed that there will be a 1.14 release and
I've added the needed macros. :)
Comment 1 Emanuele Aina 2012-09-28 08:36:40 UTC
Created attachment 225318 [details] [review]
version: Add 1.14 version macros
Comment 2 Emanuele Aina 2012-09-28 08:36:45 UTC
Created attachment 225319 [details] [review]
Add the GestureAction:threshold property

Let gesture users or subclasses set a custom threshold, falling
back to :dnd-drag-threshold otherwise:
• examples/pan-action sets it to zero to be more responsive;
• an hypothetical Tap gesture may override the property and use it
  as the max distance before cancelling the gesture, while setting
  the original GestureAction property to zero.
Comment 3 Emanuele Aina 2012-10-01 14:41:27 UTC
Created attachment 225497 [details] [review]
Add the GestureAction:threshold property

Fix some issues encountered while developing ClutterTapAction on top of this patch.
Comment 4 Emanuele Aina 2012-10-01 15:20:14 UTC
Created attachment 225501 [details] [review]
Add the GestureAction:threshold property

Honour the :threshold property while checking if a gesture should be
started when invoking clutter_gesture_action_set_n_touch_points().
Comment 5 Emanuele Aina 2012-10-05 11:09:06 UTC
Created attachment 225869 [details] [review]
Add the GestureAction:threshold property

Removed an unused variable and fixed the threshold condition.
Comment 6 Emanuele Aina 2012-10-09 15:12:48 UTC
Created attachment 226119 [details] [review]
version: Add 1.14 version macros

Oops, I forgot the CLUTTER_VERSION_1_14 macro.
Comment 7 Emmanuele Bassi (:ebassi) 2012-10-10 14:22:41 UTC
Review of attachment 226119 [details] [review]:

LGTM
Comment 8 Emmanuele Bassi (:ebassi) 2012-10-10 14:29:34 UTC
Review of attachment 225869 [details] [review]:

::: clutter/clutter-gesture-action.c
@@ +227,3 @@
+                              gint threshold)
+{
+  g_return_if_fail (threshold >= -1);

do not use g_return_if_fail() inside internal/static functions.

use g_assert() if you want to verify internal state.

@@ +244,3 @@
+      ClutterSettings *settings = clutter_settings_get_default ();
+      g_object_get (settings,
+          "dnd-drag-threshold", &threshold,

coding style: braces on a separate line, and argument alignment of g_object_get()

@@ +286,3 @@
+
+  g_signal_emit (action, gesture_signals[GESTURE_BEGIN], 0, actor,
+      &return_value);

coding style: argument alignment

@@ +347,1 @@
+          if ((ABS (point->press_y - motion_y) < drag_threshold) &&

you may want to use fabsf() instead of the ABS macro.

@@ +1053,3 @@
+  g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
+
+  g_object_set (G_OBJECT (action), "threshold", threshold, NULL);

eeeewwwwww, no, no, a thousand times *no*.

if you want a way to override the *meaning* of a threshold then I think we should just rip out the whole concept of threshold in GestureAction altogether, and define ad hoc gesture thresholds in its subclasses.

alternatively, use negative numbers for "cancel the gesture if the threshold is passed" and positive numbers for "begin the gesture if the threshold is passed". but I'd rather have the meaning of threshold be a per-GestureAction class decision.
Comment 9 Emanuele Aina 2012-10-10 18:31:02 UTC
Comment on attachment 226119 [details] [review]
version: Add 1.14 version macros

Attachment 226119 [details] pushed as cb4620d - version: Add 1.14 version macros
Comment 10 Emanuele Aina 2012-10-13 09:41:55 UTC
(In reply to comment #8)

> +  g_return_if_fail (CLUTTER_IS_GESTURE_ACTION (action));
> +
> +  g_object_set (G_OBJECT (action), "threshold", threshold, NULL);
> 
> eeeewwwwww, no, no, a thousand times *no*.
> 
> if you want a way to override the *meaning* of a threshold then I think we
> should just rip out the whole concept of threshold in GestureAction altogether,
> and define ad hoc gesture thresholds in its subclasses.
> 
> alternatively, use negative numbers for "cancel the gesture if the threshold is
> passed" and positive numbers for "begin the gesture if the threshold is
> passed". but I'd rather have the meaning of threshold be a per-GestureAction
> class decision.

I don't see it as a big problem (it's still a threshold, I just want to override the direction of the threshold) but if you prefer I can try some other way.

What about splitting it in ::begin-threshold (defaults to -1 → ::dnd-drag-threshold) and ::cancel-threshold (defaults to -1 → no threshold)?

Do you have other suggestions?
Comment 11 Emanuele Aina 2012-10-16 08:00:51 UTC
Created attachment 226526 [details] [review]
gesture-action: Let subclasses override the GestureTriggerEdge handling

Let gesture subclasses override how the drag threshold should
be handled:

• CLUTTER_GESTURE_TRIGGER_NONE tells GestureAction that the gesture
  must begin immediately and there's no drag limit that will cause
  its cancellation;
• CLUTTER_GESTURE_TRIGGER_AFTER is the default GestureAction behaviour,
  where it needs to wait until the drag threshold has been exceeded
  before considering the gesture valid;
• CLUTTER_GESTURE_TRIGGER_BEFORE will make GestureAction cancel
  the gesture once the drag exceed the configured threshold.

For example, ZoomAction and RotateAction could set
CLUTTER_GESTURE_TRIGGER_NONE since the use of two fingers makes the
begin of the action more self-evident, while an hypothetical Tap
gesture may use CLUTTER_GESTURE_TRIGGER_BEFORE to cancel the tap if
the pointer moves too much.
Comment 12 Emmanuele Bassi (:ebassi) 2012-10-19 09:00:13 UTC
Review of attachment 226526 [details] [review]:

looks okay to me
Comment 13 Emanuele Aina 2012-10-19 09:32:43 UTC
The following fix has been pushed:
abcf1d5 gesture-action: Let subclasses override the GestureTriggerEdge handling
Comment 14 Emanuele Aina 2012-10-19 09:32:51 UTC
Created attachment 226803 [details] [review]
gesture-action: Let subclasses override the GestureTriggerEdge handling

Let gesture subclasses override how the drag threshold should
be handled:

• CLUTTER_GESTURE_TRIGGER_NONE tells GestureAction that the gesture
  must begin immediately and there's no drag limit that will cause
  its cancellation;
• CLUTTER_GESTURE_TRIGGER_AFTER is the default GestureAction behaviour,
  where it needs to wait until the drag threshold has been exceeded
  before considering the gesture valid;
• CLUTTER_GESTURE_TRIGGER_BEFORE will make GestureAction cancel
  the gesture once the drag exceed the configured threshold.

For example, ZoomAction and RotateAction could set
CLUTTER_GESTURE_TRIGGER_NONE since the use of two fingers makes the
begin of the action more self-evident, while an hypothetical Tap
gesture may use CLUTTER_GESTURE_TRIGGER_BEFORE to cancel the tap if
the pointer moves too much.