summaryrefslogtreecommitdiff
path: root/examples/notepad.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/notepad.c')
-rw-r--r--examples/notepad.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/examples/notepad.c b/examples/notepad.c
index 9134653..ff12038 100644
--- a/examples/notepad.c
+++ b/examples/notepad.c
@@ -576,7 +576,7 @@ static void editor_copy(struct editor *ed)
snprintf(buf, (size_t)MAX_LINES * MAX_LINE_LEN, "%s\n", ed->lines[ed->cursor_row]);
}
- if (!yasl_clipboard_set(YASL_CLIPBOARD, buf))
+ if ((yasl_clipboard_set(YASL_CLIPBOARD, buf) < 0))
editor_set_status(ed, "Clipboard copy failed");
free(buf);
editor_set_status(ed, "Copied to clipboard");
@@ -988,7 +988,7 @@ static void prompt_execute(struct editor *ed)
static bool editor_init(struct editor *ed)
{
- ed->surface = yasl_surface_create("Untitled - YASL Notepad", 960, 640, YASL_SURFACE_CPU);
+ ed->surface = yasl_surface_create(&(struct yasl_surface_options){.title="Untitled - YASL Notepad", .width=960, .height=640, .type=YASL_SURFACE_CPU, .flags=0});
if (!ed->surface) return false;
ed->surface_scale = yasl_surface_get_scale(ed->surface);
yasl_surface_set_text_input(ed->surface, true, YASL_TEXT_NORMAL);
@@ -1483,8 +1483,10 @@ static void on_event(struct editor *ed, const yasl_event *ev)
static void editor_render(struct editor *ed)
{
- int w, h;
- uint32_t *pix = yasl_cpu_pixels(ed->surface, &w, &h);
+ struct yasl_cpu_buffer buffer;
+ int acquired = yasl_cpu_acquire(ed->surface, &buffer);
+ int w = buffer.width, h = buffer.height;
+ uint32_t *pix = acquired == 0 ? buffer.pixels : NULL;
if (!pix) return;
double display_scale = yasl_surface_get_scale(ed->surface);
@@ -1624,7 +1626,7 @@ static void editor_render(struct editor *ed)
ed->is_modified ? 0xfffab387 : status_accent, scale);
}
- if (!yasl_cpu_present(ed->surface)) {
+ if ((yasl_cpu_present(ed->surface, &buffer) < 0)) {
fprintf(stderr, "Could not present CPU image\n");
ed->failed = true;
ed->running = false;
@@ -1697,7 +1699,7 @@ int main(int argc, char **argv)
}
}
- if (!yasl_set_app_id("org.yasl.notepad") || !editor_init(&ed)) {
+ if ((yasl_init(&(struct yasl_options){.app_id="org.yasl.notepad"}) < 0) || !editor_init(&ed)) {
fprintf(stderr, "Could not initialize YASL Notepad\n");
editor_shutdown(&ed);
yasl_shutdown();