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 --- examples/game.c | 2 +- examples/hello.c | 12 +++++++----- examples/notepad.c | 2 +- examples/simple_window.c | 16 ++++++++-------- examples/tablet.c | 8 +++++--- 5 files changed, 22 insertions(+), 18 deletions(-) (limited to 'examples') diff --git a/examples/game.c b/examples/game.c index bb6c729..7ec28e1 100644 --- a/examples/game.c +++ b/examples/game.c @@ -145,7 +145,7 @@ static int on_init(void *ud, struct yasl_display *d) struct game_state *game = ud; game->display = d; - struct yasl_surface_spec spec = { + struct yasl_window_spec spec = { .title = "YASL 3D Game Loop (Approach A)", .size = {800, 600}, }; diff --git a/examples/hello.c b/examples/hello.c index 67ac88b..0c474c2 100644 --- a/examples/hello.c +++ b/examples/hello.c @@ -72,17 +72,19 @@ int main(int argc, char **argv) perror("yasl_display_open"); return 1; } - struct yasl_surface_spec spec = {.title = "Hello YASL", .size = {640, 480}}; + struct yasl_window_cbs callbacks = { + .draw = draw, .configure = configure, .close = close_window, + }; + struct yasl_window_spec spec = { + .title = "Hello YASL", .size = {640, 480}, + .cbs = &callbacks, .ud = &app, + }; struct yasl_surface *surface = yasl_surface_create_toplevel(display, &spec); if (!surface) { perror("yasl_surface_create_toplevel"); yasl_display_close(display); return 1; } - struct yasl_surface_cbs callbacks = { - .draw = draw, .configure = configure, .close = close_window, - }; - yasl_surface_set_callbacks(surface, &callbacks, &app); yasl_surface_schedule_redraw(surface); while (app.running) { diff --git a/examples/notepad.c b/examples/notepad.c index beb7051..6fb90e9 100644 --- a/examples/notepad.c +++ b/examples/notepad.c @@ -995,7 +995,7 @@ static int on_init(void *ud, struct yasl_display *d) struct editor *ed = ud; ed->display = d; - struct yasl_surface_spec spec = { + struct yasl_window_spec spec = { .title = "Untitled - YASL Notepad", .size = {960, 640}, }; diff --git a/examples/simple_window.c b/examples/simple_window.c index 85db04a..797de3b 100644 --- a/examples/simple_window.c +++ b/examples/simple_window.c @@ -120,23 +120,23 @@ int main(void) return 1; } - struct yasl_surface_spec surf_spec = { + struct yasl_window_cbs window_cbs = { + .draw = on_draw, + .configure = on_configure, + .close = on_close, + }; + struct yasl_window_spec window_spec = { .title = "YASL Interactive Window (Pen & Touch Enabled)", .size = { .x = 640, .y = 480 }, + .cbs = &window_cbs, }; - struct yasl_surface *s = yasl_surface_create_toplevel(d, &surf_spec); + struct yasl_surface *s = yasl_surface_create_toplevel(d, &window_spec); if (!s) { fprintf(stderr, "Failed to create surface\n"); yasl_display_close(d); return 1; } - struct yasl_surface_cbs surf_cbs = { - .draw = on_draw, - .configure = on_configure, - .close = on_close, - }; - yasl_surface_set_callbacks(s, &surf_cbs, NULL); yasl_surface_schedule_redraw(s); printf("=== YASL Demo Running ===\n"); diff --git a/examples/tablet.c b/examples/tablet.c index 0aae370..256d8f8 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -327,11 +327,13 @@ int main(int argc, char **argv) if (!display) { perror("Cannot open display"); return 1; } app.backend = yasl_display_backend(display); app.tablet_supported = (yasl_display_caps(display) & YASL_CAP_TABLET) != 0; - struct yasl_surface_spec spec = {.title = "YASL Tablet - pressure and tilt", .size = {900, 640}}; + struct yasl_window_cbs callbacks = {.draw = draw, .configure = configure, .close = close_window}; + struct yasl_window_spec spec = { + .title = "YASL Tablet - pressure and tilt", .size = {900, 640}, + .cbs = &callbacks, .ud = &app, + }; struct yasl_surface *surface = yasl_surface_create_toplevel(display, &spec); if (!surface) { perror("Cannot create surface"); yasl_display_close(display); return 1; } - struct yasl_surface_cbs callbacks = {.draw = draw, .configure = configure, .close = close_window}; - yasl_surface_set_callbacks(surface, &callbacks, &app); yasl_surface_set_cursor(surface, YASL_CURSOR_HIDDEN); yasl_surface_schedule_redraw(surface); printf("YASL tablet on %s: pressure changes brush width; eraser removes ink.\n" -- cgit v1.2.3