mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 12:32:05 +00:00
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
@ -28,6 +28,7 @@
|
||||
#include "clutter/clutter-types.h"
|
||||
#include "clutter/clutter-actor.h"
|
||||
#include "clutter/clutter-color.h"
|
||||
#include "clutter/clutter-event-private.h"
|
||||
#include "clutter/clutter-private.h"
|
||||
#include "meta/common.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;
|
||||
|
||||
/* Create a synthetic hold event */
|
||||
event = clutter_event_new (CLUTTER_TOUCHPAD_HOLD);
|
||||
event->touchpad_hold.phase = test_case->phase;
|
||||
event->touchpad_hold.time = EVENT_TIME;
|
||||
event->touchpad_hold.n_fingers = test_case->n_fingers;
|
||||
event->touchpad_hold.stage = (ClutterStage *) stage;
|
||||
clutter_event_set_coords (event, test_case->x, test_case->y);
|
||||
clutter_event_set_device (event, device);
|
||||
|
||||
event = clutter_event_touchpad_hold_new (CLUTTER_EVENT_NONE,
|
||||
EVENT_TIME,
|
||||
device,
|
||||
test_case->phase,
|
||||
test_case->n_fingers,
|
||||
GRAPHENE_POINT_INIT (test_case->x,
|
||||
test_case->y));
|
||||
clutter_event_put (event);
|
||||
clutter_event_free (event);
|
||||
|
||||
|
@ -224,27 +224,23 @@ key_group_init (KeyGroup *self)
|
||||
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
|
||||
send_keyval (KeyGroup *group, int keyval)
|
||||
{
|
||||
ClutterKeyEvent event;
|
||||
ClutterSeat *seat;
|
||||
ClutterEvent *event;
|
||||
|
||||
init_event (&event);
|
||||
event.keyval = keyval;
|
||||
event.unicode_value = 0; /* should be ignored for cursor keys etc. */
|
||||
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||
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 (group), (ClutterEvent *) &event, FALSE);
|
||||
clutter_actor_event (CLUTTER_ACTOR (group), event, FALSE);
|
||||
clutter_event_free (event);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -327,25 +327,19 @@ text_password_char (void)
|
||||
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
|
||||
send_keyval (ClutterText *text, int keyval)
|
||||
{
|
||||
ClutterEvent *event = init_event ();
|
||||
ClutterEvent *event;
|
||||
ClutterSeat *seat;
|
||||
|
||||
/* Unicode should be ignored for cursor keys etc. */
|
||||
clutter_event_set_key_unicode (event, 0);
|
||||
clutter_event_set_key_symbol (event, keyval);
|
||||
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||
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);
|
||||
|
||||
@ -355,11 +349,16 @@ send_keyval (ClutterText *text, int keyval)
|
||||
static void
|
||||
send_unichar (ClutterText *text, gunichar unichar)
|
||||
{
|
||||
ClutterEvent *event = init_event ();
|
||||
ClutterEvent *event;
|
||||
ClutterSeat *seat;
|
||||
|
||||
/* Key symbol should be ignored for printable characters */
|
||||
clutter_event_set_key_symbol (event, 0);
|
||||
clutter_event_set_key_unicode (event, unichar);
|
||||
seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
|
||||
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);
|
||||
|
||||
|
@ -78,7 +78,6 @@ static void wrap (gfloat *value, gfloat min, gfloat max)
|
||||
|
||||
static gboolean perf_fake_mouse_cb (gpointer stage)
|
||||
{
|
||||
ClutterEvent *event = clutter_event_new (CLUTTER_MOTION);
|
||||
static ClutterInputDevice *device = NULL;
|
||||
int i;
|
||||
static float x = 0.0;
|
||||
@ -99,35 +98,41 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
|
||||
hack is deprecated
|
||||
*/
|
||||
{
|
||||
ClutterEvent *event2 = clutter_event_new (CLUTTER_ENTER);
|
||||
ClutterEvent *event;
|
||||
ClutterBackend *backend = clutter_get_default_backend ();
|
||||
ClutterSeat *seat = clutter_backend_get_default_seat (backend);
|
||||
|
||||
device = clutter_seat_get_pointer (seat);
|
||||
|
||||
event2->crossing.stage = stage;
|
||||
event2->crossing.x = 10;
|
||||
event2->crossing.y = 10;
|
||||
event2->crossing.related = NULL;
|
||||
|
||||
clutter_event_set_device (event2, device);
|
||||
|
||||
clutter_event_put (event2);
|
||||
clutter_event_free (event2);
|
||||
event = clutter_event_crossing_new (CLUTTER_ENTER,
|
||||
CLUTTER_EVENT_NONE,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
device, NULL,
|
||||
GRAPHENE_POINT_INIT (10, 10),
|
||||
stage,
|
||||
NULL);
|
||||
clutter_event_put (event);
|
||||
clutter_event_free (event);
|
||||
inited = TRUE;
|
||||
}
|
||||
|
||||
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 */
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
event->motion.x = x;
|
||||
event->motion.y = y;
|
||||
ClutterEvent *event;
|
||||
|
||||
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_free (event);
|
||||
|
||||
x += xd;
|
||||
y += yd;
|
||||
@ -140,6 +145,5 @@ static gboolean perf_fake_mouse_cb (gpointer stage)
|
||||
xd = CLAMP(xd, -1.3, 1.3);
|
||||
yd = CLAMP(yd, -1.3, 1.3);
|
||||
}
|
||||
clutter_event_free (event);
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
|
@ -167,9 +167,10 @@ meta_backend_test_add_test_device (MetaBackendTest *backend_test,
|
||||
"n-buttons", n_buttons,
|
||||
NULL);
|
||||
|
||||
event = clutter_event_new (CLUTTER_DEVICE_ADDED);
|
||||
clutter_event_set_device (event, device);
|
||||
clutter_event_set_stage (event, stage);
|
||||
event = clutter_event_device_notify_new (CLUTTER_DEVICE_ADDED,
|
||||
CLUTTER_EVENT_NONE,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
device);
|
||||
clutter_event_put (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),
|
||||
&was_updated);
|
||||
|
||||
event = clutter_event_new (CLUTTER_DEVICE_REMOVED);
|
||||
clutter_event_set_device (event, device);
|
||||
clutter_event_set_stage (event, stage);
|
||||
event = clutter_event_device_notify_new (CLUTTER_DEVICE_REMOVED,
|
||||
CLUTTER_EVENT_NONE,
|
||||
CLUTTER_CURRENT_TIME,
|
||||
device);
|
||||
clutter_event_put (event);
|
||||
clutter_event_free (event);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user