2006-05-29 08:59:36 +00:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2006-05-29 08:59:36 +00:00
|
|
|
*/
|
2006-06-21 22:34:25 +00:00
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2010-10-21 10:49:37 +00:00
|
|
|
#include "clutter-backend-private.h"
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-event.h"
|
2008-06-09 10:13:20 +00:00
|
|
|
#include "clutter-keysyms.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
#include "clutter-keysyms-table.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
|
2007-06-07 15:28:59 +00:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-event
|
|
|
|
* @short_description: User and window system events
|
|
|
|
*
|
|
|
|
* Windowing events handled by Clutter.
|
2009-06-06 14:27:37 +00:00
|
|
|
*
|
|
|
|
* The events usually come from the windowing backend, but can also
|
|
|
|
* be synthesized by Clutter itself or by the application code.
|
2007-06-07 15:28:59 +00:00
|
|
|
*/
|
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
typedef struct _ClutterEventPrivate {
|
|
|
|
ClutterEvent base;
|
|
|
|
|
2011-01-18 14:09:04 +00:00
|
|
|
ClutterInputDevice *source_device;
|
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
gpointer platform_data;
|
|
|
|
} ClutterEventPrivate;
|
|
|
|
|
|
|
|
static GHashTable *all_events = NULL;
|
|
|
|
|
2010-10-08 14:21:57 +00:00
|
|
|
G_DEFINE_BOXED_TYPE (ClutterEvent, clutter_event,
|
|
|
|
clutter_event_copy,
|
|
|
|
clutter_event_free);
|
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
static gboolean
|
|
|
|
is_event_allocated (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
if (all_events == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return g_hash_table_lookup (all_events, event) != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _clutter_event_get_platform_data:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the pointer to platform-specific data inside an event
|
|
|
|
*
|
|
|
|
* Return value: a pointer to platform-specific data
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
|
|
|
gpointer
|
|
|
|
_clutter_event_get_platform_data (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return ((ClutterEventPrivate *) event)->platform_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_event_set_platform_data (ClutterEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return;
|
|
|
|
|
|
|
|
((ClutterEventPrivate *) event)->platform_data = data;
|
|
|
|
}
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_type:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the type of the event.
|
|
|
|
*
|
|
|
|
* Return value: a #ClutterEventType
|
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
ClutterEventType
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_type (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-03-22 18:21:59 +00:00
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_NOTHING);
|
|
|
|
|
2006-05-29 08:59:36 +00:00
|
|
|
return event->type;
|
|
|
|
}
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/**
|
2007-03-22 18:21:59 +00:00
|
|
|
* clutter_event_get_time:
|
|
|
|
* @event: a #ClutterEvent
|
2006-12-12 20:20:04 +00:00
|
|
|
*
|
|
|
|
* Retrieves the time of the event.
|
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
* Return value: the time of the event, or %CLUTTER_CURRENT_TIME
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2006-12-12 20:20:04 +00:00
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
guint32
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_time (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-03-22 18:21:59 +00:00
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_CURRENT_TIME);
|
|
|
|
|
2007-10-03 09:28:16 +00:00
|
|
|
return event->any.time;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/**
|
2007-03-22 18:21:59 +00:00
|
|
|
* clutter_event_get_state:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the modifier state of the event.
|
2006-12-12 20:20:04 +00:00
|
|
|
*
|
2007-07-01 16:44:24 +00:00
|
|
|
* Return value: the modifier state parameter, or 0
|
2006-12-12 20:20:04 +00:00
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
* Since: 0.4
|
2006-12-12 20:20:04 +00:00
|
|
|
*/
|
2007-07-21 16:48:11 +00:00
|
|
|
ClutterModifierType
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_state (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2007-03-22 18:21:59 +00:00
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
return event->key.modifier_state;
|
2009-06-06 14:27:37 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_BUTTON_PRESS:
|
2009-04-30 10:54:09 +00:00
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
2007-03-22 18:21:59 +00:00
|
|
|
return event->button.modifier_state;
|
2009-06-06 14:27:37 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_MOTION:
|
|
|
|
return event->motion.modifier_state;
|
2009-06-06 14:27:37 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
return event->scroll.modifier_state;
|
2009-06-06 14:27:37 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/**
|
2007-03-22 18:21:59 +00:00
|
|
|
* clutter_event_get_coords:
|
|
|
|
* @event: a #ClutterEvent
|
2010-09-08 14:15:57 +00:00
|
|
|
* @x: (out): return location for the X coordinate, or %NULL
|
|
|
|
* @y: (out): return location for the Y coordinate, or %NULL
|
2006-12-12 20:20:04 +00:00
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
* Retrieves the coordinates of @event and puts them into @x and @y.
|
2006-12-12 20:20:04 +00:00
|
|
|
*
|
2007-03-22 18:21:59 +00:00
|
|
|
* Since: 0.4
|
2006-12-12 20:20:04 +00:00
|
|
|
*/
|
2007-03-22 18:21:59 +00:00
|
|
|
void
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_coords (const ClutterEvent *event,
|
|
|
|
gfloat *x,
|
|
|
|
gfloat *y)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
gfloat event_x, event_y;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
event_x = event_y = 0;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
2007-08-21 15:48:51 +00:00
|
|
|
case CLUTTER_NOTHING:
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2007-08-21 15:48:51 +00:00
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
2010-04-28 15:19:37 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-03 09:28:16 +00:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
2010-04-28 15:19:37 +00:00
|
|
|
event_x = event->crossing.x;
|
|
|
|
event_y = event->crossing.y;
|
2007-03-22 18:21:59 +00:00
|
|
|
break;
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
event_x = event->button.x;
|
|
|
|
event_y = event->button.y;
|
|
|
|
break;
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_MOTION:
|
|
|
|
event_x = event->motion.x;
|
|
|
|
event_y = event->motion.y;
|
|
|
|
break;
|
Remove Units from the public API
With the recent change to internal floating point values, ClutterUnit
has become a redundant type, defined to be a float. All integer entry
points are being internally converted to floating point values to be
passed to the GL pipeline with the least amount of conversion.
ClutterUnit is thus exposed as just a "pixel with fractionary bits",
and not -- as users might think -- as generic, resolution and device
independent units. not that it was the case, but a definitive amount
of people was convinced it did provide this "feature", and was flummoxed
about the mere existence of this type.
So, having ClutterUnit exposed in the public API doubles the entry
points and has the following disadvantages:
- we have to maintain twice the amount of entry points in ClutterActor
- we still do an integer-to-float implicit conversion
- we introduce a weird impedance between pixels and "pixels with
fractionary bits"
- language bindings will have to choose what to bind, and resort
to manually overriding the API
+ *except* for language bindings based on GObject-Introspection, as
they cannot do manual overrides, thus will replicate the entire
set of entry points
For these reason, we should coalesces every Actor entry point for
pixels and for ClutterUnit into a single entry point taking a float,
like:
void clutter_actor_set_x (ClutterActor *self,
gfloat x);
void clutter_actor_get_size (ClutterActor *self,
gfloat *width,
gfloat *height);
gfloat clutter_actor_get_height (ClutterActor *self);
etc.
The issues I have identified are:
- we'll have a two cases of compiler warnings:
- printf() format of the return values from %d to %f
- clutter_actor_get_size() taking floats instead of unsigned ints
- we'll have a problem with varargs when passing an integer instead
of a floating point value, except on 64bit platforms where the
size of a float is the same as the size of an int
To be clear: the *intent* of the API should not change -- we still use
pixels everywhere -- but:
- we remove ambiguity in the API with regard to pixels and units
- we remove entry points we get to maintain for the whole 1.0
version of the API
- we make things simpler to bind for both manual language bindings
and automatic (gobject-introspection based) ones
- we have the simplest API possible while still exposing the
capabilities of the underlying GL implementation
2009-05-06 15:44:47 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
event_x = event->scroll.x;
|
|
|
|
event_y = event->scroll.y;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
if (x)
|
|
|
|
*x = event_x;
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
if (y)
|
|
|
|
*y = event_y;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2007-08-13 20:48:01 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_get_source:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the source #ClutterActor the event originated from, or
|
|
|
|
* NULL if the event has no source.
|
|
|
|
*
|
2009-02-17 00:25:20 +00:00
|
|
|
* Return value: (transfer none): a #ClutterActor
|
2007-11-23 13:11:10 +00:00
|
|
|
*
|
2007-08-13 20:48:01 +00:00
|
|
|
* Since: 0.6
|
|
|
|
*/
|
2009-06-06 14:27:37 +00:00
|
|
|
ClutterActor *
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_source (const ClutterEvent *event)
|
2007-08-13 20:48:01 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
2007-11-12 19:12:02 +00:00
|
|
|
return event->any.source;
|
2007-08-13 20:48:01 +00:00
|
|
|
}
|
|
|
|
|
2008-03-28 22:50:55 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_get_stage:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the source #ClutterStage the event originated for, or
|
2009-06-06 14:27:37 +00:00
|
|
|
* %NULL if the event has no stage.
|
2008-03-28 22:50:55 +00:00
|
|
|
*
|
2009-02-17 00:25:20 +00:00
|
|
|
* Return value: (transfer none): a #ClutterStage
|
2008-03-28 22:50:55 +00:00
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
2009-06-06 14:27:37 +00:00
|
|
|
ClutterStage *
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_stage (const ClutterEvent *event)
|
2008-03-28 22:50:55 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
|
|
|
return event->any.stage;
|
|
|
|
}
|
|
|
|
|
2006-06-22 14:31:19 +00:00
|
|
|
/**
|
2009-06-06 14:27:37 +00:00
|
|
|
* clutter_event_get_flags:
|
|
|
|
* @event: a #ClutterEvent
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Retrieves the #ClutterEventFlags of @event
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Return value: the event flags
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
ClutterEventFlags
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_flags (const ClutterEvent *event)
|
2009-06-06 14:27:37 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_EVENT_NONE);
|
|
|
|
|
|
|
|
return event->any.flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_related:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_ENTER or of
|
|
|
|
* type %CLUTTER_LEAVE
|
|
|
|
*
|
|
|
|
* Retrieves the related actor of a crossing event.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the related #ClutterActor, or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
ClutterActor *
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_related (const ClutterEvent *event)
|
2009-06-06 14:27:37 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_ENTER ||
|
|
|
|
event->type == CLUTTER_LEAVE, NULL);
|
|
|
|
|
|
|
|
return event->crossing.related;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_scroll_direction:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_SCROLL
|
|
|
|
*
|
|
|
|
* Retrieves the direction of the scrolling of @event
|
|
|
|
*
|
|
|
|
* Return value: the scrolling direction
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
ClutterScrollDirection
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_scroll_direction (const ClutterEvent *event)
|
2009-06-06 14:27:37 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_SCROLL_UP);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_SCROLL, CLUTTER_SCROLL_UP);
|
|
|
|
|
|
|
|
return event->scroll.direction;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_button:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_BUTTON_PRESS or
|
|
|
|
* of type %CLUTTER_BUTTON_RELEASE
|
|
|
|
*
|
|
|
|
* Retrieves the button number of @event
|
|
|
|
*
|
|
|
|
* Return value: the button number
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
guint32
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_button (const ClutterEvent *event)
|
2009-06-06 14:27:37 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_BUTTON_PRESS ||
|
|
|
|
event->type == CLUTTER_BUTTON_RELEASE, 0);
|
|
|
|
|
|
|
|
return event->button.button;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_click_count:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_BUTTON_PRESS or
|
|
|
|
* of type %CLUTTER_BUTTON_RELEASE
|
|
|
|
*
|
|
|
|
* Retrieves the number of clicks of @event
|
|
|
|
*
|
|
|
|
* Return value: the click count
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
2006-06-22 14:31:19 +00:00
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
guint32
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_click_count (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-06-06 14:27:37 +00:00
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_BUTTON_PRESS ||
|
|
|
|
event->type == CLUTTER_BUTTON_RELEASE, 0);
|
2006-05-29 08:59:36 +00:00
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
return event->button.click_count;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
/* keys */
|
|
|
|
|
2006-06-22 14:31:19 +00:00
|
|
|
/**
|
2009-06-06 14:27:37 +00:00
|
|
|
* clutter_event_get_key_symbol:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS or
|
|
|
|
* of type %CLUTTER_KEY_RELEASE
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Retrieves the key symbol of @event
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Return value: the key symbol representing the key
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
2006-06-22 14:31:19 +00:00
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
guint
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_key_symbol (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-06-06 14:27:37 +00:00
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE, 0);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
return event->key.keyval;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-06-22 14:31:19 +00:00
|
|
|
/**
|
2009-06-06 14:27:37 +00:00
|
|
|
* clutter_event_get_key_code:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS or
|
|
|
|
* of type %CLUTTER_KEY_RELEASE
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Retrieves the keycode of the key that caused @event
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
|
|
|
* Return value: The keycode representing the key
|
2009-06-06 14:27:37 +00:00
|
|
|
*
|
|
|
|
* Since: 1.0
|
2006-06-22 14:31:19 +00:00
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
guint16
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_key_code (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-06-06 14:27:37 +00:00
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE, 0);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
return event->key.hardware_keycode;
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
2006-06-22 14:31:19 +00:00
|
|
|
/**
|
2009-06-06 14:27:37 +00:00
|
|
|
* clutter_event_get_key_unicode:
|
2009-06-09 13:47:36 +00:00
|
|
|
* @event: A #ClutterKeyEvent
|
2006-06-22 14:31:19 +00:00
|
|
|
*
|
|
|
|
* Retrieves the unicode value for the key that caused @keyev.
|
|
|
|
*
|
|
|
|
* Return value: The unicode value representing the key
|
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
guint32
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_key_unicode (const ClutterEvent *event)
|
2006-05-29 08:59:36 +00:00
|
|
|
{
|
2009-06-06 14:27:37 +00:00
|
|
|
g_return_val_if_fail (event != NULL, 0);
|
|
|
|
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE, 0);
|
2008-06-09 10:13:20 +00:00
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
if (event->key.unicode_value)
|
|
|
|
return event->key.unicode_value;
|
2008-06-09 10:13:20 +00:00
|
|
|
else
|
2009-06-06 14:27:37 +00:00
|
|
|
return clutter_keysym_to_unicode (event->key.keyval);
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_keysym_to_unicode:
|
2008-12-08 13:57:10 +00:00
|
|
|
* @keyval: a key symbol
|
2006-05-29 08:59:36 +00:00
|
|
|
*
|
2007-06-11 09:02:28 +00:00
|
|
|
* Convert from a Clutter key symbol to the corresponding ISO10646 (Unicode)
|
2006-05-29 08:59:36 +00:00
|
|
|
* character.
|
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Return value: a Unicode character, or 0 if there is no corresponding
|
|
|
|
* character.
|
|
|
|
*/
|
2006-05-29 08:59:36 +00:00
|
|
|
guint32
|
|
|
|
clutter_keysym_to_unicode (guint keyval)
|
|
|
|
{
|
|
|
|
int min = 0;
|
|
|
|
int max = G_N_ELEMENTS (clutter_keysym_to_unicode_tab) - 1;
|
|
|
|
int mid;
|
|
|
|
|
|
|
|
/* First check for Latin-1 characters (1:1 mapping) */
|
|
|
|
if ((keyval >= 0x0020 && keyval <= 0x007e) ||
|
|
|
|
(keyval >= 0x00a0 && keyval <= 0x00ff))
|
|
|
|
return keyval;
|
|
|
|
|
|
|
|
/* Also check for directly encoded 24-bit UCS characters:
|
|
|
|
*/
|
|
|
|
if ((keyval & 0xff000000) == 0x01000000)
|
|
|
|
return keyval & 0x00ffffff;
|
|
|
|
|
|
|
|
/* binary search in table */
|
2009-06-06 14:27:37 +00:00
|
|
|
while (max >= min)
|
|
|
|
{
|
|
|
|
mid = (min + max) / 2;
|
|
|
|
|
|
|
|
if (clutter_keysym_to_unicode_tab[mid].keysym < keyval)
|
|
|
|
min = mid + 1;
|
|
|
|
else if (clutter_keysym_to_unicode_tab[mid].keysym > keyval)
|
|
|
|
max = mid - 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* found it */
|
|
|
|
return clutter_keysym_to_unicode_tab[mid].ucs;
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* No matching Unicode value found */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-23 09:55:42 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_get_device_id:
|
|
|
|
* @event: a clutter event
|
2009-06-19 12:07:20 +00:00
|
|
|
*
|
2008-06-23 09:55:42 +00:00
|
|
|
* Retrieves the events device id if set.
|
2009-06-19 12:07:20 +00:00
|
|
|
*
|
2008-06-23 09:55:42 +00:00
|
|
|
* Return value: A unique identifier for the device or -1 if the event has
|
2009-06-06 14:27:37 +00:00
|
|
|
* no specific device set.
|
|
|
|
*/
|
2008-06-23 09:55:42 +00:00
|
|
|
gint
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_device_id (const ClutterEvent *event)
|
2008-06-23 09:55:42 +00:00
|
|
|
{
|
|
|
|
ClutterInputDevice *device = NULL;
|
|
|
|
|
2008-07-01 11:51:20 +00:00
|
|
|
g_return_val_if_fail (event != NULL, -1);
|
2008-06-23 18:58:33 +00:00
|
|
|
|
2008-06-23 09:55:42 +00:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
break;
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
device = event->button.device;
|
|
|
|
break;
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
device = event->motion.device;
|
|
|
|
break;
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
device = event->scroll.device;
|
|
|
|
break;
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2009-06-06 14:27:37 +00:00
|
|
|
device = event->scroll.device;
|
2008-06-23 09:55:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
if (device != NULL)
|
2010-10-21 09:54:14 +00:00
|
|
|
return clutter_input_device_get_device_id (device);
|
2008-06-23 09:55:42 +00:00
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_get_device_type:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the type of the device for @event
|
|
|
|
*
|
|
|
|
* Return value: the #ClutterInputDeviceType for the device, if
|
|
|
|
* any is set
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
ClutterInputDeviceType
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_device_type (const ClutterEvent *event)
|
2009-06-19 12:07:20 +00:00
|
|
|
{
|
|
|
|
ClutterInputDevice *device = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_POINTER_DEVICE);
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
device = event->button.device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
device = event->motion.device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
device = event->scroll.device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
device = event->scroll.device;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device != NULL)
|
2010-10-21 09:54:14 +00:00
|
|
|
return clutter_input_device_get_device_type (device);
|
2009-06-19 12:07:20 +00:00
|
|
|
else
|
|
|
|
return CLUTTER_POINTER_DEVICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_device:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterInputDevice for the event.
|
|
|
|
*
|
|
|
|
* The #ClutterInputDevice structure is completely opaque and should
|
|
|
|
* be cast to the platform-specific implementation.
|
|
|
|
*
|
2010-09-03 11:14:50 +00:00
|
|
|
* Return value: (transfer none): the #ClutterInputDevice or %NULL. The
|
|
|
|
* returned device is owned by the #ClutterEvent and it should not
|
|
|
|
* be unreferenced
|
2009-06-19 12:07:20 +00:00
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
ClutterInputDevice *
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_get_device (const ClutterEvent *event)
|
2009-06-19 12:07:20 +00:00
|
|
|
{
|
|
|
|
ClutterInputDevice *device = NULL;
|
|
|
|
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
device = event->button.device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
device = event->motion.device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
device = event->scroll.device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2010-06-29 14:30:25 +00:00
|
|
|
device = event->key.device;
|
2009-06-19 12:07:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return device;
|
|
|
|
}
|
|
|
|
|
2006-06-22 13:44:47 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_new:
|
|
|
|
* @type: The type of event.
|
|
|
|
*
|
|
|
|
* Creates a new #ClutterEvent of the specified type.
|
|
|
|
*
|
2006-06-22 13:50:39 +00:00
|
|
|
* Return value: A newly allocated #ClutterEvent.
|
2006-06-22 13:44:47 +00:00
|
|
|
*/
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
ClutterEvent *
|
|
|
|
clutter_event_new (ClutterEventType type)
|
|
|
|
{
|
|
|
|
ClutterEvent *new_event;
|
2010-06-14 17:01:17 +00:00
|
|
|
ClutterEventPrivate *priv;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
priv = g_slice_new0 (ClutterEventPrivate);
|
|
|
|
|
|
|
|
new_event = (ClutterEvent *) priv;
|
2007-03-22 18:21:59 +00:00
|
|
|
new_event->type = new_event->any.type = type;
|
|
|
|
|
2010-09-08 14:15:57 +00:00
|
|
|
if (G_UNLIKELY (all_events == NULL))
|
2010-06-14 17:01:17 +00:00
|
|
|
all_events = g_hash_table_new (NULL, NULL);
|
|
|
|
|
|
|
|
g_hash_table_replace (all_events, priv, GUINT_TO_POINTER (1));
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
return new_event;
|
|
|
|
}
|
|
|
|
|
2006-06-22 13:44:47 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_copy:
|
|
|
|
* @event: A #ClutterEvent.
|
|
|
|
*
|
|
|
|
* Copies @event.
|
|
|
|
*
|
|
|
|
* Return value: A newly allocated #ClutterEvent
|
|
|
|
*/
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
ClutterEvent *
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_copy (const ClutterEvent *event)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
|
|
|
ClutterEvent *new_event;
|
2011-01-18 22:31:14 +00:00
|
|
|
ClutterEventPrivate *new_real_event;
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
new_event = clutter_event_new (CLUTTER_NOTHING);
|
2011-01-18 22:31:14 +00:00
|
|
|
new_real_event = (ClutterEventPrivate *) new_event;
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
*new_event = *event;
|
|
|
|
|
2011-01-18 22:31:14 +00:00
|
|
|
if (is_event_allocated (event))
|
|
|
|
{
|
|
|
|
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
|
|
|
|
|
|
|
|
new_real_event->source_device = real_event->source_device;
|
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
if (event->button.device != NULL && event->button.axes != NULL)
|
|
|
|
{
|
|
|
|
gint n_axes;
|
|
|
|
|
|
|
|
n_axes = clutter_input_device_get_n_axes (event->button.device);
|
|
|
|
new_event->button.axes = g_memdup (event->button.axes,
|
|
|
|
sizeof (gdouble) * n_axes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-01-18 22:31:14 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
if (event->scroll.device != NULL && event->scroll.axes != NULL)
|
|
|
|
{
|
|
|
|
gint n_axes;
|
|
|
|
|
|
|
|
n_axes = clutter_input_device_get_n_axes (event->scroll.device);
|
|
|
|
new_event->scroll.axes = g_memdup (event->scroll.axes,
|
|
|
|
sizeof (gdouble) * n_axes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
case CLUTTER_MOTION:
|
|
|
|
if (event->motion.device != NULL && event->motion.axes != NULL)
|
|
|
|
{
|
|
|
|
gint n_axes;
|
|
|
|
|
|
|
|
n_axes = clutter_input_device_get_n_axes (event->motion.device);
|
|
|
|
new_event->motion.axes = g_memdup (event->motion.axes,
|
|
|
|
sizeof (gdouble) * n_axes);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
if (is_event_allocated (event))
|
|
|
|
_clutter_backend_copy_event_data (clutter_get_default_backend (),
|
|
|
|
event,
|
|
|
|
new_event);
|
|
|
|
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
return new_event;
|
|
|
|
}
|
|
|
|
|
2006-06-22 13:44:47 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_free:
|
|
|
|
* @event: A #ClutterEvent.
|
|
|
|
*
|
|
|
|
* Frees all resources used by @event.
|
|
|
|
*/
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
void
|
|
|
|
clutter_event_free (ClutterEvent *event)
|
|
|
|
{
|
2009-06-06 14:27:37 +00:00
|
|
|
if (G_LIKELY (event != NULL))
|
2010-06-14 17:01:17 +00:00
|
|
|
{
|
|
|
|
_clutter_backend_free_event_data (clutter_get_default_backend (), event);
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
g_free (event->button.axes);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
g_free (event->motion.axes);
|
|
|
|
break;
|
|
|
|
|
2011-01-18 22:31:14 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
g_free (event->scroll.axes);
|
|
|
|
break;
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
g_hash_table_remove (all_events, event);
|
|
|
|
g_slice_free (ClutterEventPrivate, (ClutterEventPrivate *) event);
|
|
|
|
}
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get:
|
|
|
|
*
|
2007-07-25 22:09:53 +00:00
|
|
|
* Pops an event off the event queue. Applications should not need to call
|
|
|
|
* this.
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
2007-07-25 22:09:53 +00:00
|
|
|
* Return value: A #ClutterEvent or NULL if queue empty
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
2007-08-21 15:48:13 +00:00
|
|
|
ClutterEvent *
|
2007-03-22 18:21:59 +00:00
|
|
|
clutter_event_get (void)
|
|
|
|
{
|
2009-06-17 16:59:54 +00:00
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2007-08-21 15:48:13 +00:00
|
|
|
|
|
|
|
if (!context->events_queue)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (g_queue_is_empty (context->events_queue))
|
|
|
|
return NULL;
|
|
|
|
|
2007-08-23 12:47:25 +00:00
|
|
|
return g_queue_pop_tail (context->events_queue);
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_peek:
|
|
|
|
*
|
2007-07-25 22:09:53 +00:00
|
|
|
* Returns a pointer to the first event from the event queue but
|
|
|
|
* does not remove it.
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
2009-02-17 00:25:20 +00:00
|
|
|
* Return value: (transfer none): A #ClutterEvent or NULL if queue empty.
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
|
|
|
ClutterEvent *
|
|
|
|
clutter_event_peek (void)
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
{
|
2009-06-17 16:59:54 +00:00
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2007-05-09 23:31:08 +00:00
|
|
|
|
2007-08-23 12:47:25 +00:00
|
|
|
g_return_val_if_fail (context != NULL, NULL);
|
|
|
|
|
|
|
|
if (context->events_queue == NULL)
|
2007-08-21 15:48:13 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (g_queue_is_empty (context->events_queue))
|
2007-05-09 23:31:08 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-08-23 12:47:25 +00:00
|
|
|
return g_queue_peek_tail (context->events_queue);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 13:38:31 +00:00
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
void
|
|
|
|
_clutter_event_push (const ClutterEvent *event,
|
|
|
|
gboolean do_copy)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2011-01-19 16:23:45 +00:00
|
|
|
ClutterInputDevice *device;
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
|
|
|
|
/* FIXME: check queue is valid */
|
|
|
|
g_assert (context != NULL);
|
|
|
|
|
2011-01-19 16:23:45 +00:00
|
|
|
/* disabled devices don't propagate events */
|
|
|
|
device = clutter_event_get_device (event);
|
|
|
|
if (device != NULL)
|
|
|
|
{
|
|
|
|
if (!clutter_input_device_get_enabled (device))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
if (do_copy)
|
|
|
|
{
|
|
|
|
ClutterEvent *copy;
|
|
|
|
|
|
|
|
copy = clutter_event_copy (event);
|
|
|
|
copy->any.flags |= CLUTTER_EVENT_FLAG_SYNTHETIC;
|
|
|
|
|
|
|
|
event = copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_queue_push_head (context->events_queue, (gpointer) event);
|
|
|
|
}
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_put:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
2009-06-06 14:27:37 +00:00
|
|
|
* Puts a copy of the event on the back of the event queue. The event will
|
|
|
|
* have the %CLUTTER_EVENT_FLAG_SYNTHETIC flag set. If the source is set
|
|
|
|
* event signals will be emitted for this source and capture/bubbling for
|
|
|
|
* its ancestors. If the source is not set it will be generated by picking
|
|
|
|
* or use the actor that currently has keyboard focus
|
2007-03-22 18:21:59 +00:00
|
|
|
*
|
2007-10-15 16:50:59 +00:00
|
|
|
* Since: 0.6
|
2007-03-22 18:21:59 +00:00
|
|
|
*/
|
|
|
|
void
|
2010-09-08 14:15:57 +00:00
|
|
|
clutter_event_put (const ClutterEvent *event)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
event/x11: Rework the way we translate X11 events
This is a lump commit that is fairly difficult to break down without
either breaking bisecting or breaking the test cases.
The new design for handling X11 event translation works this way:
- ClutterBackend::translate_event() has been added as the central
point used by a ClutterBackend implementation to translate a
native event into a ClutterEvent;
- ClutterEventTranslator is a private interface that should be
implemented by backend-specific objects, like stage
implementations and ClutterDeviceManager sub-classes, and
allows dealing with class-specific event translation;
- ClutterStageX11 implements EventTranslator, and deals with the
stage-relative X11 events coming from the X11 event source;
- ClutterStageGLX overrides EventTranslator, in order to
deal with the INTEL_GLX_swap_event extension, and it chains up
to the X11 default implementation;
- ClutterDeviceManagerX11 has been split into two separate classes,
one that deals with core and (optionally) XI1 events, and the
other that deals with XI2 events; the selection is done at run-time,
since the core+XI1 and XI2 mechanisms are mutually exclusive.
All the other backends we officially support still use their own
custom event source and translation function, but the end goal is to
migrate them to the translate_event() virtual function, and have the
event source be a shared part of Clutter core.
2011-01-04 12:32:04 +00:00
|
|
|
_clutter_event_push (event, TRUE);
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
2007-07-25 22:09:53 +00:00
|
|
|
/**
|
|
|
|
* clutter_events_pending:
|
|
|
|
*
|
|
|
|
* Checks if events are pending in the event queue.
|
|
|
|
*
|
|
|
|
* Return value: TRUE if there are pending events, FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
2007-03-22 18:21:59 +00:00
|
|
|
gboolean
|
2007-05-09 23:31:08 +00:00
|
|
|
clutter_events_pending (void)
|
2007-03-22 18:21:59 +00:00
|
|
|
{
|
2009-06-17 16:59:54 +00:00
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-05-09 23:31:08 +00:00
|
|
|
g_return_val_if_fail (context != NULL, FALSE);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-05-09 23:31:08 +00:00
|
|
|
if (!context->events_queue)
|
|
|
|
return FALSE;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
2007-08-23 12:47:25 +00:00
|
|
|
return g_queue_is_empty (context->events_queue) == FALSE;
|
2007-03-22 18:21:59 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 11:38:16 +00:00
|
|
|
/**
|
|
|
|
* clutter_get_current_event_time:
|
|
|
|
*
|
|
|
|
* Retrieves the timestamp of the last event, if there is an
|
|
|
|
* event or if the event has a timestamp.
|
|
|
|
*
|
|
|
|
* Return value: the event timestamp, or %CLUTTER_CURRENT_TIME
|
|
|
|
*
|
|
|
|
* Since: 1.0
|
|
|
|
*/
|
|
|
|
guint32
|
|
|
|
clutter_get_current_event_time (void)
|
|
|
|
{
|
2009-06-17 16:59:54 +00:00
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
2009-02-14 11:38:16 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (context != NULL, FALSE);
|
|
|
|
|
|
|
|
if (context->last_event_time != 0)
|
|
|
|
return context->last_event_time;
|
|
|
|
|
|
|
|
return CLUTTER_CURRENT_TIME;
|
|
|
|
}
|
2009-06-19 12:07:20 +00:00
|
|
|
|
2009-11-12 22:33:15 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2011-01-18 14:09:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_source_device:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the hardware device that originated the event.
|
|
|
|
*
|
|
|
|
* If you need the virtual device, use clutter_event_get_device().
|
|
|
|
*
|
|
|
|
* If no hardware device originated this event, this function will
|
|
|
|
* return the same device as clutter_event_get_device().
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): a pointer to a #ClutterInputDevice
|
|
|
|
* or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
ClutterInputDevice *
|
|
|
|
clutter_event_get_source_device (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterEventPrivate *real_event;
|
|
|
|
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
real_event = (ClutterEventPrivate *) event;
|
|
|
|
|
|
|
|
if (real_event->source_device != NULL)
|
|
|
|
return real_event->source_device;
|
|
|
|
|
|
|
|
return clutter_event_get_device (event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_event_set_device (ClutterEvent *event,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
event->button.device = device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
event->motion.device = device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
event->scroll.device = device;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
event->key.device = device;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_event_set_source_device (ClutterEvent *event,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
ClutterEventPrivate *real_event;
|
|
|
|
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return;
|
|
|
|
|
|
|
|
real_event = (ClutterEventPrivate *) event;
|
|
|
|
real_event->source_device = device;
|
|
|
|
}
|
2011-01-18 16:54:12 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_axes:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @n_axes: (out): return location for the number of axes returned
|
|
|
|
*
|
|
|
|
* Retrieves the array of axes values attached to the event.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): an array of axis values
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
gdouble *
|
|
|
|
clutter_event_get_axes (const ClutterEvent *event,
|
|
|
|
guint *n_axes)
|
|
|
|
{
|
|
|
|
gdouble *retval = NULL;
|
|
|
|
guint len = 0;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
retval = event->button.axes;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
retval = event->motion.axes;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (retval != NULL)
|
|
|
|
{
|
|
|
|
ClutterInputDevice *device;
|
|
|
|
|
|
|
|
device = clutter_event_get_device (event);
|
|
|
|
if (device != NULL)
|
|
|
|
len = clutter_input_device_get_n_axes (device);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n_axes)
|
|
|
|
*n_axes = len;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|