From e24b8a8cef001e1c7e50ab12b739486f59b2a850 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 15:43:04 +0300 Subject: Let yasl_app_desc describe its initial window A new optional yasl_app_desc.window spec makes yasl_run() create that toplevel and request its first frame before init(), which is now optional too. If creation fails, yasl_run() closes the display and returns an error without calling init(). Co-Authored-By: Claude Opus 5.5 --- src/common/app.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/common') diff --git a/src/common/app.c b/src/common/app.c index 9ec1f6a..9d52e4a 100644 --- a/src/common/app.c +++ b/src/common/app.c @@ -332,7 +332,7 @@ static void app_runner_lost(void *ud) int yasl_run(const struct yasl_app_desc *desc) { - if (!desc || !desc->init) + if (!desc) return -1; struct app_runner runner = {.desc = desc, .running = true}; @@ -358,7 +358,20 @@ int yasl_run(const struct yasl_app_desc *desc) } d->app_runner = &runner; - if (desc->init(desc->userdata, d) == YASL_APP_QUIT) { + if (desc->window) { + struct yasl_surface *s = yasl_surface_create_toplevel(d, desc->window); + if (!s) { + int create_error = errno; + d->app_runner = NULL; + yasl_mutex_destroy(&runner.user_event_mutex); + yasl_display_close(d); + errno = create_error; + return -1; + } + yasl_surface_request_frame(s); + } + + if (desc->init && desc->init(desc->userdata, d) == YASL_APP_QUIT) { runner.running = false; } -- cgit v1.2.3