diff options
Diffstat (limited to 'include/yasl/yasl.h')
| -rw-r--r-- | include/yasl/yasl.h | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/include/yasl/yasl.h b/include/yasl/yasl.h index f40264e..e2c1d77 100644 --- a/include/yasl/yasl.h +++ b/include/yasl/yasl.h @@ -437,10 +437,11 @@ struct yasl_display_cbs { void (*lost)(void *ud); }; -/** Optional surface notifications, copied by yasl_surface_set_callbacks(). +/** Optional window/popup notifications, copied from yasl_window_spec.cbs or by +yasl_surface_set_callbacks(). Callbacks may destroy their surface. They must then return without further use of the surface or draw target. NULL members are ignored. */ -struct yasl_surface_cbs { +struct yasl_window_cbs { /** Initialize the entire target and optionally present. Requested through schedule_redraw/flush. */ void (*draw)(struct yasl_surface *s, struct yasl_frame *frame, void *ud); /** Configured size/scale changed; reallocate application content and request a redraw. */ @@ -586,7 +587,7 @@ YASL_API void yasl_display_drag_cancel(struct yasl_display *d); /* Surface Lifecycle */ /** Toplevel options. Zero-initialize, then supply a positive logical-pixel size. */ -struct yasl_surface_spec { +struct yasl_window_spec { /** Copied UTF-8 title; NULL uses backend defaults. */ const char *title; /** Requested logical-pixel width and height; both must be positive. */ @@ -595,6 +596,10 @@ struct yasl_surface_spec { bool fullscreen; /** Permit unpaced presentation where supported; a hint, not a guarantee. */ bool tearing; + /** Copied optional window callbacks; NULL disables them. */ + const struct yasl_window_cbs *cbs; + /** Borrowed window callback userdata. */ + void *ud; }; /** Popup options, entirely in device pixels, including size. @@ -623,10 +628,16 @@ struct yasl_popup_spec { * @return An owned surface, or NULL with errno set. EINVAL means invalid options, * including a nonpositive dimension, a dimension above 32767, or a buffer above * INT32_MAX bytes. ENODEV is the fallback backend failure. Actual configured - * size may differ from the request. Install callbacks and schedule a redraw. + * size may differ from the request. The callback table in spec->cbs is copied; + * spec->ud stays borrowed until callbacks are replaced or the surface is destroyed. + * This window's callbacks cannot run before creation returns. Use + * yasl_surface_geometry() for initial geometry; an initial configure callback + * is not guaranteed. Schedule an initial redraw after setting up application state. + * On a display owned by yasl_run(), the runner installs its own callbacks instead; + * use yasl_app_desc.event and yasl_app_desc.frame for application notifications. */ YASL_API struct yasl_surface *yasl_surface_create_toplevel(struct yasl_display *d, - const struct yasl_surface_spec *spec); + const struct yasl_window_spec *spec); /** * Create an owned popup attached to a parent surface. * @param parent Borrowed parent; destroy the popup before the parent. @@ -668,12 +679,12 @@ YASL_API struct yasl_display *yasl_surface_display(const struct yasl_surface *s) * @param s Surface, or NULL for no action. * @param cbs Table copied by value; NULL removes all callbacks. NULL members are ignored. * @param ud Borrowed userdata passed to the installed callbacks. - * Callbacks may run synchronously during this call; initialize userdata first. + * This call only replaces callbacks; it does not invoke them. * Use yasl_surface_geometry() to read current geometry; do not rely on receiving * an initial configure callback when registering. */ YASL_API void yasl_surface_set_callbacks(struct yasl_surface *s, - const struct yasl_surface_cbs *cbs, void *ud); + const struct yasl_window_cbs *cbs, void *ud); /** * Replace the window title with copied UTF-8 text. * @param s Surface. |
