2006-05-29 04:59:36 -04: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
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2006-06-21 18:34:25 -04:00
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-06-09 06:13:20 -04:00
|
|
|
#include "clutter-keysyms.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "clutter-keysyms-table.h"
|
2006-05-29 04:59:36 -04:00
|
|
|
#include "clutter-event.h"
|
2007-03-22 14:21:59 -04:00
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
|
2007-06-07 11:28:59 -04:00
|
|
|
/**
|
|
|
|
* SECTION:clutter-event
|
|
|
|
* @short_description: User and window system events
|
|
|
|
*
|
|
|
|
* Windowing events handled by Clutter.
|
|
|
|
*/
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
/**
|
|
|
|
* clutter_event_type:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the type of the event.
|
|
|
|
*
|
|
|
|
* Return value: a #ClutterEventType
|
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
ClutterEventType
|
|
|
|
clutter_event_type (ClutterEvent *event)
|
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_NOTHING);
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
return event->type;
|
|
|
|
}
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
/**
|
2007-03-22 14:21:59 -04:00
|
|
|
* clutter_event_get_time:
|
|
|
|
* @event: a #ClutterEvent
|
2006-12-12 15:20:04 -05:00
|
|
|
*
|
|
|
|
* Retrieves the time of the event.
|
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
* Return value: the time of the event, or %CLUTTER_CURRENT_TIME
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2006-12-12 15:20:04 -05:00
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
guint32
|
2007-03-22 14:21:59 -04:00
|
|
|
clutter_event_get_time (ClutterEvent *event)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
g_return_val_if_fail (event != NULL, CLUTTER_CURRENT_TIME);
|
|
|
|
|
2007-10-03 05:28:16 -04:00
|
|
|
return event->any.time;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
/**
|
2007-03-22 14:21:59 -04:00
|
|
|
* clutter_event_get_state:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the modifier state of the event.
|
2006-12-12 15:20:04 -05:00
|
|
|
*
|
2007-07-01 12:44:24 -04:00
|
|
|
* Return value: the modifier state parameter, or 0
|
2006-12-12 15:20:04 -05:00
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
* Since: 0.4
|
2006-12-12 15:20:04 -05:00
|
|
|
*/
|
2007-07-21 12:48:11 -04:00
|
|
|
ClutterModifierType
|
2007-03-22 14:21:59 -04:00
|
|
|
clutter_event_get_state (ClutterEvent *event)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-03-22 14:21:59 -04: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;
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
return event->button.modifier_state;
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
return event->motion.modifier_state;
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
return event->scroll.modifier_state;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2006-12-12 15:20:04 -05:00
|
|
|
/**
|
2007-03-22 14:21:59 -04:00
|
|
|
* clutter_event_get_coords:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
* @x: return location for the X coordinate
|
|
|
|
* @y: return location for the Y coordinate
|
2006-12-12 15:20:04 -05:00
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
* Retrieves the coordinates of @event and puts them into @x and @y.
|
2006-12-12 15:20:04 -05:00
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
* Since: 0.4
|
2006-12-12 15:20:04 -05:00
|
|
|
*/
|
2007-03-22 14:21:59 -04:00
|
|
|
void
|
|
|
|
clutter_event_get_coords (ClutterEvent *event,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
gint event_x, event_y;
|
|
|
|
|
|
|
|
g_return_if_fail (event != NULL);
|
|
|
|
|
|
|
|
event_x = event_y = 0;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
2007-08-21 11:48:51 -04:00
|
|
|
case CLUTTER_NOTHING:
|
2007-03-22 14:21:59 -04:00
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2007-08-21 11:48:51 -04:00
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
2007-10-03 05:28:16 -04:00
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
2007-03-22 14:21:59 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
event_x = event->button.x;
|
|
|
|
event_y = event->button.y;
|
|
|
|
break;
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
event_x = event->motion.x;
|
|
|
|
event_y = event->motion.y;
|
|
|
|
break;
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
event_x = event->scroll.x;
|
|
|
|
event_y = event->scroll.y;
|
|
|
|
break;
|
|
|
|
}
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
if (x)
|
|
|
|
*x = event_x;
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
if (y)
|
|
|
|
*y = event_y;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2007-08-13 16:48:01 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_get_source:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the source #ClutterActor the event originated from, or
|
|
|
|
* NULL if the event has no source.
|
|
|
|
*
|
2007-11-23 08:11:10 -05:00
|
|
|
* Return value: a #ClutterActor
|
|
|
|
*
|
2007-08-13 16:48:01 -04:00
|
|
|
* Since: 0.6
|
|
|
|
*/
|
|
|
|
ClutterActor*
|
|
|
|
clutter_event_get_source (ClutterEvent *event)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
2007-11-12 14:12:02 -05:00
|
|
|
return event->any.source;
|
2007-08-13 16:48:01 -04:00
|
|
|
}
|
|
|
|
|
2008-03-28 18:50:55 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_get_stage:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
|
|
|
* Retrieves the source #ClutterStage the event originated for, or
|
|
|
|
* NULL if the event has no stage.
|
|
|
|
*
|
|
|
|
* Return value: a #ClutterStage
|
|
|
|
*
|
|
|
|
* Since: 0.8
|
|
|
|
*/
|
|
|
|
ClutterStage*
|
|
|
|
clutter_event_get_stage (ClutterEvent *event)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
|
|
|
return event->any.stage;
|
|
|
|
}
|
|
|
|
|
2006-06-22 10:31:19 -04:00
|
|
|
/**
|
2007-03-22 14:21:59 -04:00
|
|
|
* clutter_button_event_button:
|
|
|
|
* @buttev: a #ClutterButtonEvent
|
2006-06-22 10:31:19 -04:00
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
* Retrieve the button number of the event.
|
2006-06-22 10:31:19 -04:00
|
|
|
*
|
2007-03-22 14:21:59 -04:00
|
|
|
* Return value: the button number.
|
|
|
|
*
|
|
|
|
* Since: 0.4
|
2006-06-22 10:31:19 -04:00
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
guint32
|
2007-03-22 14:21:59 -04:00
|
|
|
clutter_button_event_button (ClutterButtonEvent *buttev)
|
2006-05-29 04:59:36 -04:00
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
g_return_val_if_fail (buttev != NULL, 0);
|
2006-05-29 04:59:36 -04:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
return buttev->button;
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
/* keys */
|
|
|
|
|
2006-06-22 10:31:19 -04:00
|
|
|
/**
|
|
|
|
* clutter_key_event_symbol:
|
|
|
|
* @keyev: A #ClutterKeyEvent
|
|
|
|
*
|
|
|
|
* Retrieves the value of the key that caused @keyev.
|
|
|
|
*
|
|
|
|
* Return value: The keysym representing the key
|
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
guint
|
|
|
|
clutter_key_event_symbol (ClutterKeyEvent *keyev)
|
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
g_return_val_if_fail (keyev != NULL, 0);
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
return keyev->keyval;
|
|
|
|
}
|
|
|
|
|
2006-06-22 10:31:19 -04:00
|
|
|
/**
|
|
|
|
* clutter_key_event_code:
|
|
|
|
* @keyev: A #ClutterKeyEvent
|
|
|
|
*
|
|
|
|
* Retrieves the keycode of the key that caused @keyev.
|
|
|
|
*
|
|
|
|
* Return value: The keycode representing the key
|
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
guint16
|
|
|
|
clutter_key_event_code (ClutterKeyEvent *keyev)
|
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
g_return_val_if_fail (keyev != NULL, 0);
|
|
|
|
|
2006-05-29 04:59:36 -04:00
|
|
|
return keyev->hardware_keycode;
|
|
|
|
}
|
|
|
|
|
2006-06-22 10:31:19 -04:00
|
|
|
/**
|
|
|
|
* clutter_key_event_unicode:
|
|
|
|
* @keyev: A #ClutterKeyEvent
|
|
|
|
*
|
|
|
|
* Retrieves the unicode value for the key that caused @keyev.
|
|
|
|
*
|
|
|
|
* Return value: The unicode value representing the key
|
|
|
|
*/
|
2006-05-29 04:59:36 -04:00
|
|
|
guint32
|
|
|
|
clutter_key_event_unicode (ClutterKeyEvent *keyev)
|
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
g_return_val_if_fail (keyev != NULL, 0);
|
2008-06-09 06:13:20 -04:00
|
|
|
|
|
|
|
if (keyev->unicode_value)
|
|
|
|
return keyev->unicode_value;
|
|
|
|
else
|
|
|
|
return clutter_keysym_to_unicode (keyev->keyval);
|
2006-05-29 04:59:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_keysym_to_unicode:
|
|
|
|
* @keyval: a clutter key symbol
|
|
|
|
*
|
2007-06-11 05:02:28 -04:00
|
|
|
* Convert from a Clutter key symbol to the corresponding ISO10646 (Unicode)
|
2006-05-29 04:59:36 -04:00
|
|
|
* character.
|
|
|
|
*
|
|
|
|
* Return value: the corresponding unicode character, or 0 if there
|
|
|
|
* is no corresponding character.
|
|
|
|
**/
|
|
|
|
guint32
|
|
|
|
clutter_keysym_to_unicode (guint keyval)
|
|
|
|
{
|
|
|
|
int min = 0;
|
|
|
|
int max = G_N_ELEMENTS (clutter_keysym_to_unicode_tab) - 1;
|
|
|
|
int mid;
|
|
|
|
|
|
|
|
/* First check for Latin-1 characters (1:1 mapping) */
|
|
|
|
if ((keyval >= 0x0020 && keyval <= 0x007e) ||
|
|
|
|
(keyval >= 0x00a0 && keyval <= 0x00ff))
|
|
|
|
return keyval;
|
|
|
|
|
|
|
|
/* Also check for directly encoded 24-bit UCS characters:
|
|
|
|
*/
|
|
|
|
if ((keyval & 0xff000000) == 0x01000000)
|
|
|
|
return keyval & 0x00ffffff;
|
|
|
|
|
|
|
|
/* binary search in table */
|
|
|
|
while (max >= min) {
|
|
|
|
mid = (min + max) / 2;
|
|
|
|
if (clutter_keysym_to_unicode_tab[mid].keysym < keyval)
|
|
|
|
min = mid + 1;
|
|
|
|
else if (clutter_keysym_to_unicode_tab[mid].keysym > keyval)
|
|
|
|
max = mid - 1;
|
|
|
|
else {
|
|
|
|
/* found it */
|
|
|
|
return clutter_keysym_to_unicode_tab[mid].ucs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* No matching Unicode value found */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-23 05:55:42 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_get_device_id:
|
|
|
|
* @event: a clutter event
|
|
|
|
*
|
|
|
|
* Retrieves the events device id if set.
|
|
|
|
*
|
|
|
|
* Return value: A unique identifier for the device or -1 if the event has
|
|
|
|
* no specific device set.
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
clutter_event_get_device_id (ClutterEvent *event)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (-1, event != NULL);
|
|
|
|
|
|
|
|
ClutterInputDevice *device = NULL;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_NOTHING:
|
|
|
|
case CLUTTER_STAGE_STATE:
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
break;
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
device = event->button.device;
|
|
|
|
break;
|
|
|
|
case CLUTTER_MOTION:
|
|
|
|
device = event->motion.device;
|
|
|
|
break;
|
|
|
|
case CLUTTER_SCROLL:
|
|
|
|
device = event->scroll.device;
|
|
|
|
break;
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device)
|
|
|
|
return device->id;
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
GType
|
|
|
|
clutter_event_get_type (void)
|
|
|
|
{
|
|
|
|
static GType our_type = 0;
|
|
|
|
|
|
|
|
if (!our_type)
|
2007-12-24 09:52:41 -05:00
|
|
|
our_type = g_boxed_type_register_static (I_("ClutterEvent"),
|
2007-03-22 14:21:59 -04:00
|
|
|
(GBoxedCopyFunc) clutter_event_copy,
|
|
|
|
(GBoxedFreeFunc) clutter_event_free);
|
|
|
|
return our_type;
|
|
|
|
}
|
|
|
|
|
2006-06-22 09:44:47 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_new:
|
|
|
|
* @type: The type of event.
|
|
|
|
*
|
|
|
|
* Creates a new #ClutterEvent of the specified type.
|
|
|
|
*
|
2006-06-22 09:50:39 -04:00
|
|
|
* Return value: A newly allocated #ClutterEvent.
|
2006-06-22 09:44:47 -04: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 09:38:31 -04:00
|
|
|
ClutterEvent *
|
|
|
|
clutter_event_new (ClutterEventType type)
|
|
|
|
{
|
|
|
|
ClutterEvent *new_event;
|
|
|
|
|
2007-08-23 08:47:25 -04:00
|
|
|
new_event = g_slice_new0 (ClutterEvent);
|
2007-03-22 14:21:59 -04:00
|
|
|
new_event->type = new_event->any.type = type;
|
|
|
|
|
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 09:38:31 -04:00
|
|
|
return new_event;
|
|
|
|
}
|
|
|
|
|
2006-06-22 09:44:47 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_copy:
|
|
|
|
* @event: A #ClutterEvent.
|
|
|
|
*
|
|
|
|
* Copies @event.
|
|
|
|
*
|
|
|
|
* Return value: A newly allocated #ClutterEvent
|
|
|
|
*/
|
2006-06-05 Emmanuele Bassi <ebassi@openedhand.com>
* clutter-color.h:
* clutter-color.c: Reimplement ClutterColor as a boxed type;
add convenience API for color handling, like: add, subtract,
shade, HSL color-space conversion, packing and unpacking.
* clutter-private.h: Update ClutterMainContext, and export the
main context pointer here.
* clutter-rectangle.h:
* clutter-rectangle.c: Update the color-related code; make
clutter_rectangle_new() and empty constructor and provide
clutter_rectangle_new_with_color(); provide color setter
and getter API.
* clutter-label.h:
* clutter-label.c: Rename the "font" property to "font-name";
update the color-related code to the new ClutterColor object;
rename clutter_label_new() to clutter_label_new_with_text(),
and add setters and getters for the properties.
* clutter-marshal.list: Add VOID:OBJECT and VOID:BOXED marshallers
generators.
* clutter-stage.h:
* clutter-stage.c: Rework the API: provide a default constructor
for a singleton object, named clutter_stage_get_default(), which
supercedes the clutter_stage() function in clutter-main; provide
new events: button-press-event, button-release-event,
key-press-event and key-release-event; update the color-related
code;
(clutter_stage_snapshot): Allow negative width and height when
taking a snapshot (meaning: use full width/height).
(clutter_stage_get_element_at_pos): Rename clutter_stage_pick().
* clutter-element.c (clutter_element_paint): Clean up the
stage and color related code.
* clutter-event.h:
* clutter-event.c: Add generic ClutterAnyEvent type; add
clutter_event_new(), clutter_event_copy() and clutter_event_free();
make ClutterEvent a boxed type.
* clutter-main.h:
* clutter-main.c: Remove clutter_stage(); add clutter_main_quit(),
for cleanly quitting from clutter_main(); add multiple mainloops
support; allocate the ClutterCntx instead of adding it to the
stack; re-work the ClutterEvent dispatching.
* clutter-group.c (clutter_group_add), (clutter_group_remove): Keep
a reference on the element when added to a ClutterGroup.
* examples/rects.py
* examples/test.c:
* examples/test-text.c:
* examples/video-cube.c:
* examples/super-oh.c:
* examples/test-video.c: Update.
2006-06-05 09:38:31 -04:00
|
|
|
ClutterEvent *
|
|
|
|
clutter_event_copy (ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterEvent *new_event;
|
|
|
|
|
|
|
|
g_return_val_if_fail (event != NULL, NULL);
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
new_event = clutter_event_new (CLUTTER_NOTHING);
|
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 09:38:31 -04:00
|
|
|
*new_event = *event;
|
|
|
|
|
2008-01-19 05:30:29 -05:00
|
|
|
/* deep copies or references must be added here */
|
|
|
|
switch (new_event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
if (new_event->crossing.related)
|
|
|
|
g_object_ref (new_event->crossing.related);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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 09:38:31 -04:00
|
|
|
return new_event;
|
|
|
|
}
|
|
|
|
|
2006-06-22 09:44:47 -04: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 09:38:31 -04:00
|
|
|
void
|
|
|
|
clutter_event_free (ClutterEvent *event)
|
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
if (G_LIKELY (event))
|
|
|
|
{
|
2007-12-18 08:03:45 -05:00
|
|
|
if ((event->type == CLUTTER_LEAVE || event->type == CLUTTER_ENTER) &&
|
|
|
|
event->crossing.related)
|
2008-01-19 05:30:29 -05:00
|
|
|
g_object_unref (event->crossing.related);
|
|
|
|
|
2007-08-23 08:47:25 -04:00
|
|
|
g_slice_free (ClutterEvent, event);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_event_get:
|
|
|
|
*
|
2007-07-25 18:09:53 -04:00
|
|
|
* Pops an event off the event queue. Applications should not need to call
|
|
|
|
* this.
|
2007-03-22 14:21:59 -04:00
|
|
|
*
|
2007-07-25 18:09:53 -04:00
|
|
|
* Return value: A #ClutterEvent or NULL if queue empty
|
2007-03-22 14:21:59 -04:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
|
|
|
*/
|
2007-08-21 11:48:13 -04:00
|
|
|
ClutterEvent *
|
2007-03-22 14:21:59 -04:00
|
|
|
clutter_event_get (void)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context = clutter_context_get_default ();
|
2007-08-21 11:48:13 -04:00
|
|
|
|
|
|
|
if (!context->events_queue)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (g_queue_is_empty (context->events_queue))
|
|
|
|
return NULL;
|
|
|
|
|
2007-08-23 08:47:25 -04: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 09:38:31 -04:00
|
|
|
}
|
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_peek:
|
|
|
|
*
|
2007-07-25 18:09:53 -04:00
|
|
|
* Returns a pointer to the first event from the event queue but
|
|
|
|
* does not remove it.
|
2007-03-22 14:21:59 -04:00
|
|
|
*
|
2007-07-25 18:09:53 -04:00
|
|
|
* Return value: A #ClutterEvent or NULL if queue empty.
|
2007-03-22 14:21:59 -04: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 09:38:31 -04:00
|
|
|
{
|
2007-03-22 14:21:59 -04:00
|
|
|
ClutterMainContext *context = clutter_context_get_default ();
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2007-08-23 08:47:25 -04:00
|
|
|
g_return_val_if_fail (context != NULL, NULL);
|
|
|
|
|
|
|
|
if (context->events_queue == NULL)
|
2007-08-21 11:48:13 -04:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (g_queue_is_empty (context->events_queue))
|
2007-05-09 19:31:08 -04:00
|
|
|
return NULL;
|
|
|
|
|
2007-08-23 08:47:25 -04:00
|
|
|
return g_queue_peek_tail (context->events_queue);
|
2007-03-22 14:21:59 -04: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 09:38:31 -04:00
|
|
|
|
2007-03-22 14:21:59 -04:00
|
|
|
/**
|
|
|
|
* clutter_event_put:
|
|
|
|
* @event: a #ClutterEvent
|
|
|
|
*
|
2007-11-20 12:03:53 -05: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 it's
|
|
|
|
* 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 14:21:59 -04:00
|
|
|
*
|
2007-10-15 12:50:59 -04:00
|
|
|
* Since: 0.6
|
2007-03-22 14:21:59 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_event_put (ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterMainContext *context = clutter_context_get_default ();
|
2007-10-15 12:50:59 -04:00
|
|
|
ClutterEvent *event_copy;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-08-23 08:47:25 -04:00
|
|
|
/* FIXME: check queue is valid */
|
|
|
|
g_return_if_fail (context != NULL);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-10-15 12:50:59 -04:00
|
|
|
event_copy = clutter_event_copy (event);
|
|
|
|
event_copy->any.flags |= CLUTTER_EVENT_FLAG_SYNTHETIC;
|
|
|
|
|
|
|
|
g_queue_push_head (context->events_queue, event_copy);
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|
2007-07-25 18:09:53 -04: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 14:21:59 -04:00
|
|
|
gboolean
|
2007-05-09 19:31:08 -04:00
|
|
|
clutter_events_pending (void)
|
2007-03-22 14:21:59 -04:00
|
|
|
{
|
2007-05-09 19:31:08 -04:00
|
|
|
ClutterMainContext *context = clutter_context_get_default ();
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-05-09 19:31:08 -04:00
|
|
|
g_return_val_if_fail (context != NULL, FALSE);
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-05-09 19:31:08 -04:00
|
|
|
if (!context->events_queue)
|
|
|
|
return FALSE;
|
2007-03-22 14:21:59 -04:00
|
|
|
|
2007-08-23 08:47:25 -04:00
|
|
|
return g_queue_is_empty (context->events_queue) == FALSE;
|
2007-03-22 14:21:59 -04:00
|
|
|
}
|
|
|
|
|