mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-03 05:21:35 +00:00
tests: add frame callback waiting helpers
To avoid duplicating the code for setting and waiting for a frame callback, add helpers for it. Convert move_client() to use the new helpers. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
This commit is contained in:
parent
19dadf2617
commit
8aaef7d48c
|
@ -41,8 +41,7 @@ surface_contains(struct surface *surface, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
move_client_frame_handler(void *data,
|
frame_callback_handler(void *data, struct wl_callback *callback, uint32_t time)
|
||||||
struct wl_callback *callback, uint32_t time)
|
|
||||||
{
|
{
|
||||||
int *done = data;
|
int *done = data;
|
||||||
|
|
||||||
|
@ -52,14 +51,33 @@ move_client_frame_handler(void *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_callback_listener frame_listener = {
|
static const struct wl_callback_listener frame_listener = {
|
||||||
move_client_frame_handler
|
frame_callback_handler
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct wl_callback *
|
||||||
|
frame_callback_set(struct wl_surface *surface, int *done)
|
||||||
|
{
|
||||||
|
struct wl_callback *callback;
|
||||||
|
|
||||||
|
*done = 0;
|
||||||
|
callback = wl_surface_frame(surface);
|
||||||
|
wl_callback_add_listener(callback, &frame_listener, done);
|
||||||
|
|
||||||
|
return callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
frame_callback_wait(struct client *client, int *done)
|
||||||
|
{
|
||||||
|
while (!*done) {
|
||||||
|
assert(wl_display_dispatch(client->wl_display) >= 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
move_client(struct client *client, int x, int y)
|
move_client(struct client *client, int x, int y)
|
||||||
{
|
{
|
||||||
struct surface *surface = client->surface;
|
struct surface *surface = client->surface;
|
||||||
struct wl_callback *callback;
|
|
||||||
int done;
|
int done;
|
||||||
|
|
||||||
client->surface->x = x;
|
client->surface->x = x;
|
||||||
|
@ -69,14 +87,11 @@ move_client(struct client *client, int x, int y)
|
||||||
wl_surface_damage(surface->wl_surface, 0, 0, surface->width,
|
wl_surface_damage(surface->wl_surface, 0, 0, surface->width,
|
||||||
surface->height);
|
surface->height);
|
||||||
|
|
||||||
callback = wl_surface_frame(surface->wl_surface);
|
frame_callback_set(surface->wl_surface, &done);
|
||||||
done = 0;
|
|
||||||
wl_callback_add_listener(callback, &frame_listener, &done);
|
|
||||||
|
|
||||||
wl_surface_commit(surface->wl_surface);
|
wl_surface_commit(surface->wl_surface);
|
||||||
|
|
||||||
while (!done)
|
frame_callback_wait(client, &done);
|
||||||
wl_display_dispatch(client->wl_display);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -111,4 +111,10 @@ move_client(struct client *client, int x, int y);
|
||||||
assert(wl_display_roundtrip((c)->wl_display) >= 0); \
|
assert(wl_display_roundtrip((c)->wl_display) >= 0); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
struct wl_callback *
|
||||||
|
frame_callback_set(struct wl_surface *surface, int *done);
|
||||||
|
|
||||||
|
void
|
||||||
|
frame_callback_wait(struct client *client, int *done);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue