summaryrefslogtreecommitdiff
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
commitf8633236503df6e3caea9ed7975d6a81bc5c8025 (patch)
tree9928b40cbf4b314c0722e1249bde74cf15b9e4b7
parente24b8a8cef001e1c7e50ab12b739486f59b2a850 (diff)
Describe the hello window from main
hello no longer needs an init callback: main passes its window spec through yasl_app_desc.window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--README.md5
-rw-r--r--docs/getting-started.md5
-rw-r--r--examples/hello.c17
-rw-r--r--tests/common/test_hello_example.c5
4 files changed, 11 insertions, 21 deletions
diff --git a/README.md b/README.md
index 358ee7c..db52dd1 100644
--- a/README.md
+++ b/README.md
@@ -48,8 +48,9 @@ selection chooses the native session and allows fallback, or you can request an
explicit backend with `yasl_display_spec.backend`.
Include `<yasl/app.h>` and pass application callbacks to `yasl_run()`.
-The complete [hello.c](examples/hello.c) creates its window in `init`, handles
-close requests in `event`, and fills every pixel in its frame callback:
+The complete [hello.c](examples/hello.c) describes its window in
+`yasl_app_desc.window`, handles close requests in `event`, and fills every pixel
+in its frame callback:
```c
static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_context *frame)
diff --git a/docs/getting-started.md b/docs/getting-started.md
index caa25eb..906d425 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -38,8 +38,9 @@ Its minimum deployment target is macOS 14. Set `MACOSX_DEPLOYMENT_TARGET=14.0`
CPU pixel targets are presented through the system's Metal device; applications
do not need to create or manage that device themselves.
-The complete beginner example is [hello.c](../examples/hello.c). It checks
-construction failures, fills every pixel, and presents inside a frame callback.
+The complete beginner example is [hello.c](../examples/hello.c). It lets
+`yasl_run()` create its window from `yasl_app_desc.window`, fills every pixel,
+and presents inside a frame callback.
`yasl_run()` handles input delivery, display notifications, and cleanup. The
[interactive window](../examples/simple_window.c) adds pointer input; the
[tablet example](../examples/tablet.c) demonstrates retained application content,
diff --git a/examples/hello.c b/examples/hello.c
index 1761e04..d3d74cf 100644
--- a/examples/hello.c
+++ b/examples/hello.c
@@ -5,20 +5,6 @@
static bool failed;
-static enum yasl_app_result init(void *ud, struct yasl_display *display)
-{
- (void)ud;
- struct yasl_window_spec spec = {.title = "Hello YASL", .size = {640, 480}};
- struct yasl_surface *surface = yasl_surface_create_toplevel(display, &spec);
- if (!surface) {
- perror("yasl_surface_create_toplevel");
- failed = true;
- return YASL_APP_QUIT;
- }
- yasl_surface_request_frame(surface);
- return YASL_APP_CONTINUE;
-}
-
static enum yasl_app_result event(void *ud, const struct yasl_event *event)
{
(void)ud;
@@ -41,9 +27,10 @@ static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_conte
int main(void)
{
+ struct yasl_window_spec window = {.title = "Hello YASL", .size = {640, 480}};
struct yasl_app_desc desc = {
.app_id = "org.example.hello",
- .init = init,
+ .window = &window,
.event = event,
.frame = draw,
};
diff --git a/tests/common/test_hello_example.c b/tests/common/test_hello_example.c
index 7faa147..c648038 100644
--- a/tests/common/test_hello_example.c
+++ b/tests/common/test_hello_example.c
@@ -11,9 +11,10 @@ static void draw_once(void *ud, struct yasl_surface *surface, struct yasl_frame_
int main(void)
{
+ struct yasl_window_spec window = {.title = "Hello YASL", .size = {640, 480}};
struct yasl_app_desc desc = {
- .app_id = "org.yasl.test.hello",
- .init = init, .event = event, .frame = draw_once,
+ .app_id = "org.yasl.test.hello", .window = &window,
+ .event = event, .frame = draw_once,
};
return yasl_run(&desc) || failed ? 1 : 0;
}