diff options
Diffstat (limited to 'examples/tablet.c')
| -rw-r--r-- | examples/tablet.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/examples/tablet.c b/examples/tablet.c index 01dcdfc..ba1a94f 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -148,7 +148,7 @@ static enum yasl_app_result input(void *ud, const struct yasl_event *event) if (event->type == YASL_EVENT_WINDOW_RESIZE) { if (!resize_canvas(app, event->resize.geometry)) { app->failed = true; - return YASL_APP_QUIT; + return YASL_APP_ERROR; } } else if (event->type == YASL_EVENT_INPUT_RESET || event->type == YASL_EVENT_POINTER_LEAVE || (event->type == YASL_EVENT_FOCUS && !event->focus.focused)) { @@ -233,18 +233,19 @@ static void text(struct yasl_framebuffer *fb, double dpi, int x, int y, } } -static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_context *frame) +static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame *frame) { struct app *app = ud; - struct yasl_geometry geometry = {frame->size, frame->scale_120}; + struct yasl_geometry geometry = {frame->target.size, frame->scale_120}; if (!resize_canvas(app, geometry)) { fprintf(stderr, "Cannot allocate drawing canvas\n"); app->failed = true; + yasl_app_exit(yasl_surface_display(surface), YASL_APP_ERROR); yasl_surface_destroy(surface); app->surface = NULL; return; } - struct yasl_framebuffer target = {.size = frame->size, .pixels = frame->cpu.pixels}; + struct yasl_framebuffer target = {.size = frame->target.size, .pixels = frame->target.pixels}; struct yasl_framebuffer *fb = ⌖ memcpy(fb->pixels, app->canvas, (size_t)geometry.size.x * geometry.size.y * sizeof(uint32_t)); double dpi = (double)app->geometry.scale_120 / YASL_SCALE_UNIT; @@ -280,9 +281,10 @@ static void draw(void *ud, struct yasl_surface *surface, struct yasl_frame_conte for (int i = 0; i <= 64; i++) rect(fb, (int)lround(cx + tx * i / 64), (int)lround(cy + ty * i / 64), 2, 2, ACCENT); } - if (!yasl_frame_present_cpu(frame, NULL, 0)) { + if (!yasl_frame_present(frame, NULL, 0)) { app->failed = true; } + if (app->failed) yasl_app_exit(yasl_surface_display(surface), YASL_APP_ERROR); if (app->failed || app->smoke_test) { yasl_surface_destroy(surface); app->surface = NULL; @@ -295,13 +297,13 @@ static enum yasl_app_result init(void *ud, struct yasl_display *display) app->backend = yasl_display_backend(display); app->tablet_supported = (yasl_display_caps(display) & YASL_CAP_TABLET) != 0; struct yasl_window_spec spec = { - .title = "YASL Tablet - pressure and tilt", .size = {900, 640}, + .title = "YASL Tablet - pressure and tilt", .size_logical = {900, 640}, }; app->surface = yasl_surface_create_toplevel(display, &spec); if (!app->surface || !resize_canvas(app, yasl_surface_geometry(app->surface))) { fprintf(stderr, "Cannot create drawing surface\n"); app->failed = true; - return YASL_APP_QUIT; + return YASL_APP_ERROR; } yasl_surface_set_cursor(app->surface, YASL_CURSOR_HIDDEN); yasl_surface_request_frame(app->surface); |
