From c059e3aa7f93da470f052a5cd8ee0d8dc969e679 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 13:44:13 +0300 Subject: rename and simplification --- src/common/backend.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/common/backend.c') diff --git a/src/common/backend.c b/src/common/backend.c index e690697..be06136 100644 --- a/src/common/backend.c +++ b/src/common/backend.c @@ -152,7 +152,7 @@ void yasl_display_drag_cancel(struct yasl_display *d) } struct yasl_surface *yasl_create_toplevel(struct yasl_display *d, - const struct yasl_surface_spec *spec, void *graphics_device) + const struct yasl_window_spec *spec, void *graphics_device) { if (!d || !d->ops->surface_create_toplevel || !spec || spec->size.x <= 0 || spec->size.y <= 0 || @@ -168,14 +168,19 @@ struct yasl_surface *yasl_create_toplevel(struct yasl_display *d, errno = 0; struct yasl_surface *s = d->ops->surface_create_toplevel(d, spec, graphics_device); if (!s && !errno) errno = ENODEV; - if (s && d->app_runner) { - app_runner_register_surface(d->app_runner, s); + if (s) { + /* Native creation may dispatch events. Attach this window's callbacks + * only after it finishes, so callers can store the returned surface. */ + if (d->app_runner) + app_runner_register_surface(d->app_runner, s); + else + yasl_surface_set_callbacks(s, spec->cbs, spec->ud); } return s; } struct yasl_surface *yasl_surface_create_toplevel(struct yasl_display *d, - const struct yasl_surface_spec *spec) + const struct yasl_window_spec *spec) { return yasl_create_toplevel(d, spec, NULL); } @@ -246,11 +251,11 @@ struct yasl_display *yasl_surface_display(const struct yasl_surface *s) return s ? s->display : NULL; } -void yasl_surface_set_callbacks(struct yasl_surface *s, const struct yasl_surface_cbs *cbs, void *ud) +void yasl_surface_set_callbacks(struct yasl_surface *s, const struct yasl_window_cbs *cbs, void *ud) { if (!s) return; - s->callbacks = cbs ? *cbs : (struct yasl_surface_cbs){0}; + s->callbacks = cbs ? *cbs : (struct yasl_window_cbs){0}; s->ud = ud; if (s->display && s->display->ops && s->display->ops->surface_set_callbacks) s->display->ops->surface_set_callbacks(s, cbs, ud); -- cgit v1.2.3