summaryrefslogtreecommitdiff
path: root/tests/wayland
diff options
context:
space:
mode:
Diffstat (limited to 'tests/wayland')
-rw-r--r--tests/wayland/test_cursor.c8
-rw-r--r--tests/wayland/test_input.c10
-rw-r--r--tests/wayland/test_keyboard.c4
-rw-r--r--tests/wayland/test_popup_positioner.c11
-rw-r--r--tests/wayland/test_relative_pointer.c6
-rw-r--r--tests/wayland/test_state.c37
-rw-r--r--tests/wayland/test_tablet.c8
7 files changed, 51 insertions, 33 deletions
diff --git a/tests/wayland/test_cursor.c b/tests/wayland/test_cursor.c
index 3425821..87cea9a 100644
--- a/tests/wayland/test_cursor.c
+++ b/tests/wayland/test_cursor.c
@@ -77,15 +77,15 @@ int main(void)
tablet_tool_motion(&tool, tool.proxy, wl_fixed_from_int(56), wl_fixed_from_int(78));
tool_frame(&tool, tool.proxy, 0);
struct yasl_private_event event;
- assert(yasl_private_surface_poll_event(&surface.base, &event));
+ assert(input_queue_pop(&surface.input, &event));
assert(event.type == YASL_PRIVATE_EVENT_POINTER_MOTION && event.pointer.device == YASL_PRIVATE_PTR_DEV_MOUSE);
assert(event.pointer.pos.x == 12 && event.pointer.pos.y == 34);
- assert(yasl_private_surface_poll_event(&surface.base, &event));
+ assert(input_queue_pop(&surface.input, &event));
assert(event.type == YASL_PRIVATE_EVENT_PEN && event.pen.action == YASL_PRIVATE_PEN_ENTER);
- assert(yasl_private_surface_poll_event(&surface.base, &event));
+ assert(input_queue_pop(&surface.input, &event));
assert(event.type == YASL_PRIVATE_EVENT_POINTER_MOTION && event.pointer.device == YASL_PRIVATE_PTR_DEV_PEN);
assert(event.pointer.pos.x == 56 && event.pointer.pos.y == 78);
- assert(!yasl_private_surface_poll_event(&surface.base, &event));
+ assert(!input_queue_pop(&surface.input, &event));
/* Each new entry needs a request with its own serial. */
pointer_leave(&seat, seat.pointer, 12, surface.surface);
diff --git a/tests/wayland/test_input.c b/tests/wayland/test_input.c
index 2b5592a..820eb8b 100644
--- a/tests/wayland/test_input.c
+++ b/tests/wayland/test_input.c
@@ -62,7 +62,7 @@ int main(void)
char text[32];
snprintf(text, sizeof(text), "commit-%d", i);
struct yasl_private_event event;
- assert(wayland_surface_poll_event(&w, &event));
+ assert(input_queue_pop(&w.input, &event));
assert(event.type == YASL_PRIVATE_EVENT_TEXT && event.surface == &w.base);
assert(strcmp(event.text.data, text) == 0);
}
@@ -77,21 +77,21 @@ int main(void)
text_input_listener.commit_string(&seat, NULL, "X");
text_input_listener.done(&seat, NULL, 601);
struct yasl_private_event edit;
- assert(wayland_surface_poll_event(&w, &edit));
+ assert(input_queue_pop(&w.input, &edit));
assert(edit.type == YASL_PRIVATE_EVENT_TEXT_EDIT && edit.surface == &w.base);
assert(strcmp(edit.text_edit.data, "X") == 0 && edit.text_edit.len == 1);
assert(edit.text_edit.begin == 2 && edit.text_edit.end == 8);
assert(edit.text_edit.revision == 41 && edit.text_edit.generation == 9);
struct yasl_private_event committed;
- assert(!wayland_surface_poll_event(&w, &committed));
+ assert(!input_queue_pop(&w.input, &committed));
/* Deletion without a commit replaces the range with the empty string. */
text_input_listener.delete_surrounding_text(&seat, NULL, 2, 2);
text_input_listener.done(&seat, NULL, 602);
- assert(wayland_surface_poll_event(&w, &edit));
+ assert(input_queue_pop(&w.input, &edit));
assert(edit.type == YASL_PRIVATE_EVENT_TEXT_EDIT && edit.text_edit.len == 0);
assert(edit.text_edit.data[0] == '\0' && edit.text_edit.begin == 2 && edit.text_edit.end == 8);
- assert(!wayland_surface_poll_event(&w, &committed));
+ assert(!input_queue_pop(&w.input, &committed));
input_queue_clear(&w.input);
free(w.base.text_surrounding);
return 0;
diff --git a/tests/wayland/test_keyboard.c b/tests/wayland/test_keyboard.c
index ae4647f..2f55cf6 100644
--- a/tests/wayland/test_keyboard.c
+++ b/tests/wayland/test_keyboard.c
@@ -4,7 +4,7 @@
static struct yasl_private_event next(struct wayland_surface *w, enum yasl_private_event_type type)
{
struct yasl_private_event ev;
- assert(yasl_private_surface_poll_event(&w->base, &ev));
+ assert(input_queue_pop(&w->input, &ev));
assert(ev.type == type && ev.surface == &w->base);
return ev;
}
@@ -12,7 +12,7 @@ static struct yasl_private_event next(struct wayland_surface *w, enum yasl_priva
static void empty(struct wayland_surface *w)
{
struct yasl_private_event ev;
- assert(!yasl_private_surface_poll_event(&w->base, &ev));
+ assert(!input_queue_pop(&w->input, &ev));
}
static void layout(struct seat *s, const char *name, const char *variant)
diff --git a/tests/wayland/test_popup_positioner.c b/tests/wayland/test_popup_positioner.c
index 86778f6..a851ddb 100644
--- a/tests/wayland/test_popup_positioner.c
+++ b/tests/wayland/test_popup_positioner.c
@@ -1,5 +1,4 @@
-/* Capture xdg_positioner requests to verify explicit placement and the legacy
- * beside mapping without requiring a compositor. */
+/* Capture explicit xdg_positioner placement without requiring a compositor. */
#include "platform/wayland/internal.h"
#include <assert.h>
@@ -56,7 +55,12 @@ int main(void)
struct yasl_private_popup_spec spec = {
.size = {64, 48},
.anchor = {13, 24, 8, 6},
- .beside = true,
+ .anchor_edges = XDG_POSITIONER_ANCHOR_TOP_RIGHT,
+ .gravity = XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT,
+ .constraints = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X |
+ XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y |
+ XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X |
+ XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y,
};
struct xdg_positioner *positioner = popup_positioner(&popup, &spec);
@@ -72,7 +76,6 @@ int main(void)
XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y));
assert(record.reactive);
- spec.positioner_explicit = true;
spec.anchor_edges = XDG_POSITIONER_ANCHOR_NONE;
spec.gravity = XDG_POSITIONER_GRAVITY_RIGHT;
spec.constraints = XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X |
diff --git a/tests/wayland/test_relative_pointer.c b/tests/wayland/test_relative_pointer.c
index d44238d..81cec2f 100644
--- a/tests/wayland/test_relative_pointer.c
+++ b/tests/wayland/test_relative_pointer.c
@@ -68,7 +68,7 @@ static void shape_device_destroy(struct wp_cursor_shape_device_v1 *device) { ass
static struct yasl_private_event next_event(struct wayland_surface *w)
{
struct yasl_private_event event;
- assert(yasl_private_surface_poll_event(&w->base, &event));
+ assert(input_queue_pop(&w->input, &event));
return event;
}
@@ -121,7 +121,7 @@ int main(void)
event = next_event(&surface);
assert(event.pointer.pos.x == 14 && event.pointer.pos.y == 10);
assert(event.pointer.delta.x == 4 && event.pointer.delta.y == 0);
- assert(!yasl_private_surface_poll_event(&surface.base, &event));
+ assert(!input_queue_pop(&surface.input, &event));
/* Locked: relative samples in device pixels, position frozen at the lock. */
pointer_locked(&surface, surface.pointer_lock);
@@ -137,7 +137,7 @@ int main(void)
/* Deactivation (e.g. focus loss) returns to absolute motion without unlocking. */
pointer_unlocked(&surface, surface.pointer_lock);
relative_move(&seat, 5, 5);
- assert(!yasl_private_surface_poll_event(&surface.base, &event));
+ assert(!input_queue_pop(&surface.input, &event));
move_to(&seat, 8, 5);
event = next_event(&surface);
assert(event.pointer.delta.x == 2 && event.pointer.delta.y == 0);
diff --git a/tests/wayland/test_state.c b/tests/wayland/test_state.c
index 1ce9189..c02e01b 100644
--- a/tests/wayland/test_state.c
+++ b/tests/wayland/test_state.c
@@ -20,12 +20,15 @@ struct notifications {
uint32_t state;
};
-static void state_changed(struct yasl_surface *surface, uint32_t state, void *ud)
+static void collect(struct yasl_private_display *display, struct notifications *notifications)
{
- struct notifications *notifications = ud;
- assert(yasl_private_surface_state(surface) == state);
- notifications->count++;
- notifications->state = state;
+ struct yasl_private_event event;
+ while (yasl_private_display_poll_event(display, &event)) {
+ assert(event.type == YASL_PRIVATE_EVENT_WINDOW_STATE);
+ assert(yasl_private_surface_state(event.surface) == event.state.flags);
+ notifications->count++;
+ notifications->state = event.state.flags;
+ }
}
static void configure(struct wayland_surface *surface, uint32_t *states, size_t count)
@@ -38,31 +41,39 @@ static void configure(struct wayland_surface *surface, uint32_t *states, size_t
int main(void)
{
struct notifications notifications = {0};
- struct wayland_surface surface = {.base.state = YASL_PRIVATE_STATE_CSD};
- wayland_surface_set_callbacks(&surface, &(struct yasl_private_window_cbs){
- .state = state_changed}, &notifications);
+ const struct yasl_private_backend_ops ops = {0};
+ struct yasl_private_display display = {.ops = &ops};
+ struct wayland_surface surface = {.base = {.display = &display, .state = YASL_PRIVATE_STATE_CSD}};
+ assert(yasl_private_events_open(&display));
+ assert(yasl_private_events_register(&surface.base));
assert(yasl_private_surface_state(&surface.base) == YASL_PRIVATE_STATE_CSD);
uint32_t fullscreen[] = {XDG_TOPLEVEL_STATE_FULLSCREEN,
XDG_TOPLEVEL_STATE_ACTIVATED, XDG_TOPLEVEL_STATE_FULLSCREEN, 31, UINT32_MAX};
configure(&surface, fullscreen, sizeof(fullscreen) / sizeof(*fullscreen));
+ collect(&display, &notifications);
assert(notifications.count == 1);
assert(notifications.state == (YASL_PRIVATE_STATE_CSD | YASL_PRIVATE_STATE_FULLSCREEN | YASL_PRIVATE_STATE_ACTIVATED));
configure(&surface, fullscreen, sizeof(fullscreen) / sizeof(*fullscreen));
+ collect(&display, &notifications);
assert(notifications.count == 1);
/* Decoration changes preserve the other flags and do not notify twice. */
toplevel_decoration_configure(&surface, NULL, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
+ collect(&display, &notifications);
assert(notifications.count == 2);
assert(notifications.state == (YASL_PRIVATE_STATE_FULLSCREEN | YASL_PRIVATE_STATE_ACTIVATED));
toplevel_decoration_configure(&surface, NULL, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
+ collect(&display, &notifications);
assert(notifications.count == 2);
uint32_t maximized[] = {XDG_TOPLEVEL_STATE_MAXIMIZED, XDG_TOPLEVEL_STATE_SUSPENDED};
configure(&surface, maximized, sizeof(maximized) / sizeof(*maximized));
+ collect(&display, &notifications);
assert(notifications.count == 3);
assert(notifications.state == (YASL_PRIVATE_STATE_MAXIMIZED | YASL_PRIVATE_STATE_SUSPENDED));
toplevel_decoration_configure(&surface, NULL, ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE);
+ collect(&display, &notifications);
assert(notifications.count == 4);
assert(notifications.state == (YASL_PRIVATE_STATE_CSD | YASL_PRIVATE_STATE_MAXIMIZED | YASL_PRIVATE_STATE_SUSPENDED));
@@ -72,19 +83,21 @@ int main(void)
XDG_TOPLEVEL_STATE_TILED_TOP, XDG_TOPLEVEL_STATE_TILED_BOTTOM};
for (size_t i = 0; i < sizeof(edges) / sizeof(*edges); i++) {
configure(&surface, &edges[i], 1);
+ collect(&display, &notifications);
assert(notifications.count == 5);
assert(notifications.state == (YASL_PRIVATE_STATE_CSD | YASL_PRIVATE_STATE_TILED));
}
configure(&surface, edges, 0);
+ collect(&display, &notifications);
assert(notifications.count == 6);
assert(notifications.state == YASL_PRIVATE_STATE_CSD);
- /* State still advances when applications have not installed callbacks. */
- wayland_surface_set_callbacks(&surface, NULL, NULL);
+ /* The authoritative state advances with the queued notification. */
configure(&surface, fullscreen, sizeof(fullscreen) / sizeof(*fullscreen));
assert(yasl_private_surface_state(&surface.base) ==
(YASL_PRIVATE_STATE_CSD | YASL_PRIVATE_STATE_FULLSCREEN | YASL_PRIVATE_STATE_ACTIVATED));
- assert(notifications.count == 6);
+ collect(&display, &notifications);
+ assert(notifications.count == 7);
/* External presentation has no SHM commit callback to acknowledge xdg
* configures. Apply geometry and acknowledge before renderer submission. */
@@ -106,5 +119,7 @@ int main(void)
struct wayland_surface cpu = {.base.presenter = YASL_PRIVATE_PRESENTER_CPU};
xdg_surface_configure(&cpu, (struct xdg_surface *)&cpu, 5678);
assert(acknowledge_count == 1 && cpu.has_pending_serial && cpu.want_draw);
+ yasl_private_events_unregister(&surface.base);
+ yasl_private_events_close(&display);
return 0;
}
diff --git a/tests/wayland/test_tablet.c b/tests/wayland/test_tablet.c
index f47fbfa..0cce568 100644
--- a/tests/wayland/test_tablet.c
+++ b/tests/wayland/test_tablet.c
@@ -4,7 +4,7 @@
static struct yasl_private_event next_raw(struct wayland_surface *surface)
{
struct yasl_private_event event;
- assert(yasl_private_surface_poll_event(&surface->base, &event));
+ assert(input_queue_pop(&surface->input, &event));
assert(event.surface == &surface->base);
return event;
}
@@ -111,9 +111,9 @@ int main(void)
assert(ev.pointer.scroll_valid == 1);
assert(ev.pointer.scroll_source == 1 && ev.pointer.scroll_phase == 0);
struct yasl_private_event unused;
- assert(!yasl_private_surface_poll_event(&surface.base, &unused));
+ assert(!input_queue_pop(&surface.input, &unused));
pointer_frame(&seat, NULL);
- assert(!yasl_private_surface_poll_event(&surface.base, &unused));
+ assert(!input_queue_pop(&surface.input, &unused));
/* Finger scrolling carries pixel offsets and coherent gesture phases. */
pointer_axis_source(&seat, NULL, WL_POINTER_AXIS_SOURCE_FINGER);
@@ -152,7 +152,7 @@ int main(void)
pointer_axis_value120(&seat, NULL, WL_POINTER_AXIS_VERTICAL_SCROLL, 60);
seat_pointer_reset(&seat);
pointer_frame(&seat, NULL);
- assert(!yasl_private_surface_poll_event(&surface.base, &unused));
+ assert(!input_queue_pop(&surface.input, &unused));
input_queue_clear(&surface.input);
return 0;
}