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_desktop.c | 72 ++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'tests/common/test_desktop.c') diff --git a/tests/common/test_desktop.c b/tests/common/test_desktop.c index 89760fe..a665da5 100644 --- a/tests/common/test_desktop.c +++ b/tests/common/test_desktop.c @@ -1,7 +1,7 @@ #define _GNU_SOURCE #include "common/backend.h" #include "platform/freedesktop/dbus.h" -#include "yasl/desktop.h" +#include "common/private_desktop.h" #include #include @@ -39,31 +39,31 @@ static char *read_file(const char *path) static void test_buffers(void) { char exe[PATH_MAX], real[PATH_MAX]; - size_t len = yasl_executable_path(NULL, 0); + size_t len = yasl_private_executable_path(NULL, 0); assert(len > 0); - assert(yasl_executable_path(exe, len) == len); - assert(yasl_executable_path(exe, sizeof(exe)) == len && exe[len] == '\0'); + assert(yasl_private_executable_path(exe, len) == len); + assert(yasl_private_executable_path(exe, sizeof(exe)) == len && exe[len] == '\0'); assert(realpath("/proc/self/exe", real) && strcmp(exe, real) == 0); /* A short buffer stays untouched. */ char small[4] = "abc"; - assert(yasl_executable_path(small, sizeof(small)) == len); + assert(yasl_private_executable_path(small, sizeof(small)) == len); assert(strcmp(small, "abc") == 0); - assert(yasl_executable_path(NULL, 8) == 0); + assert(yasl_private_executable_path(NULL, 8) == 0); - assert(yasl_resource_dir(exe, sizeof(exe)) == 0); + assert(yasl_private_resource_dir(exe, sizeof(exe)) == 0); char locale[64]; setenv("LC_ALL", "", 1); setenv("LC_CTYPE", "de_DE.UTF-8", 1); setenv("LANG", "fr_FR.UTF-8", 1); - assert(yasl_default_locale(locale, sizeof(locale)) == 11); + assert(yasl_private_default_locale(locale, sizeof(locale)) == 11); assert(strcmp(locale, "de_DE.UTF-8") == 0); unsetenv("LC_CTYPE"); - assert(yasl_default_locale(locale, sizeof(locale)) == 11); + assert(yasl_private_default_locale(locale, sizeof(locale)) == 11); assert(strcmp(locale, "fr_FR.UTF-8") == 0); unsetenv("LANG"); unsetenv("LC_ALL"); - assert(yasl_default_locale(locale, sizeof(locale)) == 7); + assert(yasl_private_default_locale(locale, sizeof(locale)) == 7); assert(strcmp(locale, "C.UTF-8") == 0); } @@ -86,14 +86,14 @@ static void test_open_uri(const char *dir) snprintf(path, sizeof(path), "%s:%s", dir, old_path ? old_path : "/usr/bin:/bin"); setenv("PATH", path, 1); - struct yasl_display display = {0}; - assert(!yasl_display_open_uri(NULL, "https://example.com")); - assert(!yasl_display_open_uri(&display, NULL)); - assert(!yasl_display_open_uri(&display, "")); - assert(!yasl_display_open_uri(&display, "example.com")); - assert(!yasl_display_open_uri(&display, "-x:option")); - assert(!yasl_display_open_uri(&display, "1http://example.com")); - assert(!yasl_display_open_uri(&display, "http://example.com/\n")); + struct yasl_private_display display = {0}; + assert(!yasl_private_display_open_uri(NULL, "https://example.com")); + assert(!yasl_private_display_open_uri(&display, NULL)); + assert(!yasl_private_display_open_uri(&display, "")); + assert(!yasl_private_display_open_uri(&display, "example.com")); + assert(!yasl_private_display_open_uri(&display, "-x:option")); + assert(!yasl_private_display_open_uri(&display, "1http://example.com")); + assert(!yasl_private_display_open_uri(&display, "http://example.com/\n")); assert(access(out, F_OK) != 0); /* The opener must not inherit blocked or ignored signals or descriptors. */ @@ -110,7 +110,7 @@ static void test_open_uri(const char *dir) close(null); const char *uri = "https://example.com/a b?c='d'&e=\"f\""; - assert(yasl_display_open_uri(&display, uri)); + assert(yasl_private_display_open_uri(&display, uri)); char *text = NULL; for (int i = 0; i < 500 && !(text = read_file(out)); i++) sleep_ms(10); assert(text); @@ -137,29 +137,29 @@ static void test_open_uri(const char *dir) /* Without xdg-open in PATH, nothing launches. */ setenv("PATH", dir, 1); - assert(!yasl_display_open_uri(&display, "https://example.com")); + assert(!yasl_private_display_open_uri(&display, "https://example.com")); if (old_path) setenv("PATH", old_path, 1); } static void test_appearance_fallback(void) { - assert(yasl_display_double_click_ms(NULL) == YASL_DOUBLE_CLICK_MS_DEFAULT); + assert(yasl_private_display_double_click_ms(NULL) == YASL_PRIVATE_DOUBLE_CLICK_MS_DEFAULT); assert(portal_double_click_ms() == 0); - struct yasl_display display = {0}; - assert(yasl_display_appearance(NULL) == 0); + struct yasl_private_display display = {0}; + assert(yasl_private_display_appearance(NULL) == 0); unsetenv("GTK_THEME"); - assert(yasl_display_appearance(&display) == 0); + assert(yasl_private_display_appearance(&display) == 0); setenv("GTK_THEME", "Adwaita:dark", 1); - assert(yasl_display_appearance(&display) == YASL_APPEARANCE_DARK); + assert(yasl_private_display_appearance(&display) == YASL_PRIVATE_APPEARANCE_DARK); setenv("GTK_THEME", "HighContrast", 1); - assert(yasl_display_appearance(&display) == YASL_APPEARANCE_HIGH_CONTRAST); + assert(yasl_private_display_appearance(&display) == YASL_PRIVATE_APPEARANCE_HIGH_CONTRAST); setenv("GTK_THEME", "HighContrastInverse", 1); - assert(yasl_display_appearance(&display) == - (YASL_APPEARANCE_HIGH_CONTRAST | YASL_APPEARANCE_DARK)); + assert(yasl_private_display_appearance(&display) == + (YASL_PRIVATE_APPEARANCE_HIGH_CONTRAST | YASL_PRIVATE_APPEARANCE_DARK)); unsetenv("GTK_THEME"); - assert(!yasl_display_notify(NULL, "title", "body")); - assert(!yasl_display_notify(&display, NULL, "body")); - assert(!yasl_display_notify(&display, "title", "body")); + assert(!yasl_private_display_notify(NULL, "title", "body")); + assert(!yasl_private_display_notify(&display, NULL, "body")); + assert(!yasl_private_display_notify(&display, "title", "body")); } #if YASL_HAS_DBUS @@ -310,8 +310,8 @@ static void test_bus(const char *address) pthread_t thread; assert(pthread_create(&thread, NULL, serve, &fb) == 0); - struct yasl_display display = {.app_id = "org.example.Test"}; - assert(yasl_display_notify(&display, "Build done", NULL)); + struct yasl_private_display display = {.app_id = "org.example.Test"}; + assert(yasl_private_display_notify(&display, "Build done", NULL)); for (int i = 0; i < 500; i++) { pthread_mutex_lock(&fb.lock); int n = fb.notifications; @@ -328,10 +328,10 @@ static void test_bus(const char *address) /* Portal settings win over GTK_THEME, through ReadOne or the older Read. */ setenv("GTK_THEME", "Adwaita", 1); - uint32_t want = YASL_APPEARANCE_DARK | YASL_APPEARANCE_HIGH_CONTRAST; - assert(yasl_display_appearance(&display) == want); + uint32_t want = YASL_PRIVATE_APPEARANCE_DARK | YASL_PRIVATE_APPEARANCE_HIGH_CONTRAST; + assert(yasl_private_display_appearance(&display) == want); fb.read_one = false; - assert(yasl_display_appearance(&display) == want); + assert(yasl_private_display_appearance(&display) == want); unsetenv("GTK_THEME"); /* A KDE value, sent as a string, wins over the GNOME key. */ -- cgit v1.2.3