gesture-tracker: Implement threshold-based sequence rejection
If a sequence moves past a certain distance without being used by a gesture, reject it so clients may see and react to it ASAP. This makes gestures to be began by initially quasi-static touchpoints, in addition to quasi-simultaneous.
This commit is contained in:
parent
d05b750b8d
commit
789608b637
@ -23,6 +23,8 @@
|
|||||||
#include "gesture-tracker-private.h"
|
#include "gesture-tracker-private.h"
|
||||||
#include "meta-surface-actor.h"
|
#include "meta-surface-actor.h"
|
||||||
|
|
||||||
|
#define DISTANCE_THRESHOLD 30
|
||||||
|
|
||||||
typedef struct _MetaGestureTrackerPrivate MetaGestureTrackerPrivate;
|
typedef struct _MetaGestureTrackerPrivate MetaGestureTrackerPrivate;
|
||||||
typedef struct _GestureActionData GestureActionData;
|
typedef struct _GestureActionData GestureActionData;
|
||||||
typedef struct _MetaSequenceInfo MetaSequenceInfo;
|
typedef struct _MetaSequenceInfo MetaSequenceInfo;
|
||||||
@ -33,6 +35,8 @@ struct _MetaSequenceInfo
|
|||||||
ClutterEventSequence *sequence;
|
ClutterEventSequence *sequence;
|
||||||
MetaSequenceState state;
|
MetaSequenceState state;
|
||||||
guint autodeny_timeout_id;
|
guint autodeny_timeout_id;
|
||||||
|
gfloat start_x;
|
||||||
|
gfloat start_y;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GestureActionData
|
struct _GestureActionData
|
||||||
@ -190,6 +194,8 @@ meta_sequence_info_new (MetaGestureTracker *tracker,
|
|||||||
info->state = META_SEQUENCE_NONE;
|
info->state = META_SEQUENCE_NONE;
|
||||||
info->autodeny_timeout_id = g_timeout_add (ms, autodeny_sequence, info);
|
info->autodeny_timeout_id = g_timeout_add (ms, autodeny_sequence, info);
|
||||||
|
|
||||||
|
clutter_event_get_coords (event, &info->start_x, &info->start_y);
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,6 +408,7 @@ meta_gesture_tracker_handle_event (MetaGestureTracker *tracker,
|
|||||||
ClutterEventSequence *sequence;
|
ClutterEventSequence *sequence;
|
||||||
MetaSequenceInfo *info;
|
MetaSequenceInfo *info;
|
||||||
ClutterActor *stage;
|
ClutterActor *stage;
|
||||||
|
gfloat x, y;
|
||||||
|
|
||||||
sequence = clutter_event_get_event_sequence (event);
|
sequence = clutter_event_get_event_sequence (event);
|
||||||
|
|
||||||
@ -452,6 +459,18 @@ meta_gesture_tracker_handle_event (MetaGestureTracker *tracker,
|
|||||||
meta_gesture_tracker_untrack_stage (tracker);
|
meta_gesture_tracker_untrack_stage (tracker);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_TOUCH_UPDATE:
|
case CLUTTER_TOUCH_UPDATE:
|
||||||
|
info = g_hash_table_lookup (priv->sequences, sequence);
|
||||||
|
|
||||||
|
if (!info)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
clutter_event_get_coords (event, &x, &y);
|
||||||
|
|
||||||
|
if (info->state == META_SEQUENCE_NONE &&
|
||||||
|
(ABS (info->start_x - x) > DISTANCE_THRESHOLD ||
|
||||||
|
ABS (info->start_y - y) > DISTANCE_THRESHOLD))
|
||||||
|
meta_gesture_tracker_set_sequence_state (tracker, sequence,
|
||||||
|
META_SEQUENCE_REJECTED);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user