event: Add ClutterTouchEvent

The ClutterTouchEvent structure contains the data relative to a touch
event.
This commit is contained in:
Emmanuele Bassi 2012-03-19 13:47:19 +00:00
parent ab3582be1c
commit d15b828cc5
5 changed files with 179 additions and 1 deletions

View File

@ -703,6 +703,16 @@ typedef enum { /*< flags prefix=CLUTTER_EVENT >*/
* @CLUTTER_DESTROY_NOTIFY: Destroy notification event
* @CLUTTER_CLIENT_MESSAGE: Client message event
* @CLUTTER_DELETE: Stage delete event
* @CLUTTER_TOUCH_BEGIN: A new touch event sequence has started;
* event added in 1.10
* @CLUTTER_TOUCH_UPDATE: A touch event sequence has been updated;
* event added in 1.10
* @CLUTTER_TOUCH_END: A touch event sequence has finished;
* event added in 1.10
* @CLUTTER_TOUCH_CANCEL: A touch event sequence has been canceled;
* event added in 1.10
* @CLUTTER_EVENT_LAST: Marks the end of the #ClutterEventType enumeration;
* added in 1.10
*
* Types of events.
*
@ -721,7 +731,13 @@ typedef enum { /*< prefix=CLUTTER >*/
CLUTTER_STAGE_STATE,
CLUTTER_DESTROY_NOTIFY,
CLUTTER_CLIENT_MESSAGE,
CLUTTER_DELETE
CLUTTER_DELETE,
CLUTTER_TOUCH_BEGIN,
CLUTTER_TOUCH_UPDATE,
CLUTTER_TOUCH_END,
CLUTTER_TOUCH_CANCEL,
CLUTTER_EVENT_LAST /* helper */
} ClutterEventType;
/**

View File

@ -185,6 +185,12 @@ clutter_event_get_state (const ClutterEvent *event)
case CLUTTER_BUTTON_RELEASE:
return event->button.modifier_state;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
return event->touch.modifier_state;
case CLUTTER_MOTION:
return event->motion.modifier_state;
@ -229,6 +235,13 @@ clutter_event_set_state (ClutterEvent *event,
event->motion.modifier_state = state;
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
event->touch.modifier_state = state;
break;
case CLUTTER_SCROLL:
event->scroll.modifier_state = state;
break;
@ -268,6 +281,7 @@ clutter_event_get_coords (const ClutterEvent *event,
case CLUTTER_DESTROY_NOTIFY:
case CLUTTER_CLIENT_MESSAGE:
case CLUTTER_DELETE:
case CLUTTER_EVENT_LAST:
break;
case CLUTTER_ENTER:
@ -287,6 +301,14 @@ clutter_event_get_coords (const ClutterEvent *event,
event_y = event->motion.y;
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
event_x = event->touch.x;
event_y = event->touch.y;
break;
case CLUTTER_SCROLL:
event_x = event->scroll.x;
event_y = event->scroll.y;
@ -326,6 +348,7 @@ clutter_event_set_coords (ClutterEvent *event,
case CLUTTER_DESTROY_NOTIFY:
case CLUTTER_CLIENT_MESSAGE:
case CLUTTER_DELETE:
case CLUTTER_EVENT_LAST:
break;
case CLUTTER_ENTER:
@ -345,6 +368,14 @@ clutter_event_set_coords (ClutterEvent *event,
event->motion.y = y;
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
event->touch.x = x;
event->touch.y = y;
break;
case CLUTTER_SCROLL:
event->scroll.x = x;
event->scroll.y = y;
@ -812,6 +843,32 @@ clutter_event_set_key_unicode (ClutterEvent *event,
event->key.unicode_value = key_unicode;
}
/**
* clutter_event_get_event_sequence:
* @event: a #ClutterEvent of type %CLUTTER_TOUCH_BEGIN,
* %CLUTTER_TOUCH_UPDATE, %CLUTTER_TOUCH_END, or
* %CLUTTER_TOUCH_CANCEL
*
* Retrieves the #ClutterEventSequence of @event.
*
* Return value: (transfer none): the event sequence, or %NULL
*
* Since: 1.10
*/
ClutterEventSequence *
clutter_event_get_event_sequence (const ClutterEvent *event)
{
g_return_val_if_fail (event != NULL, NULL);
if (event->type == CLUTTER_TOUCH_BEGIN ||
event->type == CLUTTER_TOUCH_UPDATE ||
event->type == CLUTTER_TOUCH_END ||
event->type == CLUTTER_TOUCH_CANCEL)
return event->touch.sequence;
return NULL;
}
/**
* clutter_event_get_device_id:
* @event: a clutter event
@ -890,6 +947,7 @@ clutter_event_set_device (ClutterEvent *event,
case CLUTTER_DESTROY_NOTIFY:
case CLUTTER_CLIENT_MESSAGE:
case CLUTTER_DELETE:
case CLUTTER_EVENT_LAST:
break;
case CLUTTER_ENTER:
@ -910,6 +968,13 @@ clutter_event_set_device (ClutterEvent *event,
event->scroll.device = device;
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
event->touch.device = device;
break;
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
event->key.device = device;
@ -954,6 +1019,7 @@ clutter_event_get_device (const ClutterEvent *event)
case CLUTTER_DESTROY_NOTIFY:
case CLUTTER_CLIENT_MESSAGE:
case CLUTTER_DELETE:
case CLUTTER_EVENT_LAST:
break;
case CLUTTER_ENTER:
@ -974,6 +1040,13 @@ clutter_event_get_device (const ClutterEvent *event)
device = event->scroll.device;
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
device = event->touch.device;
break;
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
device = event->key.device;
@ -1068,6 +1141,15 @@ clutter_event_copy (const ClutterEvent *event)
sizeof (gdouble) * n_axes);
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
if (event->touch.axes != NULL)
new_event->touch.axes = g_memdup (event->motion.axes,
sizeof (gdouble) * n_axes);
break;
default:
break;
}
@ -1108,6 +1190,13 @@ clutter_event_free (ClutterEvent *event)
g_free (event->scroll.axes);
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
g_free (event->touch.axes);
break;
default:
break;
}
@ -1372,6 +1461,7 @@ clutter_event_get_axes (const ClutterEvent *event,
case CLUTTER_LEAVE:
case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE:
case CLUTTER_EVENT_LAST:
break;
case CLUTTER_SCROLL:
@ -1383,6 +1473,13 @@ clutter_event_get_axes (const ClutterEvent *event,
retval = event->button.axes;
break;
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
retval = event->touch.axes;
break;
case CLUTTER_MOTION:
retval = event->motion.axes;
break;

View File

@ -113,6 +113,9 @@ typedef struct _ClutterMotionEvent ClutterMotionEvent;
typedef struct _ClutterScrollEvent ClutterScrollEvent;
typedef struct _ClutterStageStateEvent ClutterStageStateEvent;
typedef struct _ClutterCrossingEvent ClutterCrossingEvent;
typedef struct _ClutterTouchEvent ClutterTouchEvent;
typedef struct _ClutterEventSequence ClutterEventSequence;
/**
* ClutterAnyEvent:
@ -329,6 +332,54 @@ struct _ClutterStageStateEvent
ClutterStageState new_state;
};
/**
* ClutterTouchEvent:
* @type: event type
* @time: event time
* @flags: event flags
* @stage: event source stage
* @source: event source actor (unused)
* @x: the X coordinate of the pointer, relative to the stage
* @y: the Y coordinate of the pointer, relative to the stage
* @axes: @x and @y, translated to the axes of @device, or %NULL
* @state: (type ClutterModifierType): a bit-mask representing the state
* of modifier keys (e.g. Control, Shift, and Alt) and the pointer
* buttons. See #ClutterModifierType
* @sequence: the event sequence that this event belongs to
* @device: the device that originated the event
*
* Used for touch events.
*
* The @type field will be one of %CLUTTER_TOUCH_BEGIN, %CLUTTER_TOUCH_END,
* %CLUTTER_TOUCH_UPDATE, or %CLUTTER_TOUCH_CANCEL.
*
* Touch events are grouped into sequences; each touch sequence will begin
* with a %CLUTTER_TOUCH_BEGIN event, progress with %CLUTTER_TOUCH_UPDATE
* events, and end either with a %CLUTTER_TOUCH_END event or with a
* %CLUTTER_TOUCH_CANCEL event.
*
* With multi-touch capable devices there can be multiple event sequence
* running at the same time.
*
* Since: 1.10
*/
struct _ClutterTouchEvent
{
ClutterEventType type;
guint32 time;
ClutterEventFlags flags;
ClutterStage *stage;
ClutterActor *source;
gfloat x;
gfloat y;
guint state;
ClutterEventSequence *sequence;
ClutterModifierType modifier_state;
gdouble *axes;
ClutterInputDevice *device;
};
/**
* ClutterEvent:
*
@ -348,6 +399,7 @@ union _ClutterEvent
ClutterScrollEvent scroll;
ClutterStageStateEvent stage_state;
ClutterCrossingEvent crossing;
ClutterTouchEvent touch;
};
GType clutter_event_get_type (void) G_GNUC_CONST;
@ -429,6 +481,9 @@ void clutter_event_get_scroll_delta (const ClutterEv
gdouble *dx,
gdouble *dy);
CLUTTER_AVAILABLE_IN_1_10
ClutterEventSequence * clutter_event_get_event_sequence (const ClutterEvent *event);
guint32 clutter_keysym_to_unicode (guint keyval);
CLUTTER_AVAILABLE_IN_1_10
guint clutter_unicode_to_keysym (guint32 wc);

View File

@ -2611,6 +2611,12 @@ _clutter_process_event_details (ClutterActor *stage,
break;
}
case CLUTTER_TOUCH_BEGIN:
case CLUTTER_TOUCH_UPDATE:
case CLUTTER_TOUCH_END:
case CLUTTER_TOUCH_CANCEL:
break;
case CLUTTER_STAGE_STATE:
/* fullscreen / focus - forward to stage */
event->any.source = stage;
@ -2619,6 +2625,9 @@ _clutter_process_event_details (ClutterActor *stage,
case CLUTTER_CLIENT_MESSAGE:
break;
case CLUTTER_EVENT_LAST:
break;
}
}

View File

@ -622,6 +622,7 @@ clutter_event_get_coords
clutter_event_get_device
clutter_event_get_device_id
clutter_event_get_device_type
clutter_event_get_event_sequence
clutter_event_get_flags
clutter_event_free
clutter_event_get