2008-11-07 14:32:28 -05:00
|
|
|
#include <gmodule.h>
|
2007-05-09 19:31:08 -04:00
|
|
|
#include <clutter/clutter.h>
|
2008-06-10 06:57:50 -04:00
|
|
|
#include <string.h>
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2007-11-19 11:30:56 -05:00
|
|
|
gboolean IsFullScreen = FALSE, IsMotion = TRUE;
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2009-10-26 07:42:16 -04:00
|
|
|
static const gchar *
|
|
|
|
get_event_type_name (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_BUTTON_PRESS:
|
|
|
|
return "BUTTON PRESS";
|
|
|
|
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
|
|
|
return "BUTTON_RELEASE";
|
|
|
|
|
|
|
|
case CLUTTER_KEY_PRESS:
|
|
|
|
return "KEY PRESS";
|
|
|
|
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
|
|
|
return "KEY RELEASE";
|
|
|
|
|
|
|
|
case CLUTTER_ENTER:
|
|
|
|
return "ENTER";
|
|
|
|
|
|
|
|
case CLUTTER_LEAVE:
|
|
|
|
return "LEAVE";
|
|
|
|
|
2009-11-24 11:31:14 -05:00
|
|
|
case CLUTTER_MOTION:
|
|
|
|
return "MOTION";
|
|
|
|
|
|
|
|
case CLUTTER_DELETE:
|
|
|
|
return "DELETE";
|
|
|
|
|
2012-09-12 08:22:30 -04:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
|
|
|
return "TOUCH BEGIN";
|
|
|
|
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
|
|
|
return "TOUCH UPDATE";
|
|
|
|
|
|
|
|
case CLUTTER_TOUCH_END:
|
|
|
|
return "TOUCH END";
|
|
|
|
|
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
return "TOUCH CANCEL";
|
|
|
|
|
2009-10-26 07:42:16 -04:00
|
|
|
default:
|
|
|
|
return "EVENT";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-20 12:03:12 -05:00
|
|
|
static gchar *
|
|
|
|
get_event_state_string (const ClutterEvent *event)
|
|
|
|
{
|
|
|
|
gchar *mods[18];
|
|
|
|
int i = 0;
|
|
|
|
ClutterModifierType state = clutter_event_get_state (event);
|
|
|
|
|
|
|
|
if (state & CLUTTER_SHIFT_MASK)
|
|
|
|
mods[i++] = "shift";
|
|
|
|
if (state & CLUTTER_LOCK_MASK)
|
|
|
|
mods[i++] = "lock";
|
|
|
|
if (state & CLUTTER_CONTROL_MASK)
|
|
|
|
mods[i++] = "ctrl";
|
|
|
|
if (state & CLUTTER_MOD1_MASK)
|
|
|
|
mods[i++] = "mod1";
|
|
|
|
if (state & CLUTTER_MOD2_MASK)
|
|
|
|
mods[i++] = "mod2";
|
|
|
|
if (state & CLUTTER_MOD3_MASK)
|
|
|
|
mods[i++] = "mod3";
|
|
|
|
if (state & CLUTTER_MOD4_MASK)
|
|
|
|
mods[i++] = "mod4";
|
|
|
|
if (state & CLUTTER_MOD5_MASK)
|
|
|
|
mods[i++] = "mod5";
|
|
|
|
if (state & CLUTTER_BUTTON1_MASK)
|
|
|
|
mods[i++] = "btn1";
|
|
|
|
if (state & CLUTTER_BUTTON2_MASK)
|
|
|
|
mods[i++] = "btn2";
|
|
|
|
if (state & CLUTTER_BUTTON3_MASK)
|
|
|
|
mods[i++] = "btn3";
|
|
|
|
if (state & CLUTTER_BUTTON4_MASK)
|
|
|
|
mods[i++] = "btn4";
|
|
|
|
if (state & CLUTTER_BUTTON5_MASK)
|
|
|
|
mods[i++] = "btn5";
|
|
|
|
if (state & CLUTTER_SUPER_MASK)
|
|
|
|
mods[i++] = "super";
|
|
|
|
if (state & CLUTTER_HYPER_MASK)
|
|
|
|
mods[i++] = "hyper";
|
|
|
|
if (state & CLUTTER_META_MASK)
|
|
|
|
mods[i++] = "meta";
|
|
|
|
if (state & CLUTTER_RELEASE_MASK)
|
|
|
|
mods[i++] = "release";
|
|
|
|
|
|
|
|
if (i == 0)
|
|
|
|
mods[i++] = "-";
|
|
|
|
|
|
|
|
mods[i] = NULL;
|
|
|
|
return g_strjoinv (",", mods);
|
|
|
|
}
|
|
|
|
|
2007-08-24 11:12:52 -04:00
|
|
|
static void
|
|
|
|
stage_state_cb (ClutterStage *stage,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gchar *detail = (gchar*)data;
|
|
|
|
|
|
|
|
printf("[stage signal] %s\n", detail);
|
|
|
|
}
|
|
|
|
|
2007-10-02 10:03:36 -04:00
|
|
|
static gboolean
|
2011-11-09 08:41:15 -05:00
|
|
|
blue_button_cb (ClutterActor *actor,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
2007-08-24 11:12:52 -04:00
|
|
|
{
|
|
|
|
ClutterActor *stage;
|
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
stage = clutter_actor_get_stage (actor);
|
2007-08-24 11:12:52 -04:00
|
|
|
|
|
|
|
if (IsFullScreen)
|
2009-06-09 09:05:03 -04:00
|
|
|
IsFullScreen = FALSE;
|
2007-08-24 11:12:52 -04:00
|
|
|
else
|
2009-06-09 09:05:03 -04:00
|
|
|
IsFullScreen = TRUE;
|
|
|
|
|
|
|
|
clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), IsFullScreen);
|
2007-10-02 10:03:36 -04:00
|
|
|
|
2008-05-14 12:47:38 -04:00
|
|
|
g_print ("*** Fullscreen %s ***\n",
|
|
|
|
IsFullScreen ? "enabled" : "disabled");
|
|
|
|
|
2007-10-02 10:03:36 -04:00
|
|
|
return FALSE;
|
2007-08-24 11:12:52 -04:00
|
|
|
}
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2007-10-03 05:28:16 -04:00
|
|
|
static gboolean
|
2011-06-20 06:41:28 -04:00
|
|
|
red_button_cb (ClutterActor *actor,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
2007-10-03 05:28:16 -04:00
|
|
|
{
|
2011-06-20 06:41:28 -04:00
|
|
|
ClutterActor *stage;
|
2007-10-03 05:28:16 -04:00
|
|
|
|
|
|
|
if (IsMotion)
|
|
|
|
IsMotion = FALSE;
|
|
|
|
else
|
|
|
|
IsMotion = TRUE;
|
|
|
|
|
2011-06-20 06:41:28 -04:00
|
|
|
stage = clutter_actor_get_stage (actor);
|
|
|
|
clutter_stage_set_motion_events_enabled (CLUTTER_STAGE (stage),
|
|
|
|
IsMotion);
|
2007-10-10 09:04:34 -04:00
|
|
|
|
2008-05-14 12:47:38 -04:00
|
|
|
g_print ("*** Per actor motion events %s ***\n",
|
|
|
|
IsMotion ? "enabled" : "disabled");
|
|
|
|
|
2007-10-10 09:04:34 -04:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2008-05-14 12:47:38 -04:00
|
|
|
capture_cb (ClutterActor *actor,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
2007-10-10 09:04:34 -04:00
|
|
|
{
|
2009-10-26 07:42:16 -04:00
|
|
|
g_print ("* captured event '%s' for type '%s' *\n",
|
|
|
|
get_event_type_name (event),
|
2008-05-14 12:47:38 -04:00
|
|
|
G_OBJECT_TYPE_NAME (actor));
|
2007-10-10 09:04:34 -04:00
|
|
|
|
|
|
|
return FALSE;
|
2007-10-03 05:28:16 -04:00
|
|
|
}
|
|
|
|
|
2007-10-02 10:03:36 -04:00
|
|
|
static void
|
2011-11-09 08:41:15 -05:00
|
|
|
key_focus_in_cb (ClutterActor *actor,
|
|
|
|
gpointer data)
|
2007-08-13 16:48:01 -04:00
|
|
|
{
|
2011-11-09 08:41:15 -05:00
|
|
|
ClutterActor *focus_box = CLUTTER_ACTOR (data);
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
if (CLUTTER_IS_STAGE (actor))
|
2008-05-14 12:47:38 -04:00
|
|
|
clutter_actor_hide (focus_box);
|
2007-08-13 16:48:01 -04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
clutter_actor_set_position (focus_box,
|
|
|
|
clutter_actor_get_x (actor) - 5,
|
|
|
|
clutter_actor_get_y (actor) - 5);
|
|
|
|
|
|
|
|
clutter_actor_set_size (focus_box,
|
|
|
|
clutter_actor_get_width (actor) + 10,
|
|
|
|
clutter_actor_get_height (actor) + 10);
|
2007-10-02 10:03:36 -04:00
|
|
|
clutter_actor_show (focus_box);
|
2007-08-13 16:48:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
static void
|
|
|
|
fill_keybuf (char *keybuf, ClutterKeyEvent *event)
|
|
|
|
{
|
|
|
|
char utf8[6];
|
|
|
|
int len;
|
|
|
|
|
|
|
|
/* printable character, if any (ß, ∑) */
|
|
|
|
len = g_unichar_to_utf8 (event->unicode_value, utf8);
|
|
|
|
utf8[len] = '\0';
|
2009-11-24 11:31:14 -05:00
|
|
|
sprintf (keybuf, "'%s' ", utf8);
|
2008-06-10 06:57:50 -04:00
|
|
|
|
|
|
|
/* key combination (<Mod1>s, <Shift><Mod1>S, <Ctrl><Mod1>Delete) */
|
2009-11-24 11:31:14 -05:00
|
|
|
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->keyval), utf8);
|
2008-06-10 06:57:50 -04:00
|
|
|
utf8[len] = '\0';
|
|
|
|
|
|
|
|
if (event->modifier_state & CLUTTER_SHIFT_MASK)
|
|
|
|
strcat (keybuf, "<Shift>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_LOCK_MASK)
|
|
|
|
strcat (keybuf, "<Lock>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_CONTROL_MASK)
|
|
|
|
strcat (keybuf, "<Control>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_MOD1_MASK)
|
|
|
|
strcat (keybuf, "<Mod1>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_MOD2_MASK)
|
|
|
|
strcat (keybuf, "<Mod2>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_MOD3_MASK)
|
|
|
|
strcat (keybuf, "<Mod3>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_MOD4_MASK)
|
|
|
|
strcat (keybuf, "<Mod4>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
if (event->modifier_state & CLUTTER_MOD5_MASK)
|
|
|
|
strcat (keybuf, "<Mod5>");
|
2009-11-24 11:31:14 -05:00
|
|
|
|
2008-06-10 06:57:50 -04:00
|
|
|
strcat (keybuf, utf8);
|
|
|
|
}
|
|
|
|
|
2007-10-02 10:03:36 -04:00
|
|
|
static gboolean
|
2009-11-24 11:31:14 -05:00
|
|
|
input_cb (ClutterActor *actor,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
2007-05-09 19:31:08 -04:00
|
|
|
{
|
2011-11-09 08:41:15 -05:00
|
|
|
ClutterActor *stage = clutter_actor_get_stage (actor);
|
2009-11-24 11:31:14 -05:00
|
|
|
ClutterActor *source_actor = clutter_event_get_source (event);
|
2012-09-21 08:44:07 -04:00
|
|
|
ClutterPoint position;
|
2012-11-20 12:03:12 -05:00
|
|
|
gchar *state;
|
2009-11-24 11:31:14 -05:00
|
|
|
gchar keybuf[128];
|
2012-09-21 08:44:07 -04:00
|
|
|
gint device_id;
|
|
|
|
gint source_device_id = 0;
|
|
|
|
|
|
|
|
device_id = clutter_event_get_device_id (event);
|
|
|
|
if (clutter_event_get_source_device (event) != NULL)
|
|
|
|
source_device_id = clutter_input_device_get_device_id (clutter_event_get_source_device (event));
|
2007-06-18 05:15:00 -04:00
|
|
|
|
2012-11-20 12:03:12 -05:00
|
|
|
state = get_event_state_string (event);
|
|
|
|
|
2007-05-09 19:31:08 -04:00
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case CLUTTER_KEY_PRESS:
|
2008-06-10 06:57:50 -04:00
|
|
|
fill_keybuf (keybuf, &event->key);
|
2009-11-24 11:31:14 -05:00
|
|
|
printf ("[%s] KEY PRESS %s",
|
|
|
|
clutter_actor_get_name (source_actor),
|
|
|
|
keybuf);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_KEY_RELEASE:
|
2008-06-10 06:57:50 -04:00
|
|
|
fill_keybuf (keybuf, &event->key);
|
2009-11-24 11:31:14 -05:00
|
|
|
printf ("[%s] KEY RELEASE %s",
|
|
|
|
clutter_actor_get_name (source_actor),
|
|
|
|
keybuf);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_MOTION:
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_position (event, &position);
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] MOTION (coords:%.02f,%.02f device:%d/%d state:%s)",
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_actor_get_name (source_actor), position.x, position.y,
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
2007-10-03 05:28:16 -04:00
|
|
|
case CLUTTER_ENTER:
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] ENTER (from:%s device:%d/%d state:%s)",
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_get_name (source_actor),
|
2009-12-07 18:02:48 -05:00
|
|
|
clutter_event_get_related (event) != NULL
|
|
|
|
? clutter_actor_get_name (clutter_event_get_related (event))
|
2012-09-21 08:44:07 -04:00
|
|
|
: "<out of stage>",
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
2007-10-03 05:28:16 -04:00
|
|
|
case CLUTTER_LEAVE:
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] LEAVE (to:%s device:%d/%d state:%s)",
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_get_name (source_actor),
|
2009-12-07 18:02:48 -05:00
|
|
|
clutter_event_get_related (event) != NULL
|
|
|
|
? clutter_actor_get_name (clutter_event_get_related (event))
|
2012-09-21 08:44:07 -04:00
|
|
|
: "<out of stage>",
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
2007-10-03 05:28:16 -04:00
|
|
|
case CLUTTER_BUTTON_PRESS:
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_position (event, &position);
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] BUTTON PRESS (button:%i, click count:%i coords:%.02f,%.02f device:%d/%d, state:%s)",
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_actor_get_name (source_actor),
|
2009-12-07 18:02:48 -05:00
|
|
|
clutter_event_get_button (event),
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_click_count (event),
|
|
|
|
position.x, position.y,
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_BUTTON_RELEASE:
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_position (event, &position);
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] BUTTON RELEASE (button:%i, click count:%i coords:%.02f,%.02f device:%d/%d state:%s)",
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_actor_get_name (source_actor),
|
2009-12-07 18:02:48 -05:00
|
|
|
clutter_event_get_button (event),
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_click_count (event),
|
|
|
|
position.x, position.y,
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2007-11-20 12:14:05 -05:00
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
if (source_actor == stage)
|
|
|
|
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL);
|
2009-11-24 11:31:14 -05:00
|
|
|
else if (source_actor == actor &&
|
2011-11-09 08:41:15 -05:00
|
|
|
clutter_actor_get_parent (actor) == stage)
|
|
|
|
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor);
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
2012-09-12 08:22:30 -04:00
|
|
|
case CLUTTER_TOUCH_BEGIN:
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_position (event, &position);
|
2012-11-20 12:15:29 -05:00
|
|
|
g_print ("[%s] TOUCH BEGIN (seq:%p coords:%.02f,%.02f device:%d/%d state:%s)",
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_actor_get_name (source_actor),
|
2012-11-20 12:15:29 -05:00
|
|
|
clutter_event_get_event_sequence (event),
|
2012-09-21 08:44:07 -04:00
|
|
|
position.x, position.y,
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2012-09-12 08:22:30 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_TOUCH_UPDATE:
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_position (event, &position);
|
2012-11-20 12:15:29 -05:00
|
|
|
g_print ("[%s] TOUCH UPDATE (seq:%p coords:%.02f,%.02f device:%d/%d state:%s)",
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_actor_get_name (source_actor),
|
2012-11-20 12:15:29 -05:00
|
|
|
clutter_event_get_event_sequence (event),
|
2012-09-21 08:44:07 -04:00
|
|
|
position.x, position.y,
|
2012-11-20 12:03:12 -05:00
|
|
|
device_id, source_device_id, state);
|
2012-09-12 08:22:30 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_TOUCH_END:
|
2012-09-21 08:44:07 -04:00
|
|
|
clutter_event_get_position (event, &position);
|
2012-11-20 12:15:29 -05:00
|
|
|
g_print ("[%s] TOUCH END (seq:%p coords:%.02f,%.02f device:%d/%d state:%s)",
|
2012-11-20 12:03:12 -05:00
|
|
|
clutter_actor_get_name (source_actor),
|
2012-11-20 12:15:29 -05:00
|
|
|
clutter_event_get_event_sequence (event),
|
2012-11-20 12:03:12 -05:00
|
|
|
position.x, position.y,
|
|
|
|
device_id, source_device_id, state);
|
2012-09-12 08:22:30 -04:00
|
|
|
break;
|
2012-11-20 12:15:56 -05:00
|
|
|
case CLUTTER_TOUCH_CANCEL:
|
|
|
|
clutter_event_get_position (event, &position);
|
|
|
|
g_print ("[%s] TOUCH CANCEL (seq:%p coords:%.02f,%.02f device:%d/%d state:%s)",
|
|
|
|
clutter_actor_get_name (source_actor),
|
|
|
|
clutter_event_get_event_sequence (event),
|
|
|
|
position.x, position.y,
|
|
|
|
device_id, source_device_id, state);
|
|
|
|
break;
|
2007-05-09 19:31:08 -04:00
|
|
|
case CLUTTER_SCROLL:
|
2012-09-12 08:45:05 -04:00
|
|
|
{
|
2012-09-12 14:08:16 -04:00
|
|
|
ClutterScrollDirection dir = clutter_event_get_scroll_direction (event);
|
2012-09-12 08:45:05 -04:00
|
|
|
|
|
|
|
if (dir == CLUTTER_SCROLL_SMOOTH)
|
|
|
|
{
|
|
|
|
gdouble dx, dy;
|
2012-09-12 14:08:16 -04:00
|
|
|
clutter_event_get_scroll_delta (event, &dx, &dy);
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] BUTTON SCROLL (direction:smooth %.02f,%.02f state:%s)",
|
|
|
|
clutter_actor_get_name (source_actor), dx, dy, state);
|
2012-09-12 08:45:05 -04:00
|
|
|
}
|
|
|
|
else
|
2012-11-20 12:03:12 -05:00
|
|
|
g_print ("[%s] BUTTON SCROLL (direction:%s state:%s)",
|
2012-09-12 14:08:16 -04:00
|
|
|
clutter_actor_get_name (source_actor),
|
|
|
|
dir == CLUTTER_SCROLL_UP ? "up" :
|
|
|
|
dir == CLUTTER_SCROLL_DOWN ? "down" :
|
|
|
|
dir == CLUTTER_SCROLL_LEFT ? "left" :
|
2012-11-20 12:03:12 -05:00
|
|
|
dir == CLUTTER_SCROLL_RIGHT ? "right" : "?",
|
|
|
|
state);
|
2012-09-12 08:45:05 -04:00
|
|
|
}
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_STAGE_STATE:
|
2009-11-24 11:31:14 -05:00
|
|
|
g_print ("[%s] STAGE STATE", clutter_actor_get_name (source_actor));
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_DESTROY_NOTIFY:
|
2009-11-24 11:31:14 -05:00
|
|
|
g_print ("[%s] DESTROY NOTIFY", clutter_actor_get_name (source_actor));
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_CLIENT_MESSAGE:
|
2009-11-24 11:31:14 -05:00
|
|
|
g_print ("[%s] CLIENT MESSAGE", clutter_actor_get_name (source_actor));
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
|
|
|
case CLUTTER_DELETE:
|
2009-11-24 11:31:14 -05:00
|
|
|
g_print ("[%s] DELETE", clutter_actor_get_name (source_actor));
|
2007-05-09 19:31:08 -04:00
|
|
|
break;
|
2007-07-26 07:04:04 -04:00
|
|
|
case CLUTTER_NOTHING:
|
2007-12-09 03:53:06 -05:00
|
|
|
return FALSE;
|
2007-05-09 19:31:08 -04:00
|
|
|
}
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2012-11-20 12:03:12 -05:00
|
|
|
g_free (state);
|
|
|
|
|
2009-11-24 11:31:14 -05:00
|
|
|
if (source_actor == actor)
|
2008-05-14 12:47:38 -04:00
|
|
|
g_print (" *source*");
|
2007-10-02 10:03:36 -04:00
|
|
|
|
2008-06-13 11:01:34 -04:00
|
|
|
g_print ("\n");
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2007-10-02 10:03:36 -04:00
|
|
|
return FALSE;
|
2007-05-09 19:31:08 -04:00
|
|
|
}
|
|
|
|
|
2008-11-07 14:32:28 -05:00
|
|
|
G_MODULE_EXPORT int
|
|
|
|
test_events_main (int argc, char *argv[])
|
2007-05-09 19:31:08 -04:00
|
|
|
{
|
2011-11-09 08:41:15 -05:00
|
|
|
ClutterActor *stage, *actor, *focus_box, *group;
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2011-02-21 19:19:35 -05:00
|
|
|
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
|
|
|
return 1;
|
2007-05-09 19:31:08 -04:00
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
stage = clutter_stage_new ();
|
|
|
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "Events");
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (stage, "Stage");
|
2011-11-09 08:41:15 -05:00
|
|
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
2007-08-13 16:48:01 -04:00
|
|
|
g_signal_connect (stage, "event", G_CALLBACK (input_cb), "stage");
|
2007-08-24 11:12:52 -04:00
|
|
|
g_signal_connect (stage, "fullscreen",
|
|
|
|
G_CALLBACK (stage_state_cb), "fullscreen");
|
|
|
|
g_signal_connect (stage, "unfullscreen",
|
|
|
|
G_CALLBACK (stage_state_cb), "unfullscreen");
|
|
|
|
g_signal_connect (stage, "activate",
|
|
|
|
G_CALLBACK (stage_state_cb), "activate");
|
|
|
|
g_signal_connect (stage, "deactivate",
|
|
|
|
G_CALLBACK (stage_state_cb), "deactivate");
|
2007-10-10 09:04:34 -04:00
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
focus_box = clutter_rectangle_new_with_color (CLUTTER_COLOR_Black);
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (focus_box, "Focus Box");
|
2007-08-13 16:48:01 -04:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER(stage), focus_box, NULL);
|
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Red);
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (actor, "Red Box");
|
2007-08-13 16:48:01 -04:00
|
|
|
clutter_actor_set_size (actor, 100, 100);
|
|
|
|
clutter_actor_set_position (actor, 100, 100);
|
2007-11-15 12:35:47 -05:00
|
|
|
clutter_actor_set_reactive (actor, TRUE);
|
2007-10-02 10:03:36 -04:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
|
2007-08-13 16:48:01 -04:00
|
|
|
g_signal_connect (actor, "event", G_CALLBACK (input_cb), "red box");
|
2009-06-08 05:58:20 -04:00
|
|
|
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
|
2007-08-13 16:48:01 -04:00
|
|
|
focus_box);
|
2007-10-03 05:28:16 -04:00
|
|
|
/* Toggle motion - enter/leave capture */
|
2008-05-14 12:47:38 -04:00
|
|
|
g_signal_connect (actor, "button-press-event",
|
|
|
|
G_CALLBACK (red_button_cb), NULL);
|
2007-10-03 05:28:16 -04:00
|
|
|
|
2007-09-28 07:03:21 -04:00
|
|
|
clutter_stage_set_key_focus (CLUTTER_STAGE (stage), actor);
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green);
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (actor, "Green Box");
|
2007-08-13 16:48:01 -04:00
|
|
|
clutter_actor_set_size (actor, 100, 100);
|
|
|
|
clutter_actor_set_position (actor, 250, 100);
|
2007-11-15 12:35:47 -05:00
|
|
|
clutter_actor_set_reactive (actor, TRUE);
|
2007-10-02 10:03:36 -04:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), actor, NULL);
|
2007-08-13 16:48:01 -04:00
|
|
|
g_signal_connect (actor, "event", G_CALLBACK (input_cb), "green box");
|
2009-06-08 05:58:20 -04:00
|
|
|
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
|
2007-08-13 16:48:01 -04:00
|
|
|
focus_box);
|
2007-10-10 09:04:34 -04:00
|
|
|
g_signal_connect (actor, "captured-event", G_CALLBACK (capture_cb), NULL);
|
|
|
|
|
2011-11-09 08:41:15 -05:00
|
|
|
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Blue);
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (actor, "Blue Box");
|
2007-08-13 16:48:01 -04:00
|
|
|
clutter_actor_set_size (actor, 100, 100);
|
|
|
|
clutter_actor_set_position (actor, 400, 100);
|
2007-11-15 12:35:47 -05:00
|
|
|
clutter_actor_set_reactive (actor, TRUE);
|
2007-08-13 16:48:01 -04:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL);
|
|
|
|
g_signal_connect (actor, "event", G_CALLBACK (input_cb), "blue box");
|
2009-06-08 05:58:20 -04:00
|
|
|
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
|
2007-08-13 16:48:01 -04:00
|
|
|
focus_box);
|
2007-10-03 05:28:16 -04:00
|
|
|
/* Fullscreen */
|
2008-05-14 12:47:38 -04:00
|
|
|
g_signal_connect (actor, "button-press-event",
|
|
|
|
G_CALLBACK (blue_button_cb), NULL);
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2007-11-18 18:24:55 -05:00
|
|
|
/* non reactive */
|
2011-11-09 08:41:15 -05:00
|
|
|
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Black);
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (actor, "Black Box");
|
2007-08-13 16:48:01 -04:00
|
|
|
clutter_actor_set_size (actor, 400, 50);
|
|
|
|
clutter_actor_set_position (actor, 100, 250);
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER(stage), actor, NULL);
|
|
|
|
g_signal_connect (actor, "event", G_CALLBACK (input_cb), "blue box");
|
2009-06-08 05:58:20 -04:00
|
|
|
g_signal_connect (actor, "key-focus-in", G_CALLBACK (key_focus_in_cb),
|
2007-08-13 16:48:01 -04:00
|
|
|
focus_box);
|
2009-06-08 05:58:20 -04:00
|
|
|
g_signal_connect (stage, "key-focus-in", G_CALLBACK (key_focus_in_cb),
|
2007-08-13 16:48:01 -04:00
|
|
|
focus_box);
|
|
|
|
|
2007-11-18 18:24:55 -05:00
|
|
|
/* non reactive group, with reactive child */
|
2011-11-09 08:41:15 -05:00
|
|
|
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow);
|
2009-11-24 11:31:14 -05:00
|
|
|
clutter_actor_set_name (actor, "Yellow Box");
|
2007-11-18 18:24:55 -05:00
|
|
|
clutter_actor_set_size (actor, 100, 100);
|
|
|
|
clutter_actor_set_reactive (actor, TRUE);
|
|
|
|
|
|
|
|
g_signal_connect (actor, "event", G_CALLBACK (input_cb), "yellow box");
|
|
|
|
|
|
|
|
/* note group not reactive */
|
|
|
|
group = clutter_group_new ();
|
2008-05-14 12:47:38 -04:00
|
|
|
clutter_container_add (CLUTTER_CONTAINER (group), actor, NULL);
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), group, NULL);
|
2007-11-18 18:24:55 -05:00
|
|
|
clutter_actor_set_position (group, 100, 350);
|
|
|
|
clutter_actor_show_all (group);
|
2007-08-13 16:48:01 -04:00
|
|
|
|
2010-02-17 05:46:16 -05:00
|
|
|
/* border actor */
|
2011-11-09 08:41:15 -05:00
|
|
|
actor = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta);
|
2010-02-17 05:46:16 -05:00
|
|
|
clutter_actor_set_name (actor, "Border Box");
|
|
|
|
clutter_actor_set_size (actor, 100, 100);
|
|
|
|
clutter_actor_set_position (actor,
|
|
|
|
(clutter_actor_get_width (stage) - 100) / 2,
|
|
|
|
clutter_actor_get_height (stage) - 100);
|
|
|
|
clutter_actor_set_reactive (actor, TRUE);
|
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
|
|
|
g_signal_connect (actor, "event", G_CALLBACK (input_cb), NULL);
|
|
|
|
|
2007-05-09 19:31:08 -04:00
|
|
|
clutter_actor_show_all (CLUTTER_ACTOR (stage));
|
|
|
|
|
|
|
|
clutter_main();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-09 08:41:15 -05:00
|
|
|
|
|
|
|
G_MODULE_EXPORT const char *
|
|
|
|
test_events_describe (void)
|
|
|
|
{
|
|
|
|
return "Event handling and propagation.";
|
|
|
|
}
|