summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-13 15:43:04 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-13 15:43:04 +0300
commite24b8a8cef001e1c7e50ab12b739486f59b2a850 (patch)
treef4678f9c7081c2bfd2dad56c8ca456c01447a116 /src/common
parent38533c81e7b7ebfc5f281c2523188aeaa38d09c3 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'src/common')
-rw-r--r--src/common/app.c17
1 files changed, 15 insertions, 2 deletions
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;
}