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"
|
2011-02-18 16:27:49 +00:00
|
|
|
#include "clutter-event-private.h"
|
2008-06-09 10:13:20 +00:00
|
|
|
#include "clutter-keysyms.h"
|
2007-03-22 18:21:59 +00:00
|
|
|
#include "clutter-private.h"
|
|
|
|
|
2012-04-19 11:16:54 +00:00
|
|
|
#include <math.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-27 17:21:08 +00:00
|
|
|
ClutterInputDevice *device;
|
2011-01-18 14:09:04 +00:00
|
|
|
ClutterInputDevice *source_device;
|
|
|
|
|
2012-03-19 12:15:41 +00:00
|
|
|
gdouble delta_x;
|
|
|
|
gdouble delta_y;
|
|
|
|
|
2010-06-14 17:01:17 +00:00
|
|
|
gpointer platform_data;
|
2012-03-19 14:28:34 +00:00
|
|
|
|
2013-09-04 12:42:56 +00:00
|
|
|
ClutterModifierType button_state;
|
|
|
|
ClutterModifierType base_state;
|
|
|
|
ClutterModifierType latched_state;
|
|
|
|
ClutterModifierType locked_state;
|
|
|
|
|
2012-03-19 14:28:34 +00:00
|
|
|
guint is_pointer_emulated : 1;
|
2010-06-14 17:01:17 +00:00
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/*< private >
|
|
|
|
* _clutter_event_set_platform_data:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @data: a pointer to platform-specific data
|
|
|
|
*
|
|
|
|
* Sets the pointer to platform-specific data inside an event
|
|
|
|
*
|
|
|
|
* Since: 1.4
|
|
|
|
*/
|
2010-06-14 17:01:17 +00:00
|
|
|
void
|
|
|
|
_clutter_event_set_platform_data (ClutterEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return;
|
|
|
|
|
|
|
|
((ClutterEventPrivate *) event)->platform_data = data;
|
|
|
|
}
|
|
|
|
|
2012-03-19 14:28:34 +00:00
|
|
|
void
|
|
|
|
_clutter_event_set_pointer_emulated (ClutterEvent *event,
|
|
|
|
gboolean is_emulated)
|
|
|
|
{
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return;
|
|
|
|
|
|
|
|
((ClutterEventPrivate *) event)->is_pointer_emulated = !!is_emulated;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_time:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @time_: the time of the event
|
|
|
|
*
|
|
|
|
* Sets the time of the event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_time (ClutterEvent *event,
|
|
|
|
guint32 time_)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
event->any.time = time_;
|
|
|
|
}
|
|
|
|
|
2006-12-12 20:20:04 +00:00
|
|
|
/**
|
2007-03-22 18:21:59 +00:00
|
|
|
* clutter_event_get_state:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
2013-09-04 12:42:56 +00:00
|
|
|
* Retrieves the modifier state of the event. In case the window system
|
|
|
|
* supports reporting latched and locked modifiers, this function returns
|
|
|
|
* the effective state.
|
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
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
return event->touch.modifier_state;
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_state:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @state: the modifier state to set
|
|
|
|
*
|
|
|
|
* Sets the modifier state of the event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_state (ClutterEvent *event,
|
|
|
|
ClutterModifierType state)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
event->key.modifier_state = state;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
event->button.modifier_state = state;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
event->motion.modifier_state = state;
|
|
|
|
break;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
event->touch.modifier_state = state;
|
|
|
|
break;
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
event->scroll.modifier_state = state;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-04 12:42:56 +00:00
|
|
|
void
|
|
|
|
_clutter_event_set_state_full (ClutterEvent *event,
|
|
|
|
ClutterModifierType button_state,
|
|
|
|
ClutterModifierType base_state,
|
|
|
|
ClutterModifierType latched_state,
|
|
|
|
ClutterModifierType locked_state,
|
|
|
|
ClutterModifierType effective_state)
|
|
|
|
{
|
|
|
|
ClutterEventPrivate *private = (ClutterEventPrivate*) event;
|
|
|
|
|
|
|
|
private->button_state = button_state;
|
|
|
|
private->base_state = base_state;
|
|
|
|
private->latched_state = latched_state;
|
|
|
|
private->locked_state = locked_state;
|
|
|
|
|
|
|
|
clutter_event_set_state (event, effective_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_state_full:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @button_state: (out) (allow-none): the pressed buttons as a mask
|
|
|
|
* @base_state: (out) (allow-none): the regular pressed modifier keys
|
|
|
|
* @latched_state: (out) (allow-none): the latched modifier keys (currently released but still valid for one key press/release)
|
|
|
|
* @locked_state: (out) (allow-none): the locked modifier keys (valid until the lock key is pressed and released again)
|
|
|
|
* @effective_state: (out) (allow-none): the logical OR of all the state bits above
|
|
|
|
*
|
|
|
|
* Retrieves the decomposition of the keyboard state into button, base,
|
|
|
|
* latched, locked and effective. This can be used to transmit to other
|
|
|
|
* applications, for example when implementing a wayland compositor.
|
|
|
|
*
|
|
|
|
* Since: 1.16
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_get_state_full (const ClutterEvent *event,
|
|
|
|
ClutterModifierType *button_state,
|
|
|
|
ClutterModifierType *base_state,
|
|
|
|
ClutterModifierType *latched_state,
|
|
|
|
ClutterModifierType *locked_state,
|
|
|
|
ClutterModifierType *effective_state)
|
|
|
|
{
|
|
|
|
const ClutterEventPrivate *private = (const ClutterEventPrivate*) event;
|
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
if (button_state)
|
|
|
|
*button_state = private->button_state;
|
|
|
|
if (base_state)
|
|
|
|
*base_state = private->base_state;
|
|
|
|
if (latched_state)
|
|
|
|
*latched_state = private->latched_state;
|
|
|
|
if (locked_state)
|
|
|
|
*locked_state = private->locked_state;
|
|
|
|
if (effective_state)
|
|
|
|
*effective_state = clutter_event_get_state (event);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2012-04-19 11:16:54 +00:00
|
|
|
ClutterPoint coords;
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_event_get_position (event, &coords);
|
|
|
|
|
|
|
|
if (x != NULL)
|
|
|
|
*x = coords.x;
|
|
|
|
|
|
|
|
if (y != NULL)
|
|
|
|
*y = coords.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_position:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @position: a #ClutterPoint
|
|
|
|
*
|
|
|
|
* Retrieves the event coordinates as a #ClutterPoint.
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_get_position (const ClutterEvent *event,
|
|
|
|
ClutterPoint *position)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (position != NULL);
|
2007-03-22 18:21:59 +00:00
|
|
|
|
|
|
|
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:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_EVENT_LAST:
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_point_init (position, 0.f, 0.f);
|
2010-04-28 15:19:37 +00:00
|
|
|
break;
|
|
|
|
|
2007-10-03 09:28:16 +00:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_point_init (position, event->crossing.x, 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:
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_point_init (position, event->button.x, event->button.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_MOTION:
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_point_init (position, event->motion.x, event->motion.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
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_point_init (position, event->touch.x, event->touch.y);
|
2012-03-19 13:47:19 +00:00
|
|
|
break;
|
|
|
|
|
2007-03-22 18:21:59 +00:00
|
|
|
case CLUTTER_SCROLL:
|
2012-04-19 11:16:54 +00:00
|
|
|
clutter_point_init (position, event->scroll.x, event->scroll.y);
|
2007-03-22 18:21:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-05-29 08:59:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_coords:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @x: the X coordinate of the event
|
|
|
|
* @y: the Y coordinate of the event
|
|
|
|
*
|
|
|
|
* Sets the coordinates of the @event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_coords (ClutterEvent *event,
|
|
|
|
gfloat x,
|
|
|
|
gfloat y)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_EVENT_LAST:
|
2011-02-22 17:12:34 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
event->crossing.x = x;
|
|
|
|
event->crossing.y = y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
event->button.x = x;
|
|
|
|
event->button.y = y;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
event->motion.x = x;
|
|
|
|
event->motion.y = y;
|
|
|
|
break;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
event->touch.x = x;
|
|
|
|
event->touch.y = y;
|
|
|
|
break;
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
event->scroll.x = x;
|
|
|
|
event->scroll.y = y;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_source:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @actor: (allow-none): a #ClutterActor, or %NULL
|
|
|
|
*
|
|
|
|
* Sets the source #ClutterActor of @event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_source (ClutterEvent *event,
|
|
|
|
ClutterActor *actor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor));
|
|
|
|
|
|
|
|
event->any.source = actor;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_stage:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @stage: (allow-none): a #ClutterStage, or %NULL
|
|
|
|
*
|
|
|
|
* Sets the source #ClutterStage of the event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_stage (ClutterEvent *event,
|
|
|
|
ClutterStage *stage)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (stage == NULL || CLUTTER_IS_STAGE (stage));
|
|
|
|
|
|
|
|
if (event->any.stage == stage)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event->any.stage = 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;
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_flags:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @flags: a binary OR of #ClutterEventFlags values
|
|
|
|
*
|
|
|
|
* Sets the #ClutterEventFlags of @event
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_flags (ClutterEvent *event,
|
|
|
|
ClutterEventFlags flags)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
if (event->any.flags == flags)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event->any.flags = flags;
|
|
|
|
event->any.flags |= CLUTTER_EVENT_FLAG_SYNTHETIC;
|
|
|
|
}
|
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
2012-04-30 16:12:12 +00:00
|
|
|
* clutter_event_set_related:
|
2011-02-22 17:12:34 +00:00
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_ENTER or %CLUTTER_LEAVE
|
|
|
|
* @actor: (allow-none): a #ClutterActor or %NULL
|
|
|
|
*
|
|
|
|
* Sets the related actor of a crossing event
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_related (ClutterEvent *event,
|
|
|
|
ClutterActor *actor)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_ENTER ||
|
|
|
|
event->type == CLUTTER_LEAVE);
|
|
|
|
g_return_if_fail (actor == NULL || CLUTTER_IS_ACTOR (actor));
|
|
|
|
|
|
|
|
if (event->crossing.related == actor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
event->crossing.related = actor;
|
|
|
|
}
|
|
|
|
|
2012-03-19 12:15:41 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_scroll_delta:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_SCROLL
|
|
|
|
* @dx: delta on the horizontal axis
|
|
|
|
* @dy: delta on the vertical axis
|
|
|
|
*
|
|
|
|
* Sets the precise scrolling information of @event.
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_scroll_delta (ClutterEvent *event,
|
|
|
|
gdouble dx,
|
|
|
|
gdouble dy)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_SCROLL);
|
|
|
|
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return;
|
|
|
|
|
|
|
|
event->scroll.direction = CLUTTER_SCROLL_SMOOTH;
|
|
|
|
|
|
|
|
((ClutterEventPrivate *) event)->delta_x = dx;
|
|
|
|
((ClutterEventPrivate *) event)->delta_y = dy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_scroll_delta:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_SCROLL
|
|
|
|
* @dx: (out): return location for the delta on the horizontal axis
|
|
|
|
* @dy: (out): return location for the delta on the vertical axis
|
|
|
|
*
|
|
|
|
* Retrieves the precise scrolling information of @event.
|
|
|
|
*
|
|
|
|
* The @event has to have a #ClutterScrollEvent.direction value
|
|
|
|
* of %CLUTTER_SCROLL_SMOOTH.
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_get_scroll_delta (const ClutterEvent *event,
|
|
|
|
gdouble *dx,
|
|
|
|
gdouble *dy)
|
|
|
|
{
|
|
|
|
gdouble delta_x, delta_y;
|
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_SCROLL);
|
|
|
|
g_return_if_fail (event->scroll.direction == CLUTTER_SCROLL_SMOOTH);
|
|
|
|
|
|
|
|
delta_x = delta_y = 0;
|
|
|
|
|
|
|
|
if (is_event_allocated (event))
|
|
|
|
{
|
|
|
|
delta_x = ((ClutterEventPrivate *) event)->delta_x;
|
|
|
|
delta_y = ((ClutterEventPrivate *) event)->delta_y;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dx != NULL)
|
|
|
|
*dx = delta_x;
|
|
|
|
|
|
|
|
if (dy != NULL)
|
|
|
|
*dy = delta_y;
|
|
|
|
}
|
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_scroll_direction:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @direction: the scrolling direction
|
|
|
|
*
|
|
|
|
* Sets the direction of the scrolling of @event
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_scroll_direction (ClutterEvent *event,
|
|
|
|
ClutterScrollDirection direction)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_SCROLL);
|
|
|
|
|
|
|
|
event->scroll.direction = direction;
|
|
|
|
}
|
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_button:
|
|
|
|
* @event: a #ClutterEvent or type %CLUTTER_BUTTON_PRESS or
|
|
|
|
* of type %CLUTTER_BUTTON_RELEASE
|
|
|
|
* @button: the button number
|
|
|
|
*
|
|
|
|
* Sets the button number of @event
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_button (ClutterEvent *event,
|
|
|
|
guint32 button)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_BUTTON_PRESS ||
|
|
|
|
event->type == CLUTTER_BUTTON_RELEASE);
|
|
|
|
|
|
|
|
event->button.button = button;
|
|
|
|
}
|
|
|
|
|
2009-06-06 14:27:37 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_key_symbol:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS
|
|
|
|
* or %CLUTTER_KEY_RELEASE
|
|
|
|
* @key_sym: the key symbol representing the key
|
|
|
|
*
|
|
|
|
* Sets the key symbol of @event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_key_symbol (ClutterEvent *event,
|
|
|
|
guint key_sym)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE);
|
|
|
|
|
|
|
|
event->key.keyval = key_sym;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_key_code:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS
|
|
|
|
* or %CLUTTER_KEY_RELEASE
|
|
|
|
* @key_code: the keycode representing the key
|
|
|
|
*
|
|
|
|
* Sets the keycode of the @event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_key_code (ClutterEvent *event,
|
|
|
|
guint16 key_code)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE);
|
|
|
|
|
|
|
|
event->key.hardware_keycode = key_code;
|
|
|
|
}
|
|
|
|
|
2006-06-22 14:31:19 +00:00
|
|
|
/**
|
2009-06-06 14:27:37 +00:00
|
|
|
* clutter_event_get_key_unicode:
|
2011-02-22 17:12:34 +00:00
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS
|
|
|
|
* or %CLUTTER_KEY_RELEASE
|
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
|
|
|
|
*/
|
2013-03-05 06:06:03 +00:00
|
|
|
gunichar
|
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
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_set_key_unicode:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_KEY_PRESS
|
|
|
|
* or %CLUTTER_KEY_RELEASE
|
|
|
|
* @key_unicode: the Unicode value representing the key
|
|
|
|
*
|
|
|
|
* Sets the Unicode value of @event.
|
|
|
|
*
|
|
|
|
* Since: 1.8
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_key_unicode (ClutterEvent *event,
|
2013-03-05 06:06:03 +00:00
|
|
|
gunichar key_unicode)
|
2011-02-22 17:12:34 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
|
|
|
event->type == CLUTTER_KEY_RELEASE);
|
|
|
|
|
|
|
|
event->key.unicode_value = key_unicode;
|
|
|
|
}
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
/**
|
|
|
|
* clutter_event_get_event_sequence:
|
|
|
|
* @event: a #ClutterEvent of type %CLUTTER_TOUCH_BEGIN,
|
|
|
|
* %CLUTTER_TOUCH_UPDATE, %CLUTTER_TOUCH_END, or
|
|
|
|
* %CLUTTER_TOUCH_CANCEL
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterEventSequence of @event.
|
|
|
|
*
|
|
|
|
* Return value: (transfer none): the event sequence, or %NULL
|
|
|
|
*
|
|
|
|
* Since: 1.10
|
|
|
|
*/
|
|
|
|
ClutterEventSequence *
|
|
|
|
clutter_event_get_event_sequence (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
|
|
|
if (event->type == CLUTTER_TOUCH_BEGIN ||
|
|
|
|
event->type == CLUTTER_TOUCH_UPDATE ||
|
|
|
|
event->type == CLUTTER_TOUCH_END ||
|
|
|
|
event->type == CLUTTER_TOUCH_CANCEL)
|
|
|
|
return event->touch.sequence;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2011-01-27 17:21:08 +00:00
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_POINTER_DEVICE);
|
2008-06-23 09:55:42 +00:00
|
|
|
|
2011-01-27 17:21:08 +00:00
|
|
|
device = clutter_event_get_device (event);
|
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);
|
2011-01-27 17:21:08 +00:00
|
|
|
|
|
|
|
return -1;
|
2008-06-23 09:55:42 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
2011-01-27 17:21:08 +00:00
|
|
|
device = clutter_event_get_device (event);
|
|
|
|
if (device != NULL)
|
|
|
|
return clutter_input_device_get_device_type (device);
|
|
|
|
|
|
|
|
return CLUTTER_POINTER_DEVICE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_set_device:
|
|
|
|
* @event: a #ClutterEvent
|
2011-02-22 17:12:34 +00:00
|
|
|
* @device: (allow-none): a #ClutterInputDevice, or %NULL
|
2011-01-27 17:21:08 +00:00
|
|
|
*
|
|
|
|
* Sets the device for @event.
|
|
|
|
*
|
|
|
|
* Since: 1.6
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_set_device (ClutterEvent *event,
|
|
|
|
ClutterInputDevice *device)
|
|
|
|
{
|
|
|
|
g_return_if_fail (event != NULL);
|
2011-01-27 17:26:16 +00:00
|
|
|
g_return_if_fail (device == NULL || CLUTTER_IS_INPUT_DEVICE (device));
|
2011-01-27 17:21:08 +00:00
|
|
|
|
|
|
|
if (is_event_allocated (event))
|
|
|
|
{
|
|
|
|
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
|
|
|
|
|
|
|
|
real_event->device = device;
|
|
|
|
}
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_EVENT_LAST:
|
2011-03-08 10:01:06 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
2011-03-08 10:01:06 +00:00
|
|
|
event->crossing.device = device;
|
2009-06-19 12:07:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
2011-01-27 17:21:08 +00:00
|
|
|
event->button.device = device;
|
2009-06-19 12:07:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_MOTION:
|
2011-01-27 17:21:08 +00:00
|
|
|
event->motion.device = device;
|
2009-06-19 12:07:20 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case CLUTTER_SCROLL:
|
2011-01-27 17:21:08 +00:00
|
|
|
event->scroll.device = device;
|
2009-06-19 12:07:20 +00:00
|
|
|
break;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
event->touch.device = device;
|
|
|
|
break;
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2011-01-27 17:21:08 +00:00
|
|
|
event->key.device = device;
|
2009-06-19 12:07:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_device:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterInputDevice for the event.
|
2013-10-08 09:40:23 +00:00
|
|
|
* If you want the physical device the event originated from, use
|
|
|
|
* clutter_event_get_source_device().
|
2009-06-19 12:07:20 +00:00
|
|
|
*
|
|
|
|
* 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);
|
|
|
|
|
2011-01-27 17:21:08 +00:00
|
|
|
if (is_event_allocated (event))
|
|
|
|
{
|
|
|
|
ClutterEventPrivate *real_event = (ClutterEventPrivate *) event;
|
|
|
|
|
|
|
|
if (real_event->device != NULL)
|
|
|
|
return real_event->device;
|
|
|
|
}
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_EVENT_LAST:
|
2011-03-08 10:05:57 +00:00
|
|
|
break;
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
2011-03-08 10:05:57 +00:00
|
|
|
device = event->crossing.device;
|
2009-06-19 12:07:20 +00:00
|
|
|
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;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
device = event->touch.device;
|
|
|
|
break;
|
|
|
|
|
2009-06-19 12:07:20 +00:00
|
|
|
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.
|
|
|
|
*
|
2011-02-22 17:12:34 +00:00
|
|
|
* Return value: (transfer full): 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.
|
|
|
|
*
|
2011-02-22 17:12:34 +00:00
|
|
|
* Return value: (transfer full): 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 *
|
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;
|
2011-01-21 15:14:11 +00:00
|
|
|
ClutterInputDevice *device;
|
|
|
|
gint n_axes = 0;
|
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;
|
|
|
|
|
2011-01-27 17:21:08 +00:00
|
|
|
new_real_event->device = real_event->device;
|
2011-01-18 22:31:14 +00:00
|
|
|
new_real_event->source_device = real_event->source_device;
|
2012-03-19 12:15:41 +00:00
|
|
|
new_real_event->delta_x = real_event->delta_x;
|
|
|
|
new_real_event->delta_y = real_event->delta_y;
|
2012-07-18 16:28:24 +00:00
|
|
|
new_real_event->is_pointer_emulated = real_event->is_pointer_emulated;
|
2013-09-19 14:38:53 +00:00
|
|
|
new_real_event->base_state = real_event->base_state;
|
|
|
|
new_real_event->button_state = real_event->button_state;
|
|
|
|
new_real_event->latched_state = real_event->latched_state;
|
|
|
|
new_real_event->locked_state = real_event->locked_state;
|
2011-01-18 22:31:14 +00:00
|
|
|
}
|
|
|
|
|
2011-01-21 15:14:11 +00:00
|
|
|
device = clutter_event_get_device (event);
|
|
|
|
if (device != NULL)
|
|
|
|
n_axes = clutter_input_device_get_n_axes (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:
|
2011-01-21 15:14:11 +00:00
|
|
|
if (event->button.axes != NULL)
|
|
|
|
new_event->button.axes = g_memdup (event->button.axes,
|
|
|
|
sizeof (gdouble) * n_axes);
|
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
|
|
|
break;
|
|
|
|
|
2011-01-18 22:31:14 +00:00
|
|
|
case CLUTTER_SCROLL:
|
2011-01-21 15:14:11 +00:00
|
|
|
if (event->scroll.axes != NULL)
|
|
|
|
new_event->scroll.axes = g_memdup (event->scroll.axes,
|
|
|
|
sizeof (gdouble) * n_axes);
|
2011-01-18 22:31:14 +00:00
|
|
|
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:
|
2011-01-21 15:14:11 +00:00
|
|
|
if (event->motion.axes != NULL)
|
|
|
|
new_event->motion.axes = g_memdup (event->motion.axes,
|
|
|
|
sizeof (gdouble) * n_axes);
|
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
|
|
|
break;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
if (event->touch.axes != NULL)
|
2012-05-03 16:56:45 +00:00
|
|
|
new_event->touch.axes = g_memdup (event->touch.axes,
|
2012-03-19 13:47:19 +00:00
|
|
|
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
|
|
|
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;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
g_free (event->touch.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
|
|
|
|
2011-02-09 12:38:10 +00:00
|
|
|
if (context->events_queue == NULL)
|
2007-08-21 15:48:13 +00:00
|
|
|
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
|
|
|
|
|
|
|
g_assert (context != NULL);
|
|
|
|
|
2011-02-09 12:38:10 +00:00
|
|
|
if (context->events_queue == NULL)
|
|
|
|
context->events_queue = g_queue_new ();
|
|
|
|
|
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);
|
|
|
|
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
|
|
|
|
2011-02-09 12:38:10 +00:00
|
|
|
if (context->events_queue == NULL)
|
2007-05-09 23:31:08 +00:00
|
|
|
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)
|
|
|
|
{
|
2012-11-16 15:33:00 +00:00
|
|
|
const ClutterEvent* event;
|
2009-02-14 11:38:16 +00:00
|
|
|
|
2012-11-16 15:33:00 +00:00
|
|
|
event = clutter_get_current_event ();
|
2009-02-14 11:38:16 +00:00
|
|
|
|
2012-11-16 15:33:00 +00:00
|
|
|
if (event != NULL)
|
|
|
|
return clutter_event_get_time (event);
|
2009-02-14 11:38:16 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
Eliminate G_CONST_RETURN
The G_CONST_RETURN define in GLib is, and has always been, a bit fuzzy.
We always used it to conform to the platform, at least for public-facing
API.
At first I assumed it has something to do with brain-damaged compilers
or with weird platforms where const was not really supported; sadly,
it's something much, much worse: it's a define that can be toggled at
compile-time to remove const from the signature of public API. This is a
truly terrifying feature that I assume was added in the past century,
and whose inception clearly had something to do with massive doses of
absynthe and opium — because any other explanation would make the
existence of such a feature even worse than assuming drugs had anything
to do with it.
Anyway, and pleasing the gods, this dubious feature is being
removed/deprecated in GLib; see bug:
https://bugzilla.gnome.org/show_bug.cgi?id=644611
Before deprecation, though, we should just remove its usage from the
whole API. We should especially remove its usage from Cally's internals,
since there it never made sense in the first place.
2011-06-07 14:49:20 +00:00
|
|
|
const ClutterEvent *
|
2009-11-12 22:33:15 +00:00
|
|
|
clutter_get_current_event (void)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context = _clutter_context_get_default ();
|
|
|
|
|
|
|
|
g_return_val_if_fail (context != NULL, NULL);
|
|
|
|
|
2012-11-16 15:33:00 +00:00
|
|
|
return context->current_event != NULL ? context->current_event->data : NULL;
|
2009-11-12 22:33:15 +00:00
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
/**
|
2011-01-27 17:21:08 +00:00
|
|
|
* clutter_event_set_source_device:
|
|
|
|
* @event: a #ClutterEvent
|
2011-02-22 17:12:34 +00:00
|
|
|
* @device: (allow-none): a #ClutterInputDevice
|
2011-01-27 17:21:08 +00:00
|
|
|
*
|
|
|
|
* Sets the source #ClutterInputDevice for @event.
|
|
|
|
*
|
|
|
|
* The #ClutterEvent must have been created using clutter_event_new().
|
|
|
|
*
|
2011-02-22 17:12:34 +00:00
|
|
|
* Since: 1.8
|
2011-01-27 17:21:08 +00:00
|
|
|
*/
|
2011-01-18 14:09:04 +00:00
|
|
|
void
|
2011-02-22 17:12:34 +00:00
|
|
|
clutter_event_set_source_device (ClutterEvent *event,
|
|
|
|
ClutterInputDevice *device)
|
2011-01-18 14:09:04 +00:00
|
|
|
{
|
|
|
|
ClutterEventPrivate *real_event;
|
|
|
|
|
2011-02-22 17:12:34 +00:00
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
g_return_if_fail (device == NULL || CLUTTER_IS_INPUT_DEVICE (device));
|
|
|
|
|
2011-01-18 14:09:04 +00:00
|
|
|
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_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_EVENT_LAST:
|
2011-01-18 16:54:12 +00:00
|
|
|
break;
|
|
|
|
|
2011-01-21 15:14:11 +00:00
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
retval = event->scroll.axes;
|
|
|
|
break;
|
|
|
|
|
2011-01-18 16:54:12 +00:00
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
retval = event->button.axes;
|
|
|
|
break;
|
|
|
|
|
2012-03-19 13:47:19 +00:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
retval = event->touch.axes;
|
|
|
|
break;
|
|
|
|
|
2011-01-18 16:54:12 +00:00
|
|
|
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);
|
2011-01-21 15:14:11 +00:00
|
|
|
else
|
|
|
|
retval = NULL;
|
2011-01-18 16:54:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n_axes)
|
|
|
|
*n_axes = len;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
2012-04-19 11:16:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_distance:
|
|
|
|
* @source: a #ClutterEvent
|
|
|
|
* @target: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the distance between two events, a @source and a @target.
|
|
|
|
*
|
|
|
|
* Return value: the distance between two #ClutterEvent
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
float
|
|
|
|
clutter_event_get_distance (const ClutterEvent *source,
|
|
|
|
const ClutterEvent *target)
|
|
|
|
{
|
|
|
|
ClutterPoint p0, p1;
|
|
|
|
|
|
|
|
clutter_event_get_position (source, &p0);
|
|
|
|
clutter_event_get_position (source, &p1);
|
|
|
|
|
|
|
|
return clutter_point_distance (&p0, &p1, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get_angle:
|
|
|
|
* @source: a #ClutterEvent
|
|
|
|
* @target: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the angle relative from @source to @target.
|
|
|
|
*
|
|
|
|
* The direction of the angle is from the position X axis towards
|
|
|
|
* the positive Y axis.
|
|
|
|
*
|
|
|
|
* Return value: the angle between two #ClutterEvent
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
double
|
|
|
|
clutter_event_get_angle (const ClutterEvent *source,
|
|
|
|
const ClutterEvent *target)
|
|
|
|
{
|
|
|
|
ClutterPoint p0, p1;
|
|
|
|
float x_distance, y_distance;
|
|
|
|
double angle;
|
|
|
|
|
|
|
|
clutter_event_get_position (source, &p0);
|
|
|
|
clutter_event_get_position (target, &p1);
|
|
|
|
|
|
|
|
if (clutter_point_equals (&p0, &p1))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
clutter_point_distance (&p0, &p1, &x_distance, &y_distance);
|
|
|
|
|
|
|
|
angle = atan2 (x_distance, y_distance);
|
|
|
|
|
|
|
|
/* invert the angle, and shift it by 90 degrees */
|
|
|
|
angle = (2.0 * G_PI) - angle;
|
|
|
|
angle += G_PI / 2.0;
|
|
|
|
|
|
|
|
/* keep the angle within the [ 0, 360 ] interval */
|
|
|
|
angle = fmod (angle, 2.0 * G_PI);
|
|
|
|
|
|
|
|
return angle;
|
|
|
|
}
|
2012-05-25 10:33:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_has_shift_modifier:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Checks whether @event has the Shift modifier mask set.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the event has the Shift modifier mask set
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_event_has_shift_modifier (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
return (clutter_event_get_state (event) & CLUTTER_SHIFT_MASK) != FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_has_control_modifier:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Checks whether @event has the Control modifier mask set.
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the event has the Control modifier mask set
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_event_has_control_modifier (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
return (clutter_event_get_state (event) & CLUTTER_CONTROL_MASK) != FALSE;
|
|
|
|
}
|
2012-07-18 14:32:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_is_pointer_emulated:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Checks whether a pointer @event has been generated by the windowing
|
|
|
|
* system. The returned value can be used to distinguish between events
|
|
|
|
* synthesized by the windowing system itself (as opposed by Clutter).
|
|
|
|
*
|
|
|
|
* Return value: %TRUE if the event is pointer emulated
|
|
|
|
*
|
|
|
|
* Since: 1.12
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
clutter_event_is_pointer_emulated (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, FALSE);
|
|
|
|
|
|
|
|
if (!is_event_allocated (event))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return ((ClutterEventPrivate *) event)->is_pointer_emulated;
|
|
|
|
}
|