Commit c185a177 authored by Carlos Garnacho's avatar Carlos Garnacho

event: Add pinch/swipe gesture event types and structs

We now have ClutterTouchpadPinchEvent and ClutterTouchpadSwipeEvent,
each bringing the necessary info for the specific gesture. Each
of these events is defined by begin/update/end/cancel phases.

These events have been also made to propagate down/up the pointer
position, just like scroll and button events do.
parent a4b79e1c
......@@ -757,6 +757,10 @@ typedef enum { /*< flags prefix=CLUTTER_EVENT >*/
* event added in 1.10
* @CLUTTER_TOUCH_CANCEL: A touch event sequence has been canceled;
* event added in 1.10
* @CLUTTER_TOUCHPAD_PINCH: A pinch gesture event, the current state is
* determined by its phase field; event added in 1.24
* @CLUTTER_TOUCHPAD_SWIPE: A swipe gesture event, the current state is
* determined by its phase field; event added in 1.24
* @CLUTTER_EVENT_LAST: Marks the end of the #ClutterEventType enumeration;
* added in 1.10
*
......@@ -782,6 +786,8 @@ typedef enum { /*< prefix=CLUTTER >*/
CLUTTER_TOUCH_UPDATE,
CLUTTER_TOUCH_END,
CLUTTER_TOUCH_CANCEL,
CLUTTER_TOUCHPAD_PINCH,
CLUTTER_TOUCHPAD_SWIPE,
CLUTTER_EVENT_LAST /* helper */
} ClutterEventType;
......@@ -1402,6 +1408,43 @@ typedef enum {
CLUTTER_GESTURE_TRIGGER_EDGE_BEFORE
} ClutterGestureTriggerEdge;
/**
* ClutterTouchpadGesturePhase:
* @CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN: The gesture has begun.
* @CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE: The gesture has been updated.
* @CLUTTER_TOUCHPAD_GESTURE_PHASE_END: The gesture was finished, changes
* should be permanently applied.
* @CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL: The gesture was cancelled, all
* changes should be undone.
*
* The phase of a touchpad gesture event. All gestures are guaranteed to
* begin with an event of type %CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN,
* followed by a number of %CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE (possibly 0).
*
* A finished gesture may have 2 possible outcomes, an event with phase
* %CLUTTER_TOUCHPAD_GESTURE_PHASE_END will be emitted when the gesture is
* considered successful, this should be used as the hint to perform any
* permanent changes.
* Cancelled gestures may be so for a variety of reasons, due to hardware,
* or due to the gesture recognition layers hinting the gesture did not
* finish resolutely (eg. a 3rd finger being added during a pinch gesture).
* In these cases, the last event with report the phase
* %CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL, this should be used as a hint
* to undo any visible/permanent changes that were done throughout the
* progress of the gesture.
*
* See also #ClutterTouchpadPinchEvent and #ClutterTouchpadPinchEvent.
*
* Since: 1.24
*/
typedef enum {
CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN,
CLUTTER_TOUCHPAD_GESTURE_PHASE_UPDATE,
CLUTTER_TOUCHPAD_GESTURE_PHASE_END,
CLUTTER_TOUCHPAD_GESTURE_PHASE_CANCEL
} ClutterTouchpadGesturePhase;
G_END_DECLS
#endif /* __CLUTTER_ENUMS_H__ */
......@@ -436,6 +436,16 @@ clutter_event_get_position (const ClutterEvent *event,
case CLUTTER_SCROLL:
clutter_point_init (position, event->scroll.x, event->scroll.y);
break;
case CLUTTER_TOUCHPAD_PINCH:
clutter_point_init (position, event->touchpad_pinch.x,
event->touchpad_pinch.y);
break;
case CLUTTER_TOUCHPAD_SWIPE:
clutter_point_init (position, event->touchpad_swipe.x,
event->touchpad_swipe.y);
break;
}
}
......@@ -498,6 +508,16 @@ clutter_event_set_coords (ClutterEvent *event,
event->scroll.x = x;
event->scroll.y = y;
break;
case CLUTTER_TOUCHPAD_PINCH:
event->touchpad_pinch.x = x;
event->touchpad_pinch.y = y;
break;
case CLUTTER_TOUCHPAD_SWIPE:
event->touchpad_swipe.x = x;
event->touchpad_swipe.y = y;
break;
}
}
......@@ -1097,6 +1117,11 @@ clutter_event_set_device (ClutterEvent *event,
case CLUTTER_KEY_RELEASE:
event->key.device = device;
break;
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
/* Rely on priv data for these */
break;
}
}
......@@ -1171,6 +1196,11 @@ clutter_event_get_device (const ClutterEvent *event)
case CLUTTER_KEY_RELEASE:
device = event->key.device;
break;
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
/* Rely on priv data for these */
break;
}
return device;
......@@ -1608,6 +1638,10 @@ clutter_event_get_axes (const ClutterEvent *event,
case CLUTTER_MOTION:
retval = event->motion.axes;
break;
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
break;
}
if (retval != NULL)
......
......@@ -115,6 +115,8 @@ typedef struct _ClutterScrollEvent ClutterScrollEvent;
typedef struct _ClutterStageStateEvent ClutterStageStateEvent;
typedef struct _ClutterCrossingEvent ClutterCrossingEvent;
typedef struct _ClutterTouchEvent ClutterTouchEvent;
typedef struct _ClutterTouchpadPinchEvent ClutterTouchpadPinchEvent;
typedef struct _ClutterTouchpadSwipeEvent ClutterTouchpadSwipeEvent;
/**
* ClutterAnyEvent:
......@@ -384,6 +386,84 @@ struct _ClutterTouchEvent
ClutterInputDevice *device;
};
/**
* ClutterTouchpadPinchEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @phase: the current phase of the gesture
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
* @dx: movement delta of the pinch focal point in the X axis
* @dy: movement delta of the pinch focal point in the Y axis
* @angle_delta: angle delta in degrees, clockwise rotations are
* represented by positive deltas
* @scale: the current scale
*
* Used for touchpad pinch gesture events. The current state of the
* gesture will be determined by the @phase field.
*
* Each event with phase %CLUTTER_TOUCHPAD_GESTURE_PHASE_BEGIN
* will report a @scale of 1.0, all later phases in the gesture
* report the current scale relative to the initial 1.0 value
* (eg. 0.5 being half the size, 2.0 twice as big).
*
* Since: 1.24
*/
struct _ClutterTouchpadPinchEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterStage *stage;
ClutterActor *source;
ClutterTouchpadGesturePhase phase;
gfloat x;
gfloat y;
gfloat dx;
gfloat dy;
gfloat angle_delta;
gfloat scale;
};
/**
* ClutterTouchpadSwipeEvent
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @phase: the current phase of the gesture
* @n_fingers: the number of fingers triggering the swipe
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
* @dx: movement delta of the pinch focal point in the X axis
* @dy: movement delta of the pinch focal point in the Y axis
*
* Used for touchpad swipe gesture events. The current state of the
* gesture will be determined by the @phase field.
*
* Since: 1.24
*/
struct _ClutterTouchpadSwipeEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterStage *stage;
ClutterActor *source;
ClutterTouchpadGesturePhase phase;
guint n_fingers;
gfloat x;
gfloat y;
gfloat dx;
gfloat dy;
};
/**
* ClutterEvent:
*
......@@ -404,6 +484,8 @@ union _ClutterEvent
ClutterStageStateEvent stage_state;
ClutterCrossingEvent crossing;
ClutterTouchEvent touch;
ClutterTouchpadPinchEvent touchpad_pinch;
ClutterTouchpadSwipeEvent touchpad_swipe;
};
/**
......
......@@ -2290,6 +2290,8 @@ _clutter_process_event_details (ClutterActor *stage,
case CLUTTER_BUTTON_PRESS:
case CLUTTER_BUTTON_RELEASE:
case CLUTTER_SCROLL:
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:
{
ClutterActor *actor;
gfloat x, y;
......
......@@ -1105,6 +1105,9 @@ ClutterStageStateEvent
ClutterCrossingEvent
ClutterTouchEvent
ClutterEventSequence
ClutterTouchpadPinchEvent
ClutterTouchpadSwipeEvent
ClutterTouchpadGesturePhase
clutter_event_new
clutter_event_copy
clutter_event_free
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment