Merge branch 'get-current-event' into ebassi-next

* get-current-event:
  Add clutter_get_current_event
This commit is contained in:
Emmanuele Bassi 2009-12-10 23:36:04 +00:00
commit 7b53aa7510
5 changed files with 61 additions and 27 deletions

View File

@ -765,6 +765,29 @@ clutter_get_current_event_time (void)
return CLUTTER_CURRENT_TIME; return CLUTTER_CURRENT_TIME;
} }
/**
* clutter_get_current_event:
*
* If an event is currently being processed, return that event.
* This function is intended to be used to access event state
* that might not be exposed by higher-level widgets. For
* example, to get the key modifier state from a Button 'clicked'
* event.
*
* Return value: (transfer none): The current ClutterEvent, or %NULL if none
*
* Since: 1.2
*/
G_CONST_RETURN ClutterEvent *
clutter_get_current_event (void)
{
ClutterMainContext *context = _clutter_context_get_default ();
g_return_val_if_fail (context != NULL, NULL);
return context->current_event;
}
/** /**
* clutter_input_device_get_device_type: * clutter_input_device_get_device_type:
* @device: a #ClutterInputDevice * @device: a #ClutterInputDevice

View File

@ -507,6 +507,7 @@ ClutterScrollDirection clutter_event_get_scroll_direction (ClutterEvent *e
guint32 clutter_keysym_to_unicode (guint keyval); guint32 clutter_keysym_to_unicode (guint keyval);
guint32 clutter_get_current_event_time (void); guint32 clutter_get_current_event_time (void);
G_CONST_RETURN ClutterEvent *clutter_get_current_event (void);
ClutterInputDeviceType clutter_input_device_get_device_type (ClutterInputDevice *device); ClutterInputDeviceType clutter_input_device_get_device_type (ClutterInputDevice *device);
gint clutter_input_device_get_device_id (ClutterInputDevice *device); gint clutter_input_device_get_device_id (ClutterInputDevice *device);

View File

@ -2166,36 +2166,13 @@ clutter_do_event (ClutterEvent *event)
_clutter_stage_queue_event (event->any.stage, event); _clutter_stage_queue_event (event->any.stage, event);
} }
/** static void
* _clutter_process_event _clutter_process_event_details (ClutterActor *stage,
* @event: a #ClutterEvent. ClutterMainContext *context,
* ClutterEvent *event)
* Does the actual work of processing an event that was queued earlier
* out of clutter_do_event().
*/
void
_clutter_process_event (ClutterEvent *event)
{ {
/* FIXME: This should probably be clutter_cook_event() - it would
* take a raw event from the backend and 'cook' it so its more tasty.
*
*/
ClutterMainContext *context;
ClutterBackend *backend;
ClutterActor *stage;
ClutterInputDevice *device = NULL; ClutterInputDevice *device = NULL;
context = _clutter_context_get_default ();
backend = context->backend;
stage = CLUTTER_ACTOR(event->any.stage);
if (!stage)
return;
CLUTTER_TIMESTAMP (EVENT, "Event received");
context->last_event_time = clutter_event_get_time (event);
switch (event->type) switch (event->type)
{ {
case CLUTTER_NOTHING: case CLUTTER_NOTHING:
@ -2393,6 +2370,37 @@ _clutter_process_event (ClutterEvent *event)
} }
} }
/**
* _clutter_process_event
* @event: a #ClutterEvent.
*
* Does the actual work of processing an event that was queued earlier
* out of clutter_do_event().
*/
void
_clutter_process_event (ClutterEvent *event)
{
ClutterMainContext *context;
ClutterBackend *backend;
ClutterActor *stage;
context = _clutter_context_get_default ();
backend = context->backend;
stage = CLUTTER_ACTOR(event->any.stage);
if (!stage)
return;
CLUTTER_TIMESTAMP (EVENT, "Event received");
context->last_event_time = clutter_event_get_time (event);
context->current_event = event;
_clutter_process_event_details (stage, context, event);
context->current_event = NULL;
}
/** /**
* clutter_get_actor_by_gid * clutter_get_actor_by_gid
* @id: a #ClutterActor ID. * @id: a #ClutterActor ID.

View File

@ -128,6 +128,7 @@ struct _ClutterMainContext
GSList *input_devices; /* For extra input devices, i.e GSList *input_devices; /* For extra input devices, i.e
MultiTouch */ MultiTouch */
ClutterEvent *current_event;
guint32 last_event_time; guint32 last_event_time;
gulong redraw_count; gulong redraw_count;

View File

@ -977,6 +977,7 @@ clutter_input_device_get_device_type
<SUBSECTION> <SUBSECTION>
clutter_get_current_event_time clutter_get_current_event_time
clutter_get_current_event
<SUBSECTION Standard> <SUBSECTION Standard>
CLUTTER_TYPE_EVENT CLUTTER_TYPE_EVENT