From dd1775a9927922c14f8679ccbc4d3ca8d5917e20 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 21:23:03 +0300 Subject: public api refactor --- src/common/backend.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src/common/backend.h') diff --git a/src/common/backend.h b/src/common/backend.h index 13ce9b5..876a4ca 100644 --- a/src/common/backend.h +++ b/src/common/backend.h @@ -10,6 +10,7 @@ #include struct yasl_backend_ops; +struct yasl_event_state; struct yasl_display { const struct yasl_backend_ops *ops; @@ -19,6 +20,9 @@ struct yasl_display { void *app_runner; /* Backend's copy of yasl_display_spec.app_id, or NULL; for desktop services. */ const char *app_id; + void *callback_ud; + struct yasl_event_state *events; + struct yasl_surface *surfaces; }; struct yasl_surface { @@ -39,8 +43,41 @@ struct yasl_surface { int timer_count; int timer_capacity; void *app_surface; + struct yasl_surface *event_next; + uint64_t id; + void *userdata; + bool popup; + bool drawing; + bool frame_presented; + uint32_t reported_scale; + uint64_t draw_index; + struct yasl_frame *active_frame; + yasl_pacing_mode pacing; + yasl_timer_id pacing_timer; }; +bool yasl_events_open(struct yasl_display *d); +void yasl_events_close(struct yasl_display *d); +int yasl_events_error(struct yasl_display *d); +bool yasl_events_pending(struct yasl_display *d); +struct yasl_surface *yasl_events_find(struct yasl_display *d, uint64_t id); +bool yasl_events_register(struct yasl_surface *s); +void yasl_events_unregister(struct yasl_surface *s); +bool yasl_events_push(struct yasl_display *d, struct yasl_surface *queue_owner, + const struct yasl_event *event); +bool yasl_events_poll_surface(struct yasl_surface *s, struct yasl_event *event); +void yasl_surface_notify_configure(struct yasl_surface *s, struct yasl_geometry geometry); +void yasl_surface_notify_close(struct yasl_surface *s); +void yasl_surface_notify_state(struct yasl_surface *s, uint32_t state); +void yasl_surface_notify_drag(struct yasl_surface *s, enum yasl_drag_event ev, struct yasl_vector2i pos); +void yasl_surface_notify_drop(struct yasl_surface *s, enum yasl_drop_event ev, struct yasl_vector2i pos); +void yasl_surface_notify_composition(struct yasl_surface *s, const char *text, int begin, int end); +void yasl_surface_draw(struct yasl_surface *s, struct yasl_frame *frame); +void yasl_display_notify_event(struct yasl_display *d, enum yasl_event_type type); +void yasl_surface_complete_paste(struct yasl_surface *s, uint64_t request_id, + enum yasl_transfer_status status, const char *text, size_t len); +uint64_t yasl_events_request_id(struct yasl_display *d); + void yasl_surface_clear_timers(struct yasl_surface *s); struct yasl_surface *yasl_create_toplevel(struct yasl_display *d, const struct yasl_window_spec *spec, void *graphics_device); @@ -74,6 +111,9 @@ struct yasl_backend_ops { int (*display_double_click_ms)(const struct yasl_display *d); void (*display_copy)(struct yasl_display *d, enum yasl_selection sel, const char *text); void (*display_paste)(struct yasl_display *d, enum yasl_selection sel, struct yasl_surface *target); + bool (*display_copy_text)(struct yasl_display *d, enum yasl_selection sel, const char *text); + bool (*display_request_paste)(struct yasl_display *d, enum yasl_selection sel, + struct yasl_surface *target, uint64_t request_id); bool (*display_drag_start)(struct yasl_display *d, struct yasl_surface *origin, const struct yasl_drag_image *image, const struct yasl_drag_listener *l, void *ud); void (*display_drag_cancel)(struct yasl_display *d); /* Create with callbacks disabled; common code installs them after return. */ @@ -82,6 +122,11 @@ struct yasl_backend_ops { struct yasl_surface *(*surface_create_popup)(struct yasl_surface *parent, const struct yasl_popup_spec *spec); bool (*surface_popup_reposition)(struct yasl_surface *popup, const struct yasl_popup_spec *spec); void (*surface_destroy)(struct yasl_surface *s); + struct input_queue *(*surface_input_queue)(struct yasl_surface *s); + bool (*surface_set_size)(struct yasl_surface *s, struct yasl_vector2i size_logical); + bool (*surface_set_fullscreen)(struct yasl_surface *s, bool enabled); + bool (*surface_set_maximized)(struct yasl_surface *s, bool enabled); + bool (*surface_minimize)(struct yasl_surface *s); struct yasl_display *(*surface_display)(const struct yasl_surface *s); /* Copy only; must not invoke application callbacks. */ void (*surface_set_callbacks)(struct yasl_surface *s, const struct yasl_window_cbs *cbs, void *ud); -- cgit v1.2.3