mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 16:10:41 -05:00
Add clutter_get_current_event
When getting signals from higher level toolkits, occasionally one wants access to the underlying event; say for a Button widget's "clicked" signal, to get the keyboard state. Rather than having all of the highlevel widgets emit ClutterEvent just for the more unusual use cases, add a global function to access the event state. http://bugzilla.openedhand.com/show_bug.cgi?id=1888 Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
This commit is contained in:
parent
86ce92eec1
commit
1374b5aac9
@ -765,6 +765,29 @@ clutter_get_current_event_time (void)
|
||||
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:
|
||||
* @device: a #ClutterInputDevice
|
||||
|
@ -507,6 +507,7 @@ ClutterScrollDirection clutter_event_get_scroll_direction (ClutterEvent *e
|
||||
guint32 clutter_keysym_to_unicode (guint keyval);
|
||||
|
||||
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);
|
||||
gint clutter_input_device_get_device_id (ClutterInputDevice *device);
|
||||
|
@ -2166,36 +2166,13 @@ clutter_do_event (ClutterEvent *event)
|
||||
_clutter_stage_queue_event (event->any.stage, 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)
|
||||
static void
|
||||
_clutter_process_event_details (ClutterActor *stage,
|
||||
ClutterMainContext *context,
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
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
|
||||
* @id: a #ClutterActor ID.
|
||||
|
@ -128,6 +128,7 @@ struct _ClutterMainContext
|
||||
GSList *input_devices; /* For extra input devices, i.e
|
||||
MultiTouch */
|
||||
|
||||
ClutterEvent *current_event;
|
||||
guint32 last_event_time;
|
||||
|
||||
gulong redraw_count;
|
||||
|
@ -977,6 +977,7 @@ clutter_input_device_get_device_type
|
||||
|
||||
<SUBSECTION>
|
||||
clutter_get_current_event_time
|
||||
clutter_get_current_event
|
||||
|
||||
<SUBSECTION Standard>
|
||||
CLUTTER_TYPE_EVENT
|
||||
|
Loading…
Reference in New Issue
Block a user