tests: Port faked events to new constructors
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
parent
a8c62251f8
commit
6fd7f95ed3
6 changed files with 64 additions and 63 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include "clutter/clutter-types.h"
|
#include "clutter/clutter-types.h"
|
||||||
#include "clutter/clutter-actor.h"
|
#include "clutter/clutter-actor.h"
|
||||||
#include "clutter/clutter-color.h"
|
#include "clutter/clutter-color.h"
|
||||||
|
#include "clutter/clutter-event-private.h"
|
||||||
#include "clutter/clutter-private.h"
|
#include "clutter/clutter-private.h"
|
||||||
#include "meta/common.h"
|
#include "meta/common.h"
|
||||||
#include "meta-test/meta-context-test.h"
|
#include "meta-test/meta-context-test.h"
|
||||||
|
|
|
@ -106,14 +106,13 @@ actor_event_hold (void)
|
||||||
const HoldTestCase *test_case = test_cases + n_test_case;
|
const HoldTestCase *test_case = test_cases + n_test_case;
|
||||||
|
|
||||||
/* Create a synthetic hold event */
|
/* Create a synthetic hold event */
|
||||||
event = clutter_event_new (CLUTTER_TOUCHPAD_HOLD);
|
event = clutter_event_touchpad_hold_new (CLUTTER_EVENT_NONE,
|
||||||
event->touchpad_hold.phase = test_case->phase;
|
EVENT_TIME,
|
||||||
event->touchpad_hold.time = EVENT_TIME;
|
device,
|
||||||
event->touchpad_hold.n_fingers = test_case->n_fingers;
|
test_case->phase,
|
||||||
event->touchpad_hold.stage = (ClutterStage *) stage;
|
test_case->n_fingers,
|
||||||
clutter_event_set_coords (event, test_case->x, test_case->y);
|
GRAPHENE_POINT_INIT (test_case->x,
|
||||||
clutter_event_set_device (event, device);
|
test_case->y));
|
||||||
|
|
||||||
clutter_event_put (event);
|
clutter_event_put (event);
|
||||||
clutter_event_free (event);
|
clutter_event_free (event);
|
||||||
|
|
||||||
|
|
|
@ -224,27 +224,23 @@ key_group_init (KeyGroup *self)
|
||||||
self->selected_index = -1;
|
self->selected_index = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
init_event (ClutterKeyEvent *event)
|
|
||||||
{
|
|
||||||
event->type = CLUTTER_KEY_PRESS;
|
|
||||||
event->time = 0; /* not needed */
|
|
||||||
event->flags = CLUTTER_EVENT_FLAG_SYNTHETIC;
|
|
||||||
event->stage = NULL; /* not needed */
|
|
||||||
event->modifier_state = 0;
|
|
||||||
event->hardware_keycode = 0; /* not needed */
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_keyval (KeyGroup *group, int keyval)
|
send_keyval (KeyGroup *group, int keyval)
|
||||||
{
|
{
|
||||||
ClutterKeyEvent event;
|
ClutterSeat *seat;
|
||||||
|
ClutterEvent *event;
|
||||||
|
|
||||||
init_event (&event);
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||||
event.keyval = keyval;
|
event = clutter_event_key_new (CLUTTER_KEY_PRESS,
|
||||||
event.unicode_value = 0; /* should be ignored for cursor keys etc. */
|
CLUTTER_EVENT_FLAG_SYNTHETIC,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
clutter_seat_get_keyboard (seat),
|
||||||
|
0,
|
||||||
|
keyval,
|
||||||
|
0, 0, 0);
|
||||||
|
|
||||||
clutter_actor_event (CLUTTER_ACTOR (group), (ClutterEvent *) &event, FALSE);
|
clutter_actor_event (CLUTTER_ACTOR (group), event, FALSE);
|
||||||
|
clutter_event_free (event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -327,25 +327,19 @@ text_password_char (void)
|
||||||
clutter_actor_destroy (CLUTTER_ACTOR (text));
|
clutter_actor_destroy (CLUTTER_ACTOR (text));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClutterEvent *
|
|
||||||
init_event (void)
|
|
||||||
{
|
|
||||||
ClutterEvent *retval = clutter_event_new (CLUTTER_KEY_PRESS);
|
|
||||||
|
|
||||||
clutter_event_set_time (retval, CLUTTER_CURRENT_TIME);
|
|
||||||
clutter_event_set_flags (retval, CLUTTER_EVENT_FLAG_SYNTHETIC);
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_keyval (ClutterText *text, int keyval)
|
send_keyval (ClutterText *text, int keyval)
|
||||||
{
|
{
|
||||||
ClutterEvent *event = init_event ();
|
ClutterEvent *event;
|
||||||
|
ClutterSeat *seat;
|
||||||
|
|
||||||
/* Unicode should be ignored for cursor keys etc. */
|
/* Unicode should be ignored for cursor keys etc. */
|
||||||
clutter_event_set_key_unicode (event, 0);
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||||
clutter_event_set_key_symbol (event, keyval);
|
event = clutter_event_key_new (CLUTTER_KEY_PRESS,
|
||||||
|
CLUTTER_EVENT_FLAG_SYNTHETIC,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
clutter_seat_get_keyboard (seat),
|
||||||
|
0, keyval, 0, 0, 0);
|
||||||
|
|
||||||
clutter_actor_event (CLUTTER_ACTOR (text), event, FALSE);
|
clutter_actor_event (CLUTTER_ACTOR (text), event, FALSE);
|
||||||
|
|
||||||
|
@ -355,11 +349,16 @@ send_keyval (ClutterText *text, int keyval)
|
||||||
static void
|
static void
|
||||||
send_unichar (ClutterText *text, gunichar unichar)
|
send_unichar (ClutterText *text, gunichar unichar)
|
||||||
{
|
{
|
||||||
ClutterEvent *event = init_event ();
|
ClutterEvent *event;
|
||||||
|
ClutterSeat *seat;
|
||||||
|
|
||||||
/* Key symbol should be ignored for printable characters */
|
/* Key symbol should be ignored for printable characters */
|
||||||
clutter_event_set_key_symbol (event, 0);
|
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||||
clutter_event_set_key_unicode (event, unichar);
|
event = clutter_event_key_new (CLUTTER_KEY_PRESS,
|
||||||
|
CLUTTER_EVENT_FLAG_SYNTHETIC,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
clutter_seat_get_keyboard (seat),
|
||||||
|
0, 0, 0, 0, unichar);
|
||||||
|
|
||||||
clutter_actor_event (CLUTTER_ACTOR (text), event, FALSE);
|
clutter_actor_event (CLUTTER_ACTOR (text), event, FALSE);
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,6 @@ static void wrap (gfloat *value, gfloat min, gfloat max)
|
||||||
|
|
||||||
static gboolean perf_fake_mouse_cb (gpointer stage)
|
static gboolean perf_fake_mouse_cb (gpointer stage)
|
||||||
{
|
{
|
||||||
ClutterEvent *event = clutter_event_new (CLUTTER_MOTION);
|
|
||||||
static ClutterInputDevice *device = NULL;
|
static ClutterInputDevice *device = NULL;
|
||||||
int i;
|
int i;
|
||||||
static float x = 0.0;
|
static float x = 0.0;
|
||||||
|
@ -99,35 +98,41 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
|
||||||
hack is deprecated
|
hack is deprecated
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
ClutterEvent *event2 = clutter_event_new (CLUTTER_ENTER);
|
ClutterEvent *event;
|
||||||
ClutterBackend *backend = clutter_get_default_backend ();
|
ClutterBackend *backend = clutter_get_default_backend ();
|
||||||
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
|
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
|
||||||
|
|
||||||
device = clutter_seat_get_pointer (seat);
|
device = clutter_seat_get_pointer (seat);
|
||||||
|
|
||||||
event2->crossing.stage = stage;
|
event = clutter_event_crossing_new (CLUTTER_ENTER,
|
||||||
event2->crossing.x = 10;
|
CLUTTER_EVENT_NONE,
|
||||||
event2->crossing.y = 10;
|
CLUTTER_CURRENT_TIME,
|
||||||
event2->crossing.related = NULL;
|
device, NULL,
|
||||||
|
GRAPHENE_POINT_INIT (10, 10),
|
||||||
clutter_event_set_device (event2, device);
|
stage,
|
||||||
|
NULL);
|
||||||
clutter_event_put (event2);
|
clutter_event_put (event);
|
||||||
clutter_event_free (event2);
|
clutter_event_free (event);
|
||||||
inited = TRUE;
|
inited = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
clutter_actor_get_size (stage, &w, &h);
|
clutter_actor_get_size (stage, &w, &h);
|
||||||
event->motion.stage = stage;
|
|
||||||
clutter_event_set_device (event, device);
|
|
||||||
|
|
||||||
/* called about every 60fps, and do 10 picks per stage */
|
/* called about every 60fps, and do 10 picks per stage */
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
event->motion.x = x;
|
ClutterEvent *event;
|
||||||
event->motion.y = y;
|
|
||||||
|
|
||||||
|
event = clutter_event_motion_new (CLUTTER_EVENT_NONE,
|
||||||
|
CLUTTER_CURRENT_TIME,
|
||||||
|
device, NULL, 0,
|
||||||
|
GRAPHENE_POINT_INIT (x, y),
|
||||||
|
GRAPHENE_POINT_INIT (0, 0),
|
||||||
|
GRAPHENE_POINT_INIT (0, 0),
|
||||||
|
GRAPHENE_POINT_INIT (0, 0),
|
||||||
|
NULL);
|
||||||
clutter_event_put (event);
|
clutter_event_put (event);
|
||||||
|
clutter_event_free (event);
|
||||||
|
|
||||||
x += xd;
|
x += xd;
|
||||||
y += yd;
|
y += yd;
|
||||||
|
@ -140,6 +145,5 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
|
||||||
xd = CLAMP(xd, -1.3, 1.3);
|
xd = CLAMP(xd, -1.3, 1.3);
|
||||||
yd = CLAMP(yd, -1.3, 1.3);
|
yd = CLAMP(yd, -1.3, 1.3);
|
||||||
}
|
}
|
||||||
clutter_event_free (event);
|
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,9 +167,10 @@ meta_backend_test_add_test_device (MetaBackendTest *backend_test,
|
||||||
"n-buttons", n_buttons,
|
"n-buttons", n_buttons,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
event = clutter_event_new (CLUTTER_DEVICE_ADDED);
|
event = clutter_event_device_notify_new (CLUTTER_DEVICE_ADDED,
|
||||||
clutter_event_set_device (event, device);
|
CLUTTER_EVENT_NONE,
|
||||||
clutter_event_set_stage (event, stage);
|
CLUTTER_CURRENT_TIME,
|
||||||
|
device);
|
||||||
clutter_event_put (event);
|
clutter_event_put (event);
|
||||||
clutter_event_free (event);
|
clutter_event_free (event);
|
||||||
|
|
||||||
|
@ -193,9 +194,10 @@ meta_backend_test_remove_device (MetaBackendTest *backend_test,
|
||||||
g_signal_connect (stage, "after-update", G_CALLBACK (on_after_update),
|
g_signal_connect (stage, "after-update", G_CALLBACK (on_after_update),
|
||||||
&was_updated);
|
&was_updated);
|
||||||
|
|
||||||
event = clutter_event_new (CLUTTER_DEVICE_REMOVED);
|
event = clutter_event_device_notify_new (CLUTTER_DEVICE_REMOVED,
|
||||||
clutter_event_set_device (event, device);
|
CLUTTER_EVENT_NONE,
|
||||||
clutter_event_set_stage (event, stage);
|
CLUTTER_CURRENT_TIME,
|
||||||
|
device);
|
||||||
clutter_event_put (event);
|
clutter_event_put (event);
|
||||||
clutter_event_free (event);
|
clutter_event_free (event);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue