Skip to content

Commit

Permalink
Move everything to [main-thread] except is_open(), add clap.gui
Browse files Browse the repository at this point in the history
… API constant
  • Loading branch information
geraintluff committed Nov 24, 2024
1 parent 2d3a4e7 commit 96daf34
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions include/clap/ext/draft/webview.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

static CLAP_CONSTEXPR const char CLAP_EXT_WEBVIEW[] = "clap.webview/1";

// clap.gui API constant. The pointer in clap_window must be NULL, but sizing methods are useful.
// uses logical size, don't call clap_plugin_gui->set_scale()
static const CLAP_CONSTEXPR char CLAP_WINDOW_API_WEBVIEW[] = "webview";

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -17,33 +21,35 @@ extern "C" {

typedef struct clap_plugin_webview {
// Returns the URL for the webview's initial navigation, as a null-terminated UTF-8 string.
// This must be called at least once before any messages are sent (or accepted by the host).
// If this URL is relative, it is resolved relative to the plugin (bundle) resource directory.
// The host may assume that no resources outside of that directory are used, and may use any
// protocol to provide this content, following HTTP-like relative URL resolution. The page must
// not assume that the root path of the domain is the root of the bundle. The URL may also be
// absolute, including a `file://` URL.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *get_start)(const clap_plugin_t *plugin,
bool(CLAP_ABI *provide_starting_uri)(const clap_plugin_t *plugin,
char *out_buffer,
uint32_t out_buffer_capacity);

// Receives a single message from the webview.
// Receives a single message from the webview, which must be open and ready to receive replies.
// Returns true on success.
// [main-thread]
bool(CLAP_ABI *receive)(const clap_plugin_t *plugin, const void *buffer, uint32_t size);

} clap_plugin_webview_t;

typedef struct clap_host_webview {
// Checks whether the webview is open (and ready to receive messages)
// Checks whether the webview is open and likely to receive messages.
// This may be called at any time and is a hint for non-essential work, such as being able to
// skip metering calculations.
// [thread-safe]
bool(CLAP_ABI *is_open)(const clap_host_t *host);

// Sends a single message to the webview.
// It must not allocate or block if called from the audio thread.
// Returns true on success.
// [thread-safe]
// Returns true on success. It must fail (false) if the webview is not open.
// [main-thread]
bool(CLAP_ABI *send)(const clap_host_t *host, const void *buffer, uint32_t size);

} clap_host_webview_t;
Expand Down

0 comments on commit 96daf34

Please sign in to comment.