summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-11 23:27:41 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-11 23:27:41 +0300
commit472ed3e4e50a165638acecaf071ec3c2c13c451f (patch)
treed1894debde800d8e87d3c242ae6c3f4760c68787 /README.md
parent8d9f7c7cb39359d62bf28ef1775b944a7dddd6fb (diff)
core: optimize struct layouts, eliminate branches, and fix event loop dispatch
- Fix Wayland event loop lockout by properly decoupling read arming and adding poll-backed dispatching - Support standalone display lifecycle without requiring caller to manage a loop - Eliminate alignment holes across yasl_surface, yasl_display, seat, touch_point, and conn_drag using pahole - Replace branching state/button decoders with compile-time locked LUTs and branchless bitwise operations - Accelerate UTF-8 validation with 64-bit word scanning for ASCII runs
Diffstat (limited to 'README.md')
-rw-r--r--README.md27
1 files changed, 22 insertions, 5 deletions
diff --git a/README.md b/README.md
index 23f4811..ee061b9 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,8 @@ ninja -C build test
```c
#include <yasl/yasl.h>
+static bool running = true;
+
static void on_draw(struct yasl_surface *s, struct yasl_frame *frame, void *ud)
{
/* Present frame target */
@@ -46,29 +48,44 @@ static void on_draw(struct yasl_surface *s, struct yasl_frame *frame, void *ud)
yasl_surface_present(s, &frame->target, &dmg);
}
+static void on_close(struct yasl_surface *s, void *ud)
+{
+ (void)s; (void)ud;
+ running = false;
+}
+
int main(void)
{
- struct yasl_loop *loop = yasl_loop_create();
struct yasl_display_spec dspec = { .app_id = "org.example.app" };
- struct yasl_display *d = yasl_display_open(loop, &dspec);
+ struct yasl_display *d = yasl_display_open(NULL, &dspec);
struct yasl_surface_spec sspec = {
.title = "YASL Application",
.size = { .x = 800, .y = 600 },
};
struct yasl_surface *s = yasl_surface_create_toplevel(d, &sspec);
- struct yasl_surface_cbs cbs = { .draw = on_draw };
+ struct yasl_surface_cbs cbs = {
+ .draw = on_draw,
+ .close = on_close,
+ };
yasl_surface_set_callbacks(s, &cbs, NULL);
yasl_surface_schedule_redraw(s);
- while (true) {
+ while (running) {
yasl_display_dispatch(d);
struct yasl_input_event ev;
while (yasl_surface_input_poll(s, &ev)) {
- /* Handle input */
+ if (ev.kind == YASL_INPUT_KEY && ev.key.action == YASL_KEY_PRESS) {
+ if (ev.key.key == 0xff1b) /* Escape */
+ running = false;
+ }
}
yasl_display_flush(d);
}
+
+ yasl_surface_destroy(s);
+ yasl_display_close(d);
+ return 0;
}
```