tests: Use ClutterEvent getter methods
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
parent
60aa098e94
commit
ba4795a5f9
10 changed files with 59 additions and 39 deletions
|
@ -120,8 +120,8 @@ key_group_key_press (ClutterActor *actor,
|
|||
g_assert (pool != NULL);
|
||||
|
||||
res = clutter_binding_pool_activate (pool,
|
||||
event->keyval,
|
||||
event->modifier_state,
|
||||
clutter_event_get_key_symbol ((ClutterEvent *) event),
|
||||
clutter_event_get_state ((ClutterEvent *) event),
|
||||
G_OBJECT (actor));
|
||||
|
||||
/* if we activate a key binding, redraw the actor */
|
||||
|
|
|
@ -53,13 +53,16 @@ event_cb (ClutterActor *actor,
|
|||
GArray *events = user_data;
|
||||
EventLog entry;
|
||||
|
||||
switch (event->type)
|
||||
switch (clutter_event_type (event))
|
||||
{
|
||||
case CLUTTER_ENTER:
|
||||
case CLUTTER_LEAVE:
|
||||
if ((event->any.flags & CLUTTER_EVENT_FLAG_GRAB_NOTIFY) != 0)
|
||||
if ((clutter_event_get_flags (event) & CLUTTER_EVENT_FLAG_GRAB_NOTIFY) != 0)
|
||||
{
|
||||
entry = (EventLog) { clutter_actor_get_name (actor), event->type };
|
||||
entry = (EventLog) {
|
||||
clutter_actor_get_name (actor),
|
||||
clutter_event_type (event)
|
||||
};
|
||||
|
||||
g_debug ("Event '%s' on actor '%s'",
|
||||
clutter_event_get_name (event),
|
||||
|
@ -69,7 +72,10 @@ event_cb (ClutterActor *actor,
|
|||
break;
|
||||
|
||||
default:
|
||||
entry = (EventLog) { clutter_actor_get_name (actor), event->type };
|
||||
entry = (EventLog) {
|
||||
clutter_actor_get_name (actor),
|
||||
clutter_event_type (event)
|
||||
};
|
||||
g_debug ("Event '%s' on actor '%s'",
|
||||
clutter_event_get_name (event),
|
||||
entry.name);
|
||||
|
@ -560,7 +566,7 @@ handle_input_only_event (const ClutterEvent *event,
|
|||
gpointer user_data)
|
||||
{
|
||||
GArray *events = user_data;
|
||||
EventLog entry = { "input-only grab", event->type };
|
||||
EventLog entry = { "input-only grab", clutter_event_type (event) };
|
||||
|
||||
g_debug ("Input only grab event '%s'", clutter_event_get_name (event));
|
||||
g_array_append_val (events, entry);
|
||||
|
|
|
@ -75,7 +75,7 @@ input_cb (ClutterActor *stage,
|
|||
{
|
||||
SuperOH *oh = data;
|
||||
|
||||
if (event->type == CLUTTER_KEY_RELEASE)
|
||||
if (clutter_event_type (event) == CLUTTER_KEY_RELEASE)
|
||||
{
|
||||
g_print ("*** key press event (key:%c) ***\n",
|
||||
clutter_event_get_key_symbol (event));
|
||||
|
|
|
@ -140,8 +140,8 @@ key_group_key_press (ClutterActor *actor,
|
|||
g_assert (pool != NULL);
|
||||
|
||||
res = clutter_binding_pool_activate (pool,
|
||||
event->keyval,
|
||||
event->modifier_state,
|
||||
clutter_event_get_key_symbol ((ClutterEvent *) event),
|
||||
clutter_event_get_state ((ClutterEvent *) event),
|
||||
G_OBJECT (actor));
|
||||
|
||||
/* if we activate a key binding, redraw the actor */
|
||||
|
|
|
@ -240,7 +240,7 @@ button_release_cb (ClutterActor *actor,
|
|||
* which shader to display */
|
||||
g_clear_handle_id (&timeout_id, g_source_remove);
|
||||
|
||||
if (event->button.button == 1)
|
||||
if (clutter_event_get_button (event) == 1)
|
||||
{
|
||||
new_no = shader_no - 1;
|
||||
if (new_no < 0)
|
||||
|
|
|
@ -89,7 +89,7 @@ on_button_press (ClutterActor *actor,
|
|||
ClutterButtonEvent *event,
|
||||
ClutterActor *rectangle)
|
||||
{
|
||||
if (event->button == CLUTTER_BUTTON_SECONDARY)
|
||||
if (clutter_event_get_button ((ClutterEvent *) event) == CLUTTER_BUTTON_SECONDARY)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
|
@ -107,16 +107,18 @@ on_button_press (ClutterActor *actor,
|
|||
clutter_text_set_text (CLUTTER_TEXT (easing_mode_label), text);
|
||||
g_free (text);
|
||||
}
|
||||
else if (event->button == CLUTTER_BUTTON_PRIMARY)
|
||||
else if (clutter_event_get_button ((ClutterEvent *) event) == CLUTTER_BUTTON_PRIMARY)
|
||||
{
|
||||
ClutterAnimationMode cur_mode;
|
||||
float x, y;
|
||||
|
||||
cur_mode = easing_modes[current_mode].mode;
|
||||
|
||||
clutter_actor_save_easing_state (rectangle);
|
||||
clutter_actor_set_easing_duration (rectangle, DURATION * 1000);
|
||||
clutter_actor_set_easing_mode (rectangle, cur_mode);
|
||||
clutter_actor_set_position (rectangle, event->x, event->y);
|
||||
clutter_event_get_coords ((ClutterEvent *) event, &x, &y);
|
||||
clutter_actor_set_position (rectangle, x, y);
|
||||
|
||||
/* if we were asked to, recenter the bouncer at the end of the
|
||||
* animation. we keep track of the animation to avoid connecting
|
||||
|
|
|
@ -15,7 +15,7 @@ test_events_describe (void);
|
|||
static const gchar *
|
||||
get_event_type_name (const ClutterEvent *event)
|
||||
{
|
||||
switch (event->type)
|
||||
switch (clutter_event_type (event))
|
||||
{
|
||||
case CLUTTER_BUTTON_PRESS:
|
||||
return "BUTTON PRESS";
|
||||
|
@ -140,40 +140,45 @@ key_focus_in_cb (ClutterActor *actor,
|
|||
static void
|
||||
fill_keybuf (char *keybuf, ClutterKeyEvent *event)
|
||||
{
|
||||
ClutterModifierType state;
|
||||
char utf8[6];
|
||||
uint32_t keyval;
|
||||
int len;
|
||||
|
||||
/* printable character, if any (ß, ∑) */
|
||||
len = g_unichar_to_utf8 (event->unicode_value, utf8);
|
||||
len = g_unichar_to_utf8 (clutter_event_get_key_unicode ((ClutterEvent *) event), utf8);
|
||||
utf8[len] = '\0';
|
||||
sprintf (keybuf, "'%s' ", utf8);
|
||||
|
||||
/* key combination (<Mod1>s, <Shift><Mod1>S, <Ctrl><Mod1>Delete) */
|
||||
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->keyval), utf8);
|
||||
keyval = clutter_event_get_key_symbol ((ClutterEvent *) event);
|
||||
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (keyval), utf8);
|
||||
utf8[len] = '\0';
|
||||
|
||||
if (event->modifier_state & CLUTTER_SHIFT_MASK)
|
||||
state = clutter_event_get_state ((ClutterEvent *) event);
|
||||
|
||||
if (state & CLUTTER_SHIFT_MASK)
|
||||
strcat (keybuf, "<Shift>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_LOCK_MASK)
|
||||
if (state & CLUTTER_LOCK_MASK)
|
||||
strcat (keybuf, "<Lock>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_CONTROL_MASK)
|
||||
if (state & CLUTTER_CONTROL_MASK)
|
||||
strcat (keybuf, "<Control>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_MOD1_MASK)
|
||||
if (state & CLUTTER_MOD1_MASK)
|
||||
strcat (keybuf, "<Mod1>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_MOD2_MASK)
|
||||
if (state & CLUTTER_MOD2_MASK)
|
||||
strcat (keybuf, "<Mod2>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_MOD3_MASK)
|
||||
if (state & CLUTTER_MOD3_MASK)
|
||||
strcat (keybuf, "<Mod3>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_MOD4_MASK)
|
||||
if (state & CLUTTER_MOD4_MASK)
|
||||
strcat (keybuf, "<Mod4>");
|
||||
|
||||
if (event->modifier_state & CLUTTER_MOD5_MASK)
|
||||
if (state & CLUTTER_MOD5_MASK)
|
||||
strcat (keybuf, "<Mod5>");
|
||||
|
||||
strcat (keybuf, utf8);
|
||||
|
@ -184,19 +189,21 @@ input_cb (ClutterActor *actor,
|
|||
ClutterEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
ClutterActor *stage = clutter_actor_get_stage (actor);
|
||||
ClutterActor *stage = clutter_actor_get_stage (actor);
|
||||
ClutterActor *source_actor;
|
||||
graphene_point_t position;
|
||||
gchar *state;
|
||||
gchar keybuf[128];
|
||||
ClutterInputDevice *device, *source;
|
||||
const gchar *device_name, *source_name = NULL;
|
||||
ClutterEventType event_type;
|
||||
|
||||
device = clutter_event_get_device (event);
|
||||
device_name = clutter_input_device_get_device_name (device);
|
||||
event_type = clutter_event_type (event);
|
||||
|
||||
if (event->type == CLUTTER_KEY_PRESS ||
|
||||
event->type == CLUTTER_KEY_RELEASE)
|
||||
if (event_type == CLUTTER_KEY_PRESS ||
|
||||
event_type == CLUTTER_KEY_RELEASE)
|
||||
{
|
||||
source_actor = clutter_stage_get_key_focus (CLUTTER_STAGE (stage));
|
||||
}
|
||||
|
@ -215,16 +222,16 @@ input_cb (ClutterActor *actor,
|
|||
|
||||
state = get_event_state_string (event);
|
||||
|
||||
switch (event->type)
|
||||
switch (event_type)
|
||||
{
|
||||
case CLUTTER_KEY_PRESS:
|
||||
fill_keybuf (keybuf, &event->key);
|
||||
fill_keybuf (keybuf, (ClutterKeyEvent *) event);
|
||||
printf ("[%s] KEY PRESS %s",
|
||||
clutter_actor_get_name (source_actor),
|
||||
keybuf);
|
||||
break;
|
||||
case CLUTTER_KEY_RELEASE:
|
||||
fill_keybuf (keybuf, &event->key);
|
||||
fill_keybuf (keybuf, (ClutterKeyEvent *) event);
|
||||
printf ("[%s] KEY RELEASE %s",
|
||||
clutter_actor_get_name (source_actor),
|
||||
keybuf);
|
||||
|
|
|
@ -16,18 +16,21 @@ debug_event_cb (ClutterActor *actor,
|
|||
{
|
||||
gchar keybuf[9], *source = (gchar*)data;
|
||||
ClutterActor *target;
|
||||
int len = 0;
|
||||
uint32_t keyval;
|
||||
int len = 0;
|
||||
|
||||
switch (event->type)
|
||||
switch (clutter_event_type (event))
|
||||
{
|
||||
case CLUTTER_KEY_PRESS:
|
||||
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval),
|
||||
keyval = clutter_event_get_key_symbol (event);
|
||||
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (keyval),
|
||||
keybuf);
|
||||
keybuf[len] = '\0';
|
||||
printf ("[%s] KEY PRESS '%s'", source, keybuf);
|
||||
break;
|
||||
case CLUTTER_KEY_RELEASE:
|
||||
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (event->key.keyval),
|
||||
keyval = clutter_event_get_key_symbol (event);
|
||||
len = g_unichar_to_utf8 (clutter_keysym_to_unicode (keyval),
|
||||
keybuf);
|
||||
keybuf[len] = '\0';
|
||||
printf ("[%s] KEY RELEASE '%s'", source, keybuf);
|
||||
|
|
|
@ -35,7 +35,7 @@ on_captured_event (ClutterText *text,
|
|||
gunichar c;
|
||||
guint keyval;
|
||||
|
||||
if (event->type != CLUTTER_KEY_PRESS)
|
||||
if (clutter_event_type (event) != CLUTTER_KEY_PRESS)
|
||||
return FALSE;
|
||||
|
||||
is_unicode_mode = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (text),
|
||||
|
|
|
@ -59,6 +59,7 @@ draw_touch (ClutterEvent *event,
|
|||
{
|
||||
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
||||
const ClutterColor *color;
|
||||
float x, y;
|
||||
|
||||
color = g_hash_table_lookup (sequence_to_color, sequence);
|
||||
if (color == NULL)
|
||||
|
@ -71,7 +72,8 @@ draw_touch (ClutterEvent *event,
|
|||
color->green / 255,
|
||||
color->blue / 255,
|
||||
color->alpha / 255);
|
||||
cairo_arc (cr, event->touch.x, event->touch.y, 5, 0, 2 * G_PI);
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
cairo_arc (cr, x, y, 5, 0, 2 * G_PI);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
|
@ -94,7 +96,7 @@ event_cb (ClutterActor *actor, ClutterEvent *event, ClutterActor *canvas)
|
|||
{
|
||||
ClutterEvent *copy;
|
||||
|
||||
if (event->type != CLUTTER_TOUCH_UPDATE)
|
||||
if (clutter_event_type (event) != CLUTTER_TOUCH_UPDATE)
|
||||
return FALSE;
|
||||
|
||||
copy = clutter_event_copy (event);
|
||||
|
@ -110,7 +112,7 @@ rect_event_cb (ClutterActor *actor, ClutterEvent *event, gpointer data)
|
|||
{
|
||||
ClutterColor color;
|
||||
|
||||
if (event->type != CLUTTER_TOUCH_BEGIN)
|
||||
if (clutter_event_type (event) != CLUTTER_TOUCH_BEGIN)
|
||||
return FALSE;
|
||||
|
||||
color = static_colors[g_random_int_range (0, NUM_COLORS)];
|
||||
|
|
Loading…
Reference in a new issue