mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
Constify Event accessors and copy method
This is still C, but at least we can get some sort of safety net when using the API correctly.
This commit is contained in:
parent
8fb4c7b9a9
commit
e4870ebaf4
@ -519,9 +519,9 @@ _clutter_backend_get_units_per_em (ClutterBackend *backend,
|
||||
}
|
||||
|
||||
void
|
||||
_clutter_backend_copy_event_data (ClutterBackend *backend,
|
||||
ClutterEvent *src,
|
||||
ClutterEvent *dest)
|
||||
_clutter_backend_copy_event_data (ClutterBackend *backend,
|
||||
const ClutterEvent *src,
|
||||
ClutterEvent *dest)
|
||||
{
|
||||
ClutterBackendClass *klass;
|
||||
|
||||
|
@ -85,11 +85,11 @@ struct _ClutterBackendClass
|
||||
ClutterStage *stage);
|
||||
ClutterDeviceManager *(* get_device_manager) (ClutterBackend *backend);
|
||||
|
||||
void (* copy_event_data) (ClutterBackend *backend,
|
||||
ClutterEvent *src,
|
||||
ClutterEvent *dest);
|
||||
void (* free_event_data) (ClutterBackend *backend,
|
||||
ClutterEvent *event);
|
||||
void (* copy_event_data) (ClutterBackend *backend,
|
||||
const ClutterEvent *src,
|
||||
ClutterEvent *dest);
|
||||
void (* free_event_data) (ClutterBackend *backend,
|
||||
ClutterEvent *event);
|
||||
|
||||
/* signals */
|
||||
void (* resolution_changed) (ClutterBackend *backend);
|
||||
|
@ -98,7 +98,7 @@ _clutter_event_set_platform_data (ClutterEvent *event,
|
||||
* Return value: a #ClutterEventType
|
||||
*/
|
||||
ClutterEventType
|
||||
clutter_event_type (ClutterEvent *event)
|
||||
clutter_event_type (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, CLUTTER_NOTHING);
|
||||
|
||||
@ -116,7 +116,7 @@ clutter_event_type (ClutterEvent *event)
|
||||
* Since: 0.4
|
||||
*/
|
||||
guint32
|
||||
clutter_event_get_time (ClutterEvent *event)
|
||||
clutter_event_get_time (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, CLUTTER_CURRENT_TIME);
|
||||
|
||||
@ -134,7 +134,7 @@ clutter_event_get_time (ClutterEvent *event)
|
||||
* Since: 0.4
|
||||
*/
|
||||
ClutterModifierType
|
||||
clutter_event_get_state (ClutterEvent *event)
|
||||
clutter_event_get_state (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, 0);
|
||||
|
||||
@ -164,17 +164,17 @@ clutter_event_get_state (ClutterEvent *event)
|
||||
/**
|
||||
* clutter_event_get_coords:
|
||||
* @event: a #ClutterEvent
|
||||
* @x: return location for the X coordinate
|
||||
* @y: return location for the Y coordinate
|
||||
* @x: (out): return location for the X coordinate, or %NULL
|
||||
* @y: (out): return location for the Y coordinate, or %NULL
|
||||
*
|
||||
* Retrieves the coordinates of @event and puts them into @x and @y.
|
||||
*
|
||||
* Since: 0.4
|
||||
*/
|
||||
void
|
||||
clutter_event_get_coords (ClutterEvent *event,
|
||||
gfloat *x,
|
||||
gfloat *y)
|
||||
clutter_event_get_coords (const ClutterEvent *event,
|
||||
gfloat *x,
|
||||
gfloat *y)
|
||||
{
|
||||
gfloat event_x, event_y;
|
||||
|
||||
@ -235,7 +235,7 @@ clutter_event_get_coords (ClutterEvent *event,
|
||||
* Since: 0.6
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_event_get_source (ClutterEvent *event)
|
||||
clutter_event_get_source (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, NULL);
|
||||
|
||||
@ -254,7 +254,7 @@ clutter_event_get_source (ClutterEvent *event)
|
||||
* Since: 0.8
|
||||
*/
|
||||
ClutterStage *
|
||||
clutter_event_get_stage (ClutterEvent *event)
|
||||
clutter_event_get_stage (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, NULL);
|
||||
|
||||
@ -272,7 +272,7 @@ clutter_event_get_stage (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterEventFlags
|
||||
clutter_event_get_flags (ClutterEvent *event)
|
||||
clutter_event_get_flags (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, CLUTTER_EVENT_NONE);
|
||||
|
||||
@ -291,7 +291,7 @@ clutter_event_get_flags (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterActor *
|
||||
clutter_event_get_related (ClutterEvent *event)
|
||||
clutter_event_get_related (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, NULL);
|
||||
g_return_val_if_fail (event->type == CLUTTER_ENTER ||
|
||||
@ -311,7 +311,7 @@ clutter_event_get_related (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterScrollDirection
|
||||
clutter_event_get_scroll_direction (ClutterEvent *event)
|
||||
clutter_event_get_scroll_direction (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, CLUTTER_SCROLL_UP);
|
||||
g_return_val_if_fail (event->type == CLUTTER_SCROLL, CLUTTER_SCROLL_UP);
|
||||
@ -331,7 +331,7 @@ clutter_event_get_scroll_direction (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
guint32
|
||||
clutter_event_get_button (ClutterEvent *event)
|
||||
clutter_event_get_button (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, 0);
|
||||
g_return_val_if_fail (event->type == CLUTTER_BUTTON_PRESS ||
|
||||
@ -352,7 +352,7 @@ clutter_event_get_button (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
guint32
|
||||
clutter_event_get_click_count (ClutterEvent *event)
|
||||
clutter_event_get_click_count (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, 0);
|
||||
g_return_val_if_fail (event->type == CLUTTER_BUTTON_PRESS ||
|
||||
@ -375,7 +375,7 @@ clutter_event_get_click_count (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
guint
|
||||
clutter_event_get_key_symbol (ClutterEvent *event)
|
||||
clutter_event_get_key_symbol (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, 0);
|
||||
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
||||
@ -396,7 +396,7 @@ clutter_event_get_key_symbol (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
guint16
|
||||
clutter_event_get_key_code (ClutterEvent *event)
|
||||
clutter_event_get_key_code (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, 0);
|
||||
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
||||
@ -414,7 +414,7 @@ clutter_event_get_key_code (ClutterEvent *event)
|
||||
* Return value: The unicode value representing the key
|
||||
*/
|
||||
guint32
|
||||
clutter_event_get_key_unicode (ClutterEvent *event)
|
||||
clutter_event_get_key_unicode (const ClutterEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (event != NULL, 0);
|
||||
g_return_val_if_fail (event->type == CLUTTER_KEY_PRESS ||
|
||||
@ -483,7 +483,7 @@ clutter_keysym_to_unicode (guint keyval)
|
||||
* no specific device set.
|
||||
*/
|
||||
gint
|
||||
clutter_event_get_device_id (ClutterEvent *event)
|
||||
clutter_event_get_device_id (const ClutterEvent *event)
|
||||
{
|
||||
ClutterInputDevice *device = NULL;
|
||||
|
||||
@ -533,7 +533,7 @@ clutter_event_get_device_id (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterInputDeviceType
|
||||
clutter_event_get_device_type (ClutterEvent *event)
|
||||
clutter_event_get_device_type (const ClutterEvent *event)
|
||||
{
|
||||
ClutterInputDevice *device = NULL;
|
||||
|
||||
@ -591,7 +591,7 @@ clutter_event_get_device_type (ClutterEvent *event)
|
||||
* Since: 1.0
|
||||
*/
|
||||
ClutterInputDevice *
|
||||
clutter_event_get_device (ClutterEvent *event)
|
||||
clutter_event_get_device (const ClutterEvent *event)
|
||||
{
|
||||
ClutterInputDevice *device = NULL;
|
||||
|
||||
@ -661,7 +661,7 @@ clutter_event_new (ClutterEventType type)
|
||||
new_event = (ClutterEvent *) priv;
|
||||
new_event->type = new_event->any.type = type;
|
||||
|
||||
if (all_events == NULL)
|
||||
if (G_UNLIKELY (all_events == NULL))
|
||||
all_events = g_hash_table_new (NULL, NULL);
|
||||
|
||||
g_hash_table_replace (all_events, priv, GUINT_TO_POINTER (1));
|
||||
@ -678,7 +678,7 @@ clutter_event_new (ClutterEventType type)
|
||||
* Return value: A newly allocated #ClutterEvent
|
||||
*/
|
||||
ClutterEvent *
|
||||
clutter_event_copy (ClutterEvent *event)
|
||||
clutter_event_copy (const ClutterEvent *event)
|
||||
{
|
||||
ClutterEvent *new_event;
|
||||
|
||||
@ -776,7 +776,7 @@ clutter_event_peek (void)
|
||||
* Since: 0.6
|
||||
*/
|
||||
void
|
||||
clutter_event_put (ClutterEvent *event)
|
||||
clutter_event_put (const ClutterEvent *event)
|
||||
{
|
||||
ClutterMainContext *context = _clutter_context_get_default ();
|
||||
ClutterEvent *event_copy;
|
||||
|
@ -441,38 +441,38 @@ GType clutter_event_get_type (void) G_GNUC_CONST;
|
||||
gboolean clutter_events_pending (void);
|
||||
ClutterEvent * clutter_event_get (void);
|
||||
ClutterEvent * clutter_event_peek (void);
|
||||
void clutter_event_put (ClutterEvent *event);
|
||||
void clutter_event_put (const ClutterEvent *event);
|
||||
|
||||
ClutterEvent * clutter_event_new (ClutterEventType type);
|
||||
ClutterEvent * clutter_event_copy (ClutterEvent *event);
|
||||
void clutter_event_free (ClutterEvent *event);
|
||||
ClutterEvent * clutter_event_new (ClutterEventType type);
|
||||
ClutterEvent * clutter_event_copy (const ClutterEvent *event);
|
||||
void clutter_event_free (ClutterEvent *event);
|
||||
|
||||
ClutterEventType clutter_event_type (ClutterEvent *event);
|
||||
ClutterEventFlags clutter_event_get_flags (ClutterEvent *event);
|
||||
guint32 clutter_event_get_time (ClutterEvent *event);
|
||||
ClutterModifierType clutter_event_get_state (ClutterEvent *event);
|
||||
gint clutter_event_get_device_id (ClutterEvent *event);
|
||||
ClutterInputDeviceType clutter_event_get_device_type (ClutterEvent *event);
|
||||
ClutterInputDevice * clutter_event_get_device (ClutterEvent *event);
|
||||
ClutterActor * clutter_event_get_source (ClutterEvent *event);
|
||||
ClutterStage * clutter_event_get_stage (ClutterEvent *event);
|
||||
ClutterEventType clutter_event_type (const ClutterEvent *event);
|
||||
ClutterEventFlags clutter_event_get_flags (const ClutterEvent *event);
|
||||
guint32 clutter_event_get_time (const ClutterEvent *event);
|
||||
ClutterModifierType clutter_event_get_state (const ClutterEvent *event);
|
||||
gint clutter_event_get_device_id (const ClutterEvent *event);
|
||||
ClutterInputDeviceType clutter_event_get_device_type (const ClutterEvent *event);
|
||||
ClutterInputDevice * clutter_event_get_device (const ClutterEvent *event);
|
||||
ClutterActor * clutter_event_get_source (const ClutterEvent *event);
|
||||
ClutterStage * clutter_event_get_stage (const ClutterEvent *event);
|
||||
|
||||
void clutter_event_get_coords (ClutterEvent *event,
|
||||
gfloat *x,
|
||||
gfloat *y);
|
||||
void clutter_event_get_coords (const ClutterEvent *event,
|
||||
gfloat *x,
|
||||
gfloat *y);
|
||||
|
||||
guint clutter_event_get_key_symbol (ClutterEvent *event);
|
||||
guint16 clutter_event_get_key_code (ClutterEvent *event);
|
||||
guint32 clutter_event_get_key_unicode (ClutterEvent *event);
|
||||
guint clutter_event_get_key_symbol (const ClutterEvent *event);
|
||||
guint16 clutter_event_get_key_code (const ClutterEvent *event);
|
||||
guint32 clutter_event_get_key_unicode (const ClutterEvent *event);
|
||||
|
||||
guint32 clutter_event_get_button (ClutterEvent *event);
|
||||
guint clutter_event_get_click_count (ClutterEvent *event);
|
||||
guint32 clutter_event_get_button (const ClutterEvent *event);
|
||||
guint clutter_event_get_click_count (const ClutterEvent *event);
|
||||
|
||||
ClutterActor * clutter_event_get_related (ClutterEvent *event);
|
||||
ClutterActor * clutter_event_get_related (const ClutterEvent *event);
|
||||
|
||||
ClutterScrollDirection clutter_event_get_scroll_direction (ClutterEvent *event);
|
||||
ClutterScrollDirection clutter_event_get_scroll_direction (const ClutterEvent *event);
|
||||
|
||||
guint32 clutter_keysym_to_unicode (guint keyval);
|
||||
guint32 clutter_keysym_to_unicode (guint keyval);
|
||||
|
||||
guint32 clutter_get_current_event_time (void);
|
||||
G_CONST_RETURN ClutterEvent *clutter_get_current_event (void);
|
||||
|
@ -291,11 +291,11 @@ gboolean _clutter_backend_post_parse (ClutterBackend *backend,
|
||||
GError **error);
|
||||
void _clutter_backend_init_events (ClutterBackend *backend);
|
||||
|
||||
void _clutter_backend_copy_event_data (ClutterBackend *backend,
|
||||
ClutterEvent *src,
|
||||
ClutterEvent *dest);
|
||||
void _clutter_backend_free_event_data (ClutterBackend *backend,
|
||||
ClutterEvent *event);
|
||||
void _clutter_backend_copy_event_data (ClutterBackend *backend,
|
||||
const ClutterEvent *src,
|
||||
ClutterEvent *dest);
|
||||
void _clutter_backend_free_event_data (ClutterBackend *backend,
|
||||
ClutterEvent *event);
|
||||
|
||||
ClutterFeatureFlags _clutter_backend_get_features (ClutterBackend *backend);
|
||||
|
||||
|
@ -482,9 +482,9 @@ clutter_backend_x11_get_features (ClutterBackend *backend)
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_backend_x11_copy_event_data (ClutterBackend *backend,
|
||||
ClutterEvent *src,
|
||||
ClutterEvent *dest)
|
||||
clutter_backend_x11_copy_event_data (ClutterBackend *backend,
|
||||
const ClutterEvent *src,
|
||||
ClutterEvent *dest)
|
||||
{
|
||||
gpointer event_x11;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user