AtlatestRepositorysigil-ui
1
/* Trusted native-adapter API. No AppKit pointers cross the Sigil window API.2
* Every function and callback runs synchronously on the main thread. Callbacks3
* must not suspend, block, navigate or enter a script engine. Tokens are scoped4
* to this process and never reused; stale tokens fail without touching AppKit.5
*/6
#ifndef SIGIL_UI_APPKIT_HOST_H7
#define SIGIL_UI_APPKIT_HOST_H8
#include <stdbool.h>9
#include <stdint.h>10
#ifdef __cplusplus11
extern "C" {12
#endif14
typedef uint64_t SUIHostToken;15
typedef uint64_t SUIChildToken;16
typedef uint64_t SUIHookToken;18
typedef struct {19
double x, y, width, height; /* Logical top-left child allocation. */20
double content_width, content_height;21
int scale;22
bool visible, focused;23
} SUIGeometry;25
typedef enum {26
SUI_HOST_GEOMETRY, SUI_HOST_FOCUS, SUI_HOST_DEACTIVATED,27
SUI_CHILD_WILL_DETACH, SUI_HOST_WILL_CLOSE28
} SUIHostEvent;29
typedef void (*SUIHostNotify)(void *context, SUIHostToken host,30
SUIChildToken child, SUIHostEvent event, const SUIGeometry *geometry);32
typedef struct {33
int action; /* 0 release, 1 press, 2 repeat. */34
uint16_t hardware_code;35
uint32_t modifiers; /* shift=1 control=2 alt=4 super=8 caps=16 num=32 */36
SUIChildToken target; /* Zero means the sigil-ui canvas. */37
const char *name, *text; /* Copied data, valid only during this callback. */38
} SUIKey;39
typedef bool (*SUIKeyFilter)(void *context, SUIHostToken host, const SUIKey *key);41
bool sigil_ui_appkit_host_valid(SUIHostToken host);42
bool sigil_ui_appkit_host_geometry(SUIHostToken host, SUIGeometry *geometry);43
/* native_view is an unparented NSView*, bridged by the trusted adapter. The44
* host retains it until detach; the adapter keeps its own ownership. Higher45
* order values draw above lower values, below the canvas overlay. */46
SUIChildToken sigil_ui_appkit_child_adopt(SUIHostToken host, void *native_view,47
double x, double y, double width, double height, int order,48
SUIHostNotify notify, void *context);49
bool sigil_ui_appkit_child_place(SUIHostToken host, SUIChildToken child,50
double x, double y, double width, double height, int order);51
bool sigil_ui_appkit_child_remove(SUIHostToken host, SUIChildToken child);52
bool sigil_ui_appkit_focus_child(SUIHostToken host, SUIChildToken child);53
bool sigil_ui_appkit_focus_ui(SUIHostToken host);54
/* Filters run newest first on a press; consume/pass and target stick through55
* its repeats/release. A passed child event follows native dispatch once.56
* Removing a filter or changing focus cancels its pending key ownership. */57
SUIHookToken sigil_ui_appkit_key_filter_add(SUIHostToken host,58
SUIKeyFilter filter, void *context);59
bool sigil_ui_appkit_key_filter_remove(SUIHostToken host, SUIHookToken hook);60
#ifdef __cplusplus61
}62
#endif63
#endif