From 76073fe5fad8799e5850805f2f090af2cb62c741 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 23:41:31 +0300 Subject: Simplify the public event and CPU API Applications now need far less ceremony: hello.c is a 20-line loop that handles REFRESH, CLOSE and QUIT and draws into the surface's own pixels. - Fold GEOMETRY, STATE and FOCUS into one WINDOW event carrying size, scale and state; unchanged values send nothing. - Guarantee REFRESH once a window has a size and after every resize, never at size zero. - Merge DROP_HOVER into DROP with over/leave/data actions and give drag and drop actions enums. - Keep event strings valid until the next wait and drop yasl_event_release; empty or failed waits report NONE. - Replace copy-in presentation with a lent pixel buffer: yasl_cpu_pixels and yasl_cpu_present. - Remove yasl_poll_event, yasl_cpu_read_pixels, unused event fields and comments that restated names. - Wayland: resize floating windows in request_size instead of reporting it unsupported, and stop marking new GPU surfaces as Vulkan so yasl_vulkan_create_surface no longer fails with NATIVE_WINDOW_IN_USE. Also includes the in-progress public API refactor that was uncommitted in the tree (removal of the app/loop layer, new surface, GL and Vulkan entry points). Co-Authored-By: Claude Opus 5.5 --- tests/common/test_backends.c | 302 +++++++++++++++++++++---------------------- 1 file changed, 151 insertions(+), 151 deletions(-) (limited to 'tests/common/test_backends.c') diff --git a/tests/common/test_backends.c b/tests/common/test_backends.c index 30f9b67..7eba57f 100644 --- a/tests/common/test_backends.c +++ b/tests/common/test_backends.c @@ -1,13 +1,13 @@ #define _POSIX_C_SOURCE 200809L -#include "yasl/native.h" +#include "common/private_native.h" #if YASL_HAS_WAYLAND -#include "yasl/native/wayland.h" +#include "common/private_native_wayland.h" #endif #if YASL_HAS_X11 -#include "yasl/native/x11.h" +#include "common/private_native_x11.h" #endif -#include "yasl/loop.h" -#include "yasl/yasl.h" +#include "common/private_loop.h" +#include "common/types.h" #include #include @@ -24,14 +24,14 @@ struct window { struct yasl_surface *surface; - struct yasl_display *display; + struct yasl_private_display *display; int draws, configures, closes; bool destroy_on_draw, destroy_on_configure; }; struct pump { - struct yasl_loop *loop; - struct yasl_display *displays[2]; + struct yasl_private_loop *loop; + struct yasl_private_display *displays[2]; int ticks; }; @@ -43,76 +43,76 @@ static int tick(int fd, short events, void *ud) struct pump *p = ud; for (int i = 0; i < 2; i++) { if (p->displays[i]) { - yasl_display_dispatch(p->displays[i], 0); - yasl_display_flush(p->displays[i]); + yasl_private_display_dispatch(p->displays[i], 0); + yasl_private_display_flush(p->displays[i]); } } - if (--p->ticks == 0) yasl_loop_quit(p->loop); + if (--p->ticks == 0) yasl_private_loop_quit(p->loop); return 0; } -static void pump(struct yasl_loop *loop, struct yasl_display *a, struct yasl_display *b) +static void pump(struct yasl_private_loop *loop, struct yasl_private_display *a, struct yasl_private_display *b) { int timer = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); assert(timer >= 0); struct pump p = {.loop = loop, .displays = {a, b}, .ticks = 20}; struct itimerspec spec = {.it_value.tv_nsec = 10000000, .it_interval.tv_nsec = 10000000}; assert(timerfd_settime(timer, 0, &spec, NULL) == 0); - int watch = yasl_loop_add_fd(loop, timer, POLLIN, tick, &p); + int watch = yasl_private_loop_add_fd(loop, timer, POLLIN, tick, &p); assert(watch > 0); - assert(yasl_loop_run(loop) == 0); - assert(yasl_loop_del_fd(loop, watch) == 0); + assert(yasl_private_loop_run(loop) == 0); + assert(yasl_private_loop_del_fd(loop, watch) == 0); close(timer); } -static void draw(struct yasl_surface *s, struct yasl_frame *frame, void *ud) +static void draw(struct yasl_surface *s, struct yasl_private_frame *frame, void *ud) { struct window *w = ud; assert(s == w->surface); assert(frame->surface == s); - assert(yasl_surface_display(s) == w->display); - struct yasl_vector2i size = yasl_surface_geometry(s).size; + assert(yasl_private_surface_display(s) == w->display); + struct yasl_private_vector2i size = yasl_private_surface_geometry(s).size; assert(size.x == frame->target.size.x && size.y == frame->target.size.y); assert(frame->target.pixels); - struct yasl_native_frame native = {0}; - assert(!yasl_surface_get_native_frame(s, &frame->target, &native)); + struct yasl_private_native_frame native = {0}; + assert(!yasl_private_surface_get_native_frame(s, &frame->target, &native)); for (int i = 0; i < size.x * size.y; i++) frame->target.pixels[i] = 0xff4080c0; - struct yasl_damage_list damage = {.n = YASL_DAMAGE_MAX + 1}; - assert(!yasl_surface_present(s, &frame->target, &damage)); + struct yasl_private_damage_list damage = {.n = YASL_PRIVATE_DAMAGE_MAX + 1}; + assert(!yasl_private_surface_present(s, &frame->target, &damage)); damage.n = -2; - assert(!yasl_surface_present(s, &frame->target, &damage)); + assert(!yasl_private_surface_present(s, &frame->target, &damage)); damage.n = 1; damage.rects[0].width = -1; - assert(!yasl_surface_present(s, &frame->target, &damage)); + assert(!yasl_private_surface_present(s, &frame->target, &damage)); damage.n = -1; - struct yasl_framebuffer invalid = frame->target; + struct yasl_private_framebuffer invalid = frame->target; invalid.size.x++; - assert(!yasl_surface_present(s, &invalid, &damage)); + assert(!yasl_private_surface_present(s, &invalid, &damage)); invalid = frame->target; invalid.generation--; - assert(!yasl_surface_present(s, &invalid, &damage)); + assert(!yasl_private_surface_present(s, &invalid, &damage)); invalid = frame->target; invalid.pixels = (uint32_t *)(uintptr_t)1; - assert(!yasl_surface_present(s, &invalid, &damage)); - assert(!yasl_surface_present(s, &frame->target, NULL)); - assert(yasl_surface_present(s, &frame->target, &damage)); - assert(!yasl_surface_present(s, &frame->target, &damage)); + assert(!yasl_private_surface_present(s, &invalid, &damage)); + assert(!yasl_private_surface_present(s, &frame->target, NULL)); + assert(yasl_private_surface_present(s, &frame->target, &damage)); + assert(!yasl_private_surface_present(s, &frame->target, &damage)); w->draws++; - if (w->destroy_on_draw) { yasl_surface_destroy(s); w->surface = NULL; } + if (w->destroy_on_draw) { yasl_private_surface_destroy(s); w->surface = NULL; } } -static void configure(struct yasl_surface *s, struct yasl_geometry geometry, void *ud) +static void configure(struct yasl_surface *s, struct yasl_private_geometry geometry, void *ud) { struct window *w = ud; assert(w->surface == s); - struct yasl_vector2i size = yasl_surface_geometry(s).size; + struct yasl_private_vector2i size = yasl_private_surface_geometry(s).size; assert(geometry.size.x == size.x && geometry.size.y == size.y); - assert(geometry.scale_120 == yasl_surface_geometry(s).scale_120); + assert(geometry.scale_120 == yasl_private_surface_geometry(s).scale_120); w->configures++; - if (w->destroy_on_configure) { yasl_surface_destroy(s); w->surface = NULL; } + if (w->destroy_on_configure) { yasl_private_surface_destroy(s); w->surface = NULL; } } -static void draw_without_present(struct yasl_surface *s, struct yasl_frame *frame, void *ud) +static void draw_without_present(struct yasl_surface *s, struct yasl_private_frame *frame, void *ud) { (void)s; struct window *w = ud; @@ -126,62 +126,62 @@ static void close_window(struct yasl_surface *s, void *ud) struct window *w = ud; assert(s == w->surface); w->closes++; - yasl_surface_destroy(s); + yasl_private_surface_destroy(s); w->surface = NULL; } -static const struct yasl_window_cbs callbacks = { +static const struct yasl_private_window_cbs callbacks = { .draw = draw, .configure = configure, .close = close_window, }; static void attach(struct window *w) { - struct yasl_window_cbs temporary = callbacks; - yasl_surface_set_callbacks(w->surface, &temporary, w); + struct yasl_private_window_cbs temporary = callbacks; + yasl_private_surface_set_callbacks(w->surface, &temporary, w); temporary.draw = NULL; temporary.configure = NULL; temporary.close = NULL; } -static struct window create(struct yasl_display *d) +static struct window create(struct yasl_private_display *d) { - struct yasl_window_spec spec = {.title = "Backend test", .size = {160, 100}}; - struct yasl_surface *s = yasl_surface_create_toplevel(d, &spec); + struct yasl_private_window_spec spec = {.title = "Backend test", .size = {160, 100}}; + struct yasl_surface *s = yasl_private_surface_create_toplevel(d, &spec); assert(s); - assert(yasl_display_get_native_handle(d)); - assert(yasl_surface_get_native_handle(s)); - assert(yasl_surface_display(s) == d); - assert(yasl_surface_timing(s).source == YASL_TIMING_UNKNOWN); + assert(yasl_private_display_get_native_handle(d)); + assert(yasl_private_surface_get_native_handle(s)); + assert(yasl_private_surface_display(s) == d); + assert(yasl_private_surface_timing(s).source == YASL_PRIVATE_TIMING_UNKNOWN); return (struct window){.surface = s, .display = d}; } /* The last presented frame reads back until a later draw replaces it. */ -static void test_read_pixels(struct yasl_loop *loop, struct yasl_display *d, struct window *w) +static void test_read_pixels(struct yasl_private_loop *loop, struct yasl_private_display *d, struct window *w) { - struct yasl_vector2i size = {-1, -1}; - assert(!yasl_surface_read_pixels(w->surface, NULL, 0, NULL)); - assert(!yasl_surface_read_pixels(NULL, NULL, 0, &size) && !size.x && !size.y); - assert(!yasl_surface_read_pixels(w->surface, NULL, 0, &size)); - struct yasl_vector2i extent = yasl_surface_geometry(w->surface).size; + struct yasl_private_vector2i size = {-1, -1}; + assert(!yasl_private_surface_read_pixels(w->surface, NULL, 0, NULL)); + assert(!yasl_private_surface_read_pixels(NULL, NULL, 0, &size) && !size.x && !size.y); + assert(!yasl_private_surface_read_pixels(w->surface, NULL, 0, &size)); + struct yasl_private_vector2i extent = yasl_private_surface_geometry(w->surface).size; assert(size.x == extent.x && size.y == extent.y); size_t count = (size_t)size.x * (size_t)size.y; uint32_t *pixels = calloc(count, sizeof(*pixels)); assert(pixels); - assert(!yasl_surface_read_pixels(w->surface, pixels, count - 1, &size)); + assert(!yasl_private_surface_read_pixels(w->surface, pixels, count - 1, &size)); assert(!pixels[0]); - assert(yasl_surface_read_pixels(w->surface, pixels, count, &size)); + assert(yasl_private_surface_read_pixels(w->surface, pixels, count, &size)); for (size_t i = 0; i < count; i++) assert(pixels[i] == 0xff4080c0); /* Draws that never present must not show through. X11 reuses its one * target; Wayland keeps the presented buffer while the compositor holds it. */ - struct yasl_window_cbs skip = callbacks; + struct yasl_private_window_cbs skip = callbacks; skip.draw = draw_without_present; - yasl_surface_set_callbacks(w->surface, &skip, w); + yasl_private_surface_set_callbacks(w->surface, &skip, w); for (int i = 0; i < 4; i++) { - yasl_surface_schedule_redraw(w->surface); + yasl_private_surface_schedule_redraw(w->surface); pump(loop, d, NULL); - if (yasl_surface_read_pixels(w->surface, pixels, count, &size)) { - assert(yasl_display_backend(d) != YASL_BACKEND_X11); + if (yasl_private_surface_read_pixels(w->surface, pixels, count, &size)) { + assert(yasl_private_display_backend(d) != YASL_PRIVATE_BACKEND_X11); for (size_t j = 0; j < count; j++) assert(pixels[j] == 0xff4080c0); } else { assert(!size.x && !size.y); @@ -189,47 +189,47 @@ static void test_read_pixels(struct yasl_loop *loop, struct yasl_display *d, str } attach(w); - yasl_surface_schedule_redraw(w->surface); + yasl_private_surface_schedule_redraw(w->surface); pump(loop, d, NULL); memset(pixels, 0, count * sizeof(*pixels)); - assert(yasl_surface_read_pixels(w->surface, pixels, count, &size)); + assert(yasl_private_surface_read_pixels(w->surface, pixels, count, &size)); assert(pixels[0] == 0xff4080c0 && pixels[count - 1] == 0xff4080c0); free(pixels); } -static void test_window_spec(struct yasl_loop *loop, struct yasl_display *d) +static void test_window_spec(struct yasl_private_loop *loop, struct yasl_private_display *d) { struct window w = {.display = d, .destroy_on_draw = true}; { - struct yasl_window_cbs temporary = callbacks; - struct yasl_window_spec spec = { + struct yasl_private_window_cbs temporary = callbacks; + struct yasl_private_window_spec spec = { .title = "Callbacks at creation", .size = {160, 100}, .cbs = &temporary, .ud = &w, }; - w.surface = yasl_surface_create_toplevel(d, &spec); + w.surface = yasl_private_surface_create_toplevel(d, &spec); assert(w.surface); assert(!w.draws && !w.configures && !w.closes); /* Neither the spec nor its callback table needs to outlive creation. */ memset(&temporary, 0, sizeof(temporary)); memset(&spec, 0, sizeof(spec)); } - yasl_surface_schedule_redraw(w.surface); + yasl_private_surface_schedule_redraw(w.surface); pump(loop, d, NULL); assert(w.draws == 1 && !w.surface); } -static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct window *w) +static void x11_behavior(struct yasl_private_loop *loop, struct yasl_private_display *d, struct window *w) { - Display *native = yasl_display_get_native_handle(d); - Window window = (Window)(uintptr_t)yasl_surface_get_native_handle(w->surface); + Display *native = yasl_private_display_get_native_handle(d); + Window window = (Window)(uintptr_t)yasl_private_surface_get_native_handle(w->surface); assert(native && window); - assert(yasl_x11_display_get_display(d) == native); - assert(yasl_x11_surface_get_window(w->surface) == (uintptr_t)window); + assert(yasl_private_x11_display_get_display(d) == native); + assert(yasl_private_x11_surface_get_window(w->surface) == (uintptr_t)window); XSync(native, False); XImage *image = XGetImage(native, window, 0, 0, 1, 1, AllPlanes, ZPixmap); assert(image && (XGetPixel(image, 0, 0) & 0xffffff) == 0x4080c0); XDestroyImage(image); - yasl_surface_set_title(w->surface, "Updated title"); + yasl_private_surface_set_title(w->surface, "Updated title"); char *title = NULL; assert(XFetchName(native, window, &title)); assert(strcmp(title, "Updated title") == 0); @@ -238,19 +238,19 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct XFlush(native); pump(loop, d, NULL); assert(w->configures > 0); - struct yasl_vector2i size = yasl_surface_geometry(w->surface).size; + struct yasl_private_vector2i size = yasl_private_surface_geometry(w->surface).size; assert(size.x == 200 && size.y == 120); /* A server-generated motion verifies the XI2 subscription and cookie * dispatch path, including source-device lookup, rather than SendEvent. */ - struct yasl_event pointer_event; - while (yasl_surface_poll_event(w->surface, &pointer_event)) {} + struct yasl_private_event pointer_event; + while (yasl_private_surface_poll_event(w->surface, &pointer_event)) {} XWarpPointer(native, None, window, 0, 0, 0, 0, 80, 50); XFlush(native); pump(loop, d, NULL); bool saw_motion = false; - while (yasl_surface_poll_event(w->surface, &pointer_event)) { - if (pointer_event.type == YASL_EVENT_POINTER_MOTION) { - assert(pointer_event.pointer.device == YASL_PTR_DEV_MOUSE); + while (yasl_private_surface_poll_event(w->surface, &pointer_event)) { + if (pointer_event.type == YASL_PRIVATE_EVENT_POINTER_MOTION) { + assert(pointer_event.pointer.device == YASL_PRIVATE_PTR_DEV_MOUSE); assert(!pointer_event.pointer.pen.pressure); if (pointer_event.pointer.pos.x == 80 && pointer_event.pointer.pos.y == 50) saw_motion = true; @@ -263,25 +263,25 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct .keycode = XKeysymToKeycode(native, XK_a)}; XSendEvent(native, window, False, KeyPressMask, &key); XFlush(native); - yasl_display_copy(d, YASL_CLIPBOARD, "clipboard text"); - yasl_display_paste(d, YASL_CLIPBOARD, w->surface); + yasl_private_display_copy(d, YASL_PRIVATE_CLIPBOARD, "clipboard text"); + yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, w->surface); pump(loop, d, NULL); bool saw_key = false, saw_paste = false, saw_text = false; - struct yasl_event event; - while (yasl_surface_poll_event(w->surface, &event)) { + struct yasl_private_event event; + while (yasl_private_surface_poll_event(w->surface, &event)) { assert(event.surface == w->surface); - if (event.type == YASL_EVENT_KEY) { + if (event.type == YASL_PRIVATE_EVENT_KEY) { assert(event.key.codepoint == 'a'); assert(event.key.shifted == 'A'); assert(event.key.native_code == key.xkey.keycode); saw_key = event.key.key == YASL_KEY_A; } - if (event.type == YASL_EVENT_PASTE) { + if (event.type == YASL_PRIVATE_EVENT_PASTE) { assert(event.text.len == strlen("clipboard text")); assert(memcmp(event.text.data, "clipboard text", event.text.len) == 0); saw_paste = true; } - if (event.type == YASL_EVENT_TEXT) { + if (event.type == YASL_PRIVATE_EVENT_TEXT) { assert(event.text.len == 1 && event.text.data[0] == 'a'); saw_text = true; } @@ -297,12 +297,12 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct XFlush(native); pump(loop, d, NULL); int key_count = 0, text_count = 0; - while (yasl_surface_poll_event(w->surface, &event)) { - if (event.type == YASL_EVENT_KEY) { + while (yasl_private_surface_poll_event(w->surface, &event)) { + if (event.type == YASL_PRIVATE_EVENT_KEY) { assert(event.key.key == YASL_KEY_A); assert(event.key.action == (key_count ? YASL_KEY_RELEASE : YASL_KEY_PRESS)); key_count++; - } else if (event.type == YASL_EVENT_TEXT) { + } else if (event.type == YASL_PRIVATE_EVENT_TEXT) { assert(event.text.len == 1 && event.text.data[0] == 'A'); text_count++; } @@ -313,10 +313,10 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct XSendEvent(native, window, False, KeyPressMask, &key); XFlush(native); pump(loop, d, NULL); - assert(yasl_surface_poll_event(w->surface, &event)); - assert(event.type == YASL_EVENT_KEY && event.key.key == YASL_KEY_A); - assert(event.key.mods & YASL_MOD_CTRL); - assert(!yasl_surface_poll_event(w->surface, &event)); + assert(yasl_private_surface_poll_event(w->surface, &event)); + assert(event.type == YASL_PRIVATE_EVENT_KEY && event.key.key == YASL_KEY_A); + assert(event.key.mods & YASL_PRIVATE_MOD_CTRL); + assert(!yasl_private_surface_poll_event(w->surface, &event)); int symbols_per_key = 0; KeySym *saved_symbols = XGetKeyboardMapping(native, key.xkey.keycode, 1, &symbols_per_key); @@ -333,11 +333,11 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct XFlush(native); pump(loop, d, NULL); saw_key = saw_text = false; - while (yasl_surface_poll_event(w->surface, &event)) { - if (event.type == YASL_EVENT_KEY) { + while (yasl_private_surface_poll_event(w->surface, &event)) { + if (event.type == YASL_PRIVATE_EVENT_KEY) { assert(event.key.key == YASL_KEY_A && event.key.codepoint == 'q'); saw_key = true; - } else if (event.type == YASL_EVENT_TEXT) { + } else if (event.type == YASL_PRIVATE_EVENT_TEXT) { assert(event.text.len == 1 && event.text.data[0] == 'q'); saw_text = true; } @@ -359,67 +359,67 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct XSendEvent(native, window, False, NoEventMask, &wheel); XFlush(native); pump(loop, d, NULL); - assert(yasl_surface_poll_event(w->surface, &event)); - assert(event.type == YASL_EVENT_POINTER_SCROLL); + assert(yasl_private_surface_poll_event(w->surface, &event)); + assert(event.type == YASL_PRIVATE_EVENT_POINTER_SCROLL); assert(event.pointer.scroll.x == (button == 6 ? -1 : button == 7 ? 1 : 0)); assert(event.pointer.scroll.y == (button == 4 ? -1 : button == 5 ? 1 : 0)); - assert(!yasl_surface_poll_event(w->surface, &event)); + assert(!yasl_private_surface_poll_event(w->surface, &event)); } - assert(yasl_surface_timing(w->surface).source == YASL_TIMING_SUBMISSION); - assert(!(yasl_display_caps(d) & YASL_CAP_FRAME_PACING)); + assert(yasl_private_surface_timing(w->surface).source == YASL_PRIVATE_TIMING_SUBMISSION); + assert(!(yasl_private_display_caps(d) & YASL_PRIVATE_CAP_FRAME_PACING)); /* Reuse caller storage, replace the selection, and exceed the old queue * cap before polling: each paste must retain its own original contents. */ for (int i = 0; i < 300; i++) { char text[32]; snprintf(text, sizeof(text), "owned-%d", i); - yasl_display_copy(d, YASL_CLIPBOARD, text); - yasl_display_paste(d, YASL_CLIPBOARD, w->surface); + yasl_private_display_copy(d, YASL_PRIVATE_CLIPBOARD, text); + yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, w->surface); memset(text, 'x', sizeof(text)); } for (int i = 0; i < 300; i++) { char text[32]; snprintf(text, sizeof(text), "owned-%d", i); - assert(yasl_surface_poll_event(w->surface, &event)); - assert(event.type == YASL_EVENT_PASTE && strcmp(event.text.data, text) == 0); + assert(yasl_private_surface_poll_event(w->surface, &event)); + assert(event.type == YASL_PRIVATE_EVENT_PASTE && strcmp(event.text.data, text) == 0); } const char *last = event.text.data; - assert(!yasl_surface_poll_event(w->surface, &event)); - yasl_display_copy(d, YASL_CLIPBOARD, "changed"); + assert(!yasl_private_surface_poll_event(w->surface, &event)); + yasl_private_display_copy(d, YASL_PRIVATE_CLIPBOARD, "changed"); pump(loop, d, NULL); assert(strcmp(last, "owned-299") == 0); - yasl_display_copy(d, YASL_CLIPBOARD, ""); - yasl_display_paste(d, YASL_CLIPBOARD, w->surface); - assert(yasl_surface_poll_event(w->surface, &event)); - assert(event.type == YASL_EVENT_PASTE && !event.text.len && !event.text.data[0]); + yasl_private_display_copy(d, YASL_PRIVATE_CLIPBOARD, ""); + yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, w->surface); + assert(yasl_private_surface_poll_event(w->surface, &event)); + assert(event.type == YASL_PRIVATE_EVENT_PASTE && !event.text.len && !event.text.data[0]); /* Concurrent external conversions must not share a mutable target slot. */ - struct yasl_display_spec ds = {.backend = YASL_BACKEND_X11}; - struct yasl_display *owner = yasl_display_open(loop, &ds); + struct yasl_private_display_spec ds = {.backend = YASL_PRIVATE_BACKEND_X11}; + struct yasl_private_display *owner = yasl_private_display_open(loop, &ds); assert(owner); - yasl_display_copy(owner, YASL_CLIPBOARD, "external"); + yasl_private_display_copy(owner, YASL_PRIVATE_CLIPBOARD, "external"); struct window other = create(d), cancelled = create(d); - yasl_display_paste(d, YASL_CLIPBOARD, w->surface); - yasl_display_paste(d, YASL_CLIPBOARD, other.surface); - yasl_display_paste(d, YASL_CLIPBOARD, cancelled.surface); - yasl_surface_destroy(cancelled.surface); + yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, w->surface); + yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, other.surface); + yasl_private_display_paste(d, YASL_PRIVATE_CLIPBOARD, cancelled.surface); + yasl_private_surface_destroy(cancelled.surface); pump(loop, d, owner); int first_pastes = 0, second_pastes = 0; - while (yasl_surface_poll_event(w->surface, &event)) { - if (event.type == YASL_EVENT_PASTE) { + while (yasl_private_surface_poll_event(w->surface, &event)) { + if (event.type == YASL_PRIVATE_EVENT_PASTE) { assert(strcmp(event.text.data, "external") == 0); first_pastes++; } } - while (yasl_surface_poll_event(other.surface, &event)) { - if (event.type == YASL_EVENT_PASTE) { + while (yasl_private_surface_poll_event(other.surface, &event)) { + if (event.type == YASL_PRIVATE_EVENT_PASTE) { assert(strcmp(event.text.data, "external") == 0); second_pastes++; } } assert(first_pastes == 1 && second_pastes == 1); - yasl_surface_destroy(other.surface); - yasl_display_close(owner); + yasl_private_surface_destroy(other.surface); + yasl_private_display_close(owner); key.xclient = (XClientMessageEvent){.type = ClientMessage, .display = native, .window = window, .message_type = XInternAtom(native, "WM_PROTOCOLS", False), .format = 32, .data.l = {(long)XInternAtom(native, "WM_DELETE_WINDOW", False)}}; @@ -432,64 +432,64 @@ static void x11_behavior(struct yasl_loop *loop, struct yasl_display *d, struct int main(int argc, char **argv) { assert(argc >= 2); - struct yasl_loop *loop = yasl_loop_create(); + struct yasl_private_loop *loop = yasl_private_loop_create(); assert(loop); if (strcmp(argv[1], "failure") == 0) { - struct yasl_display_spec spec = {.backend = (enum yasl_backend)atoi(argv[2])}; - assert(!yasl_display_open(loop, &spec)); + struct yasl_private_display_spec spec = {.backend = (enum yasl_private_backend)atoi(argv[2])}; + assert(!yasl_private_display_open(loop, &spec)); } else if (strcmp(argv[1], "mixed") == 0) { - struct yasl_display_spec spec = {.backend = YASL_BACKEND_WAYLAND}; - struct yasl_display *a = yasl_display_open(loop, &spec); - spec.backend = YASL_BACKEND_X11; - struct yasl_display *b = yasl_display_open(loop, &spec); + struct yasl_private_display_spec spec = {.backend = YASL_PRIVATE_BACKEND_WAYLAND}; + struct yasl_private_display *a = yasl_private_display_open(loop, &spec); + spec.backend = YASL_PRIVATE_BACKEND_X11; + struct yasl_private_display *b = yasl_private_display_open(loop, &spec); assert(a && b); test_window_spec(loop, a); test_window_spec(loop, b); struct window wa = create(a), wb = create(b); #if YASL_HAS_WAYLAND - assert(yasl_wayland_display_get_wl_display(a) != NULL); - assert(yasl_wayland_surface_get_wl_surface(wa.surface) != NULL); - assert(!yasl_x11_display_get_display(a)); + assert(yasl_private_wayland_display_get_wl_display(a) != NULL); + assert(yasl_private_wayland_surface_get_wl_surface(wa.surface) != NULL); + assert(!yasl_private_x11_display_get_display(a)); #endif #if YASL_HAS_X11 - assert(yasl_x11_display_get_display(b) != NULL); - assert(yasl_x11_surface_get_window(wb.surface) != 0); - assert(!yasl_wayland_display_get_wl_display(b)); + assert(yasl_private_x11_display_get_display(b) != NULL); + assert(yasl_private_x11_surface_get_window(wb.surface) != 0); + assert(!yasl_private_wayland_display_get_wl_display(b)); #endif attach(&wa); attach(&wb); pump(loop, a, b); assert(wa.draws && wb.draws); - yasl_surface_destroy(wa.surface); - yasl_surface_destroy(wb.surface); - yasl_display_close(a); - yasl_display_close(b); + yasl_private_surface_destroy(wa.surface); + yasl_private_surface_destroy(wb.surface); + yasl_private_display_close(a); + yasl_private_display_close(b); } else { assert(argc == 4); - struct yasl_display_spec spec = {.backend = (enum yasl_backend)atoi(argv[2])}; - struct yasl_display *d = strcmp(argv[1], "null") == 0 ? - yasl_display_open(loop, NULL) : yasl_display_open(loop, &spec); + struct yasl_private_display_spec spec = {.backend = (enum yasl_private_backend)atoi(argv[2])}; + struct yasl_private_display *d = strcmp(argv[1], "null") == 0 ? + yasl_private_display_open(loop, NULL) : yasl_private_display_open(loop, &spec); assert(d); - assert(yasl_display_backend(d) == (enum yasl_backend)atoi(argv[3])); + assert(yasl_private_display_backend(d) == (enum yasl_private_backend)atoi(argv[3])); struct window w = create(d); pump(loop, d, NULL); assert(w.draws == 0); attach(&w); - yasl_surface_schedule_redraw(w.surface); + yasl_private_surface_schedule_redraw(w.surface); pump(loop, d, NULL); assert(w.draws > 0); test_read_pixels(loop, d, &w); - if (yasl_display_backend(d) == YASL_BACKEND_X11) + if (yasl_private_display_backend(d) == YASL_PRIVATE_BACKEND_X11) x11_behavior(loop, d, &w); - if (w.surface) yasl_surface_destroy(w.surface); + if (w.surface) yasl_private_surface_destroy(w.surface); w = create(d); w.destroy_on_draw = true; attach(&w); pump(loop, d, NULL); assert(w.draws && !w.surface); - yasl_display_close(d); + yasl_private_display_close(d); } - yasl_loop_destroy(loop); + yasl_private_loop_destroy(loop); puts("Backend test passed."); return 0; } -- cgit v1.2.3