@native-sdk/cli 0.9.1 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/app.zig +26 -9
- package/build.zig +124 -1
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.ts +3 -1
- package/packages/core/sdk/events.d.ts +7 -0
- package/packages/core/sdk/events.ts +26 -5
- package/packages/core/sdk/text.d.ts +4 -0
- package/packages/core/sdk/text.ts +51 -0
- package/packages/core/src/checker.ts +58 -1
- package/packages/core/src/contract.ts +5 -4
- package/packages/core/src/devhost_journal.mjs +2 -2
- package/packages/core/src/diagnostics.ts +2 -2
- package/packages/core/src/service_contract.ts +10 -0
- package/packages/core/src/typed_ast.ts +9 -7
- package/packages/core/src/types.ts +28 -8
- package/skill-data/automation/SKILL.md +4 -3
- package/skill-data/native-ui/SKILL.md +10 -8
- package/skill-data/ts-core/SKILL.md +8 -5
- package/src/app_runner/root.zig +301 -12
- package/src/app_runner/ts_core_main.zig +6 -4
- package/src/app_runner/window_placement.zig +63 -0
- package/src/automation/protocol.zig +5 -1
- package/src/automation/snapshot.zig +119 -0
- package/src/embed/app_exports.zig +2 -1
- package/src/embed/conversions.zig +1 -0
- package/src/embed/host.zig +10 -3
- package/src/embed/root.zig +1 -0
- package/src/embed/tests.zig +13 -1
- package/src/embed/types.zig +2 -0
- package/src/embed/ui_host.zig +26 -2
- package/src/platform/android/NativeSdkActivity.java +49 -4
- package/src/platform/android/android_host.c +3 -3
- package/src/platform/android/native_sdk_app.h +1 -1
- package/src/platform/ios/apple_image_fit.h +38 -0
- package/src/platform/ios/files.zig +1 -0
- package/src/platform/ios/native_sdk_app.h +1 -1
- package/src/platform/ios/uikit_host.m +28 -5
- package/src/platform/linux/cef_host.cpp +10 -2
- package/src/platform/linux/gtk_host.c +43 -10
- package/src/platform/linux/gtk_host.h +3 -3
- package/src/platform/linux/root.zig +22 -7
- package/src/platform/macos/appkit_host.h +7 -4
- package/src/platform/macos/appkit_host.m +271 -52
- package/src/platform/macos/cef_host.mm +132 -34
- package/src/platform/macos/image_fit_test.m +44 -0
- package/src/platform/macos/root.zig +222 -14
- package/src/platform/null_platform.zig +17 -3
- package/src/platform/null_platform_tests.zig +58 -4
- package/src/platform/root.zig +2 -0
- package/src/platform/types.zig +69 -19
- package/src/platform/windows/root.zig +22 -7
- package/src/platform/windows/webview2_host.cpp +31 -6
- package/src/primitives/app_manifest/root.zig +3 -0
- package/src/primitives/app_manifest/tests.zig +24 -0
- package/src/primitives/app_manifest/types.zig +13 -0
- package/src/primitives/app_manifest/validation.zig +24 -0
- package/src/primitives/canvas/a11y_audit.zig +9 -7
- package/src/primitives/canvas/a11y_audit_tests.zig +24 -0
- package/src/primitives/canvas/events.zig +129 -1
- package/src/primitives/canvas/layout_audit.zig +6 -6
- package/src/primitives/canvas/markdown.zig +4 -0
- package/src/primitives/canvas/markdown_tests.zig +1 -0
- package/src/primitives/canvas/png.zig +138 -0
- package/src/primitives/canvas/root.zig +14 -2
- package/src/primitives/canvas/text_interaction.zig +23 -0
- package/src/primitives/canvas/text_span_tests.zig +5 -3
- package/src/primitives/canvas/text_spans.zig +2 -0
- package/src/primitives/canvas/text_tests.zig +65 -0
- package/src/primitives/canvas/ui.zig +66 -10
- package/src/primitives/canvas/ui_markup.zig +40 -13
- package/src/primitives/canvas/ui_markup_binary.zig +8 -6
- package/src/primitives/canvas/ui_markup_binary_tests.zig +14 -4
- package/src/primitives/canvas/ui_markup_compiled.zig +5 -1
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +55 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +6 -5
- package/src/primitives/canvas/ui_markup_tests.zig +11 -2
- package/src/primitives/canvas/ui_markup_view.zig +8 -2
- package/src/primitives/canvas/ui_markup_view_tests.zig +67 -6
- package/src/primitives/canvas/ui_schema.zig +17 -13
- package/src/primitives/canvas/ui_tests.zig +84 -0
- package/src/primitives/canvas/widget_access.zig +3 -3
- package/src/primitives/canvas/widget_anchored_tests.zig +106 -0
- package/src/primitives/canvas/widget_builtin_tests.zig +593 -32
- package/src/primitives/canvas/widget_invalidation.zig +33 -6
- package/src/primitives/canvas/widget_layout.zig +333 -126
- package/src/primitives/canvas/widget_layout_tests.zig +169 -0
- package/src/primitives/canvas/widget_metrics.zig +7 -8
- package/src/primitives/canvas/widget_render.zig +76 -44
- package/src/primitives/canvas/widget_render_controls.zig +110 -32
- package/src/primitives/canvas/widget_render_style.zig +58 -18
- package/src/primitives/canvas/widget_render_surfaces.zig +45 -14
- package/src/primitives/canvas/widget_routing.zig +40 -34
- package/src/primitives/canvas/widget_runtime.zig +11 -2
- package/src/primitives/canvas/widget_runtime_tests.zig +10 -14
- package/src/primitives/canvas/widget_semantics.zig +8 -3
- package/src/primitives/canvas/widget_semantics_tests.zig +6 -2
- package/src/primitives/canvas/widget_tree.zig +99 -5
- package/src/primitives/canvas/widgets.zig +20 -7
- package/src/root.zig +3 -0
- package/src/runtime/api.zig +6 -0
- package/src/runtime/automation_snapshot.zig +4 -0
- package/src/runtime/automation_widget_dispatch.zig +48 -6
- package/src/runtime/builtin_bridge.zig +5 -2
- package/src/runtime/canvas_frame_packet_tests.zig +22 -13
- package/src/runtime/canvas_image_tests.zig +146 -2
- package/src/runtime/canvas_images.zig +35 -16
- package/src/runtime/canvas_limits.zig +13 -3
- package/src/runtime/canvas_widget_accessibility_tests.zig +279 -4
- package/src/runtime/canvas_widget_anchored_tests.zig +54 -0
- package/src/runtime/canvas_widget_control_tests.zig +33 -1
- package/src/runtime/canvas_widget_events.zig +151 -26
- package/src/runtime/canvas_widget_floating_tests.zig +48 -0
- package/src/runtime/canvas_widget_runtime.zig +322 -102
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +34 -0
- package/src/runtime/canvas_widget_scroll_drivers.zig +12 -10
- package/src/runtime/canvas_widget_scroll_tests.zig +193 -2
- package/src/runtime/canvas_widget_semantics_tests.zig +337 -3
- package/src/runtime/canvas_widget_split_tree_tests.zig +55 -0
- package/src/runtime/canvas_widget_state.zig +33 -7
- package/src/runtime/canvas_widget_text_tests.zig +124 -0
- package/src/runtime/core.zig +16 -0
- package/src/runtime/effects.zig +14 -14
- package/src/runtime/effects_image_tests.zig +91 -0
- package/src/runtime/gpu_surface_events.zig +25 -2
- package/src/runtime/native_command_event_tests.zig +29 -0
- package/src/runtime/root.zig +2 -0
- package/src/runtime/session_journal.zig +21 -2
- package/src/runtime/session_replay.zig +13 -8
- package/src/runtime/session_tests.zig +111 -4
- package/src/runtime/shell_layout_tests.zig +12 -0
- package/src/runtime/ts_core_host_tests.zig +47 -0
- package/src/runtime/ts_ui_app.zig +164 -1
- package/src/runtime/ui_app.zig +100 -21
- package/src/runtime/ui_app_tests.zig +351 -32
- package/src/runtime/ui_app_window_tests.zig +13 -1
- package/src/runtime/view.zig +3 -0
- package/src/runtime/view_widget_control.zig +18 -0
- package/src/runtime/view_widget_scroll.zig +112 -18
- package/src/runtime/view_widget_text.zig +1 -1
- package/src/runtime/view_widget_tree.zig +110 -13
- package/src/runtime/widget_bridge.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +86 -0
- package/src/runtime/window_storage.zig +16 -1
- package/src/runtime/window_views.zig +1 -0
- package/src/tooling/ios.zig +3 -0
- package/src/tooling/manifest.zig +90 -2
- package/src/tooling/package.zig +67 -2
- package/src/tooling/raw_manifest.zig +10 -0
- package/src/tooling/templates.zig +128 -18
- package/src/tooling/verbs.zig +1 -0
- package/src/tooling/web_engine.zig +1 -1
- package/tools/corewire/emit.zig +31 -12
- package/tools/corewire/emit_facade.zig +57 -2
- package/tools/corewire/shim_rt.zig +20 -0
|
@@ -408,6 +408,8 @@ struct native_sdk_gtk_host {
|
|
|
408
408
|
char *window_label;
|
|
409
409
|
double init_x, init_y, init_width, init_height;
|
|
410
410
|
int restore_frame;
|
|
411
|
+
int initial_placement;
|
|
412
|
+
int restore_policy;
|
|
411
413
|
/* Startup-window options applied when on_activate creates @w1 (the
|
|
412
414
|
* window does not exist yet when the host is created). */
|
|
413
415
|
int init_resizable;
|
|
@@ -3108,7 +3110,7 @@ static void native_sdk_ensure_transparent_css(native_sdk_gtk_host_t *host) {
|
|
|
3108
3110
|
host->transparent_css_provider = provider;
|
|
3109
3111
|
}
|
|
3110
3112
|
|
|
3111
|
-
static native_sdk_gtk_window_t *native_sdk_create_window_internal(native_sdk_gtk_host_t *host, uint64_t window_id, const char *title, const char *label, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
3113
|
+
static native_sdk_gtk_window_t *native_sdk_create_window_internal(native_sdk_gtk_host_t *host, uint64_t window_id, const char *title, const char *label, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
3112
3114
|
if (native_sdk_find_window(host, window_id)) return NULL;
|
|
3113
3115
|
|
|
3114
3116
|
int slot = -1;
|
|
@@ -3127,8 +3129,10 @@ static native_sdk_gtk_window_t *native_sdk_create_window_internal(native_sdk_gtk
|
|
|
3127
3129
|
memset(win, 0, sizeof(*win));
|
|
3128
3130
|
win->id = window_id;
|
|
3129
3131
|
win->host = host;
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
+
(void)restore_frame;
|
|
3133
|
+
(void)restore_policy;
|
|
3134
|
+
win->x = initial_placement != 2 ? x : 0;
|
|
3135
|
+
win->y = initial_placement != 2 ? y : 0;
|
|
3132
3136
|
win->label = native_sdk_strndup(label && label[0] ? label : "main", strlen(label && label[0] ? label : "main"));
|
|
3133
3137
|
win->title = native_sdk_strndup(title && title[0] ? title : host->app_name, strlen(title && title[0] ? title : host->app_name));
|
|
3134
3138
|
win->transparent = (window_flags & (1u << 0)) != 0;
|
|
@@ -3257,7 +3261,8 @@ static void on_activate(GtkApplication *app, gpointer data) {
|
|
|
3257
3261
|
host->init_x, host->init_y,
|
|
3258
3262
|
host->init_width > 0 ? host->init_width : 720,
|
|
3259
3263
|
host->init_height > 0 ? host->init_height : 480,
|
|
3260
|
-
host->restore_frame, host->
|
|
3264
|
+
host->restore_frame, host->initial_placement, host->restore_policy,
|
|
3265
|
+
host->init_resizable, host->init_titlebar_style,
|
|
3261
3266
|
host->init_min_width, host->init_min_height,
|
|
3262
3267
|
host->init_show_policy, host->init_window_flags);
|
|
3263
3268
|
if (!win) return;
|
|
@@ -3281,7 +3286,8 @@ native_sdk_gtk_host_t *native_sdk_gtk_create(
|
|
|
3281
3286
|
const char *icon_path, size_t icon_path_len,
|
|
3282
3287
|
const char *window_label, size_t window_label_len,
|
|
3283
3288
|
double x, double y, double width, double height,
|
|
3284
|
-
int restore_frame, int
|
|
3289
|
+
int restore_frame, int initial_placement, int restore_policy,
|
|
3290
|
+
int resizable, int titlebar_style,
|
|
3285
3291
|
double min_width, double min_height, int show_policy,
|
|
3286
3292
|
uint32_t window_flags)
|
|
3287
3293
|
{
|
|
@@ -3298,6 +3304,8 @@ native_sdk_gtk_host_t *native_sdk_gtk_create(
|
|
|
3298
3304
|
host->init_width = width;
|
|
3299
3305
|
host->init_height = height;
|
|
3300
3306
|
host->restore_frame = restore_frame;
|
|
3307
|
+
host->initial_placement = initial_placement;
|
|
3308
|
+
host->restore_policy = restore_policy;
|
|
3301
3309
|
host->init_resizable = resizable;
|
|
3302
3310
|
host->init_titlebar_style = titlebar_style;
|
|
3303
3311
|
host->init_min_width = min_width;
|
|
@@ -3475,13 +3483,38 @@ void native_sdk_gtk_request_frame(native_sdk_gtk_host_t *host) {
|
|
|
3475
3483
|
* codec its loaders ship — the framework bundles none. Decoded rows are
|
|
3476
3484
|
* repacked tightly (gdk-pixbuf rowstride may pad) as straight-alpha RGBA8,
|
|
3477
3485
|
* the layout the canvas image pipeline expects. */
|
|
3478
|
-
|
|
3486
|
+
typedef struct {
|
|
3487
|
+
size_t max_pixels;
|
|
3488
|
+
} native_sdk_image_fit_t;
|
|
3489
|
+
|
|
3490
|
+
#define NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION 8192
|
|
3491
|
+
|
|
3492
|
+
static void native_sdk_gtk_image_size_prepared(GdkPixbufLoader *loader, int width, int height, gpointer user_data) {
|
|
3493
|
+
native_sdk_image_fit_t *fit = user_data;
|
|
3494
|
+
if (!fit || fit->max_pixels == 0 || width <= 0 || height <= 0) return;
|
|
3495
|
+
double source_pixels = (double)width * (double)height;
|
|
3496
|
+
if (source_pixels <= (double)fit->max_pixels && width <= NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION && height <= NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION) return;
|
|
3497
|
+
double area_scale = sqrt((double)fit->max_pixels / source_pixels);
|
|
3498
|
+
double axis_scale = (double)NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION / (double)MAX(width, height);
|
|
3499
|
+
double scale = MIN(1.0, MIN(area_scale, axis_scale));
|
|
3500
|
+
int fitted_width = MAX(1, (int)floor((double)width * scale));
|
|
3501
|
+
int fitted_height = MAX(1, (int)floor((double)height * scale));
|
|
3502
|
+
while ((size_t)fitted_width * (size_t)fitted_height > fit->max_pixels) {
|
|
3503
|
+
if (fitted_width > 1 && (fitted_height == 1 || fitted_width > fitted_height)) fitted_width -= 1;
|
|
3504
|
+
else fitted_height -= 1;
|
|
3505
|
+
}
|
|
3506
|
+
gdk_pixbuf_loader_set_size(loader, fitted_width, fitted_height);
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
int native_sdk_gtk_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t max_pixels, size_t *out_width, size_t *out_height) {
|
|
3479
3510
|
if (out_width) *out_width = 0;
|
|
3480
3511
|
if (out_height) *out_height = 0;
|
|
3481
|
-
if (!bytes || bytes_len == 0 || !pixels) return 0;
|
|
3512
|
+
if (!bytes || bytes_len == 0 || !pixels || max_pixels == 0) return 0;
|
|
3482
3513
|
|
|
3483
3514
|
GdkPixbufLoader *loader = gdk_pixbuf_loader_new();
|
|
3484
3515
|
if (!loader) return 0;
|
|
3516
|
+
native_sdk_image_fit_t fit = { .max_pixels = max_pixels };
|
|
3517
|
+
g_signal_connect(loader, "size-prepared", G_CALLBACK(native_sdk_gtk_image_size_prepared), &fit);
|
|
3485
3518
|
gboolean ok = gdk_pixbuf_loader_write(loader, bytes, bytes_len, NULL);
|
|
3486
3519
|
ok = gdk_pixbuf_loader_close(loader, NULL) && ok;
|
|
3487
3520
|
GdkPixbuf *decoded = ok ? gdk_pixbuf_loader_get_pixbuf(loader) : NULL;
|
|
@@ -3503,7 +3536,7 @@ int native_sdk_gtk_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t
|
|
|
3503
3536
|
|
|
3504
3537
|
int width_px = gdk_pixbuf_get_width(rgba);
|
|
3505
3538
|
int height_px = gdk_pixbuf_get_height(rgba);
|
|
3506
|
-
if (width_px <= 0 || height_px <= 0 || width_px >
|
|
3539
|
+
if (width_px <= 0 || height_px <= 0 || width_px > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION || height_px > NATIVE_SDK_MAX_DECODED_IMAGE_DIMENSION) {
|
|
3507
3540
|
g_object_unref(rgba);
|
|
3508
3541
|
g_object_unref(loader);
|
|
3509
3542
|
return 0;
|
|
@@ -3838,10 +3871,10 @@ void native_sdk_gtk_set_shortcuts(native_sdk_gtk_host_t *host, const char *const
|
|
|
3838
3871
|
}
|
|
3839
3872
|
}
|
|
3840
3873
|
|
|
3841
|
-
int native_sdk_gtk_create_window(native_sdk_gtk_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
3874
|
+
int native_sdk_gtk_create_window(native_sdk_gtk_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags) {
|
|
3842
3875
|
char *title = window_title_len > 0 ? native_sdk_strndup(window_title, window_title_len) : NULL;
|
|
3843
3876
|
char *label = window_label_len > 0 ? native_sdk_strndup(window_label, window_label_len) : NULL;
|
|
3844
|
-
native_sdk_gtk_window_t *win = native_sdk_create_window_internal(host, window_id, title, label, x, y, width, height, restore_frame, resizable, titlebar_style, min_width, min_height, show_policy, window_flags);
|
|
3877
|
+
native_sdk_gtk_window_t *win = native_sdk_create_window_internal(host, window_id, title, label, x, y, width, height, restore_frame, initial_placement, restore_policy, resizable, titlebar_style, min_width, min_height, show_policy, window_flags);
|
|
3845
3878
|
free(title);
|
|
3846
3879
|
free(label);
|
|
3847
3880
|
if (!win) return 0;
|
|
@@ -162,7 +162,7 @@ typedef struct {
|
|
|
162
162
|
* window with client-side decorations — a header bar carrying the
|
|
163
163
|
* desktop-themed window controls and system drag behavior, no title
|
|
164
164
|
* text); min_width/min_height <= 0 leave that axis unfloored. */
|
|
165
|
-
native_sdk_gtk_host_t *native_sdk_gtk_create(const char *app_name, size_t app_name_len, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags);
|
|
165
|
+
native_sdk_gtk_host_t *native_sdk_gtk_create(const char *app_name, size_t app_name_len, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags);
|
|
166
166
|
void native_sdk_gtk_destroy(native_sdk_gtk_host_t *host);
|
|
167
167
|
void native_sdk_gtk_run(native_sdk_gtk_host_t *host, native_sdk_gtk_event_callback_t callback, void *context);
|
|
168
168
|
void native_sdk_gtk_stop(native_sdk_gtk_host_t *host);
|
|
@@ -179,7 +179,7 @@ void native_sdk_gtk_request_frame(native_sdk_gtk_host_t *host);
|
|
|
179
179
|
* `out_height` set), 0 when the bytes cannot be decoded, and -1 when the
|
|
180
180
|
* decoded pixels do not fit `pixels_len` (`out_width`/`out_height` still
|
|
181
181
|
* report the decoded dimensions). */
|
|
182
|
-
int native_sdk_gtk_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t *out_width, size_t *out_height);
|
|
182
|
+
int native_sdk_gtk_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t max_pixels, size_t *out_width, size_t *out_height);
|
|
183
183
|
void native_sdk_gtk_load_webview(native_sdk_gtk_host_t *host, const char *source, size_t source_len, int source_kind, const char *asset_root, size_t asset_root_len, const char *asset_entry, size_t asset_entry_len, const char *asset_origin, size_t asset_origin_len, int spa_fallback);
|
|
184
184
|
void native_sdk_gtk_load_window_webview(native_sdk_gtk_host_t *host, uint64_t window_id, const char *source, size_t source_len, int source_kind, const char *asset_root, size_t asset_root_len, const char *asset_entry, size_t asset_entry_len, const char *asset_origin, size_t asset_origin_len, int spa_fallback);
|
|
185
185
|
void native_sdk_gtk_set_bridge_callback(native_sdk_gtk_host_t *host, native_sdk_gtk_bridge_callback_t callback, void *context);
|
|
@@ -190,7 +190,7 @@ void native_sdk_gtk_emit_window_event(native_sdk_gtk_host_t *host, uint64_t wind
|
|
|
190
190
|
void native_sdk_gtk_set_security_policy(native_sdk_gtk_host_t *host, const char *allowed_origins, size_t allowed_origins_len, const char *external_urls, size_t external_urls_len, int external_action);
|
|
191
191
|
void native_sdk_gtk_set_menus(native_sdk_gtk_host_t *host, const char *const *menu_titles, const size_t *menu_title_lens, size_t menu_count, const uint32_t *item_menu_indices, const char *const *item_labels, const size_t *item_label_lens, const char *const *item_commands, const size_t *item_command_lens, const char *const *item_keys, const size_t *item_key_lens, const uint32_t *item_modifiers, const int *item_separators, const int *item_enabled, const int *item_checked, size_t item_count);
|
|
192
192
|
void native_sdk_gtk_set_shortcuts(native_sdk_gtk_host_t *host, const char *const *ids, const size_t *id_lens, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count);
|
|
193
|
-
int native_sdk_gtk_create_window(native_sdk_gtk_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags);
|
|
193
|
+
int native_sdk_gtk_create_window(native_sdk_gtk_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, double min_width, double min_height, int show_policy, uint32_t window_flags);
|
|
194
194
|
/* Ask the windowing system to start an interactive move from the last
|
|
195
195
|
* pointer press (the widget `window_drag` channel). Returns 0 when the
|
|
196
196
|
* window is unknown or no press has been recorded yet. */
|
|
@@ -113,13 +113,13 @@ const shortcut_modifier_control: u32 = 1 << 2;
|
|
|
113
113
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
114
114
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
115
115
|
|
|
116
|
-
extern fn native_sdk_gtk_create(app_name: [*]const u8, app_name_len: usize, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) ?*GtkHost;
|
|
116
|
+
extern fn native_sdk_gtk_create(app_name: [*]const u8, app_name_len: usize, window_title: [*]const u8, window_title_len: usize, bundle_id: [*]const u8, bundle_id_len: usize, icon_path: [*]const u8, icon_path_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, initial_placement: c_int, restore_policy: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) ?*GtkHost;
|
|
117
117
|
extern fn native_sdk_gtk_destroy(host: *GtkHost) void;
|
|
118
118
|
extern fn native_sdk_gtk_run(host: *GtkHost, callback: GtkCallback, context: ?*anyopaque) void;
|
|
119
119
|
extern fn native_sdk_gtk_stop(host: *GtkHost) void;
|
|
120
120
|
extern fn native_sdk_gtk_wake(host: *GtkHost) void;
|
|
121
121
|
extern fn native_sdk_gtk_request_frame(host: *GtkHost) void;
|
|
122
|
-
extern fn native_sdk_gtk_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, out_width: *usize, out_height: *usize) c_int;
|
|
122
|
+
extern fn native_sdk_gtk_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, max_pixels: usize, out_width: *usize, out_height: *usize) c_int;
|
|
123
123
|
extern fn native_sdk_gtk_load_webview(host: *GtkHost, source: [*]const u8, source_len: usize, source_kind: c_int, asset_root: [*]const u8, asset_root_len: usize, asset_entry: [*]const u8, asset_entry_len: usize, asset_origin: [*]const u8, asset_origin_len: usize, spa_fallback: c_int) void;
|
|
124
124
|
extern fn native_sdk_gtk_load_window_webview(host: *GtkHost, window_id: u64, source: [*]const u8, source_len: usize, source_kind: c_int, asset_root: [*]const u8, asset_root_len: usize, asset_entry: [*]const u8, asset_entry_len: usize, asset_origin: [*]const u8, asset_origin_len: usize, spa_fallback: c_int) void;
|
|
125
125
|
extern fn native_sdk_gtk_set_bridge_callback(host: *GtkHost, callback: GtkBridgeCallback, context: ?*anyopaque) void;
|
|
@@ -130,7 +130,7 @@ extern fn native_sdk_gtk_emit_window_event(host: *GtkHost, window_id: u64, name:
|
|
|
130
130
|
extern fn native_sdk_gtk_set_security_policy(host: *GtkHost, allowed_origins: [*]const u8, allowed_origins_len: usize, external_urls: [*]const u8, external_urls_len: usize, external_action: c_int) void;
|
|
131
131
|
extern fn native_sdk_gtk_set_menus(host: *GtkHost, menu_titles: [*]const [*]const u8, menu_title_lens: [*]const usize, menu_count: usize, item_menu_indices: [*]const u32, item_labels: [*]const [*]const u8, item_label_lens: [*]const usize, item_commands: [*]const [*]const u8, item_command_lens: [*]const usize, item_keys: [*]const [*]const u8, item_key_lens: [*]const usize, item_modifiers: [*]const u32, item_separators: [*]const c_int, item_enabled: [*]const c_int, item_checked: [*]const c_int, item_count: usize) void;
|
|
132
132
|
extern fn native_sdk_gtk_set_shortcuts(host: *GtkHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
133
|
-
extern fn native_sdk_gtk_create_window(host: *GtkHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) c_int;
|
|
133
|
+
extern fn native_sdk_gtk_create_window(host: *GtkHost, window_id: u64, window_title: [*]const u8, window_title_len: usize, window_label: [*]const u8, window_label_len: usize, x: f64, y: f64, width: f64, height: f64, restore_frame: c_int, initial_placement: c_int, restore_policy: c_int, resizable: c_int, titlebar_style: c_int, min_width: f64, min_height: f64, show_policy: c_int, window_flags: u32) c_int;
|
|
134
134
|
extern fn native_sdk_gtk_start_window_drag(host: *GtkHost, window_id: u64) c_int;
|
|
135
135
|
extern fn native_sdk_gtk_set_window_drag_regions(host: *GtkHost, window_id: u64, label: [*]const u8, label_len: usize, rects: [*]const f64, exclusions: [*]const c_int, count: usize) c_int;
|
|
136
136
|
extern fn native_sdk_gtk_window_chrome(host: *GtkHost, window_id: u64, top: *f64, left: *f64, bottom: *f64, right: *f64, buttons_x: *f64, buttons_y: *f64, buttons_width: *f64, buttons_height: *f64) c_int;
|
|
@@ -290,7 +290,7 @@ pub const LinuxPlatform = struct {
|
|
|
290
290
|
try refuseUnsupportedMainWindowClosePolicy(window_options);
|
|
291
291
|
const window_title = window_options.resolvedTitle(app_info.app_name);
|
|
292
292
|
const frame = window_options.default_frame;
|
|
293
|
-
const host = native_sdk_gtk_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
293
|
+
const host = native_sdk_gtk_create(app_info.app_name.ptr, app_info.app_name.len, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, app_info.icon_path.ptr, app_info.icon_path.len, window_options.label.ptr, window_options.label.len, frame.x, frame.y, frame.width, frame.height, if (window_options.restore_state) 1 else 0, initialPlacementInt(window_options.initial_placement), restorePolicyInt(window_options.restore_policy), if (window_options.resizable) 1 else 0, titlebarStyleInt(window_options.titlebar), minSizeFloor(window_options.min_width), minSizeFloor(window_options.min_height), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
294
294
|
return .{
|
|
295
295
|
.host = host,
|
|
296
296
|
.web_engine = web_engine,
|
|
@@ -841,11 +841,11 @@ pub fn installHeadlessImageCodec(services: *platform_mod.PlatformServices) void
|
|
|
841
841
|
|
|
842
842
|
/// gdk-pixbuf-backed image decoding (PNG, JPEG, ... — whatever loaders
|
|
843
843
|
/// the system ships) into straight-alpha RGBA8.
|
|
844
|
-
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
|
|
844
|
+
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
|
|
845
845
|
_ = context;
|
|
846
846
|
var width: usize = 0;
|
|
847
847
|
var height: usize = 0;
|
|
848
|
-
return switch (native_sdk_gtk_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
|
|
848
|
+
return switch (native_sdk_gtk_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
|
|
849
849
|
1 => .{ .width = width, .height = height, .rgba8 = buffer[0 .. width * height * 4] },
|
|
850
850
|
-1 => error.ImageTooLarge,
|
|
851
851
|
else => error.ImageDecodeFailed,
|
|
@@ -861,6 +861,21 @@ fn titlebarStyleInt(style: platform_mod.WindowTitlebarStyle) c_int {
|
|
|
861
861
|
};
|
|
862
862
|
}
|
|
863
863
|
|
|
864
|
+
fn initialPlacementInt(placement: platform_mod.WindowInitialPlacement) c_int {
|
|
865
|
+
return switch (placement) {
|
|
866
|
+
.restored => 0,
|
|
867
|
+
.explicit => 1,
|
|
868
|
+
.default => 2,
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
fn restorePolicyInt(policy: platform_mod.WindowRestorePolicy) c_int {
|
|
873
|
+
return switch (policy) {
|
|
874
|
+
.clamp_to_visible_screen => 0,
|
|
875
|
+
.center_on_primary => 1,
|
|
876
|
+
};
|
|
877
|
+
}
|
|
878
|
+
|
|
864
879
|
fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
865
880
|
return switch (mode) {
|
|
866
881
|
.immediate => 0,
|
|
@@ -889,7 +904,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
889
904
|
const self: *LinuxPlatform = @ptrCast(@alignCast(context.?));
|
|
890
905
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
891
906
|
const frame = options.default_frame;
|
|
892
|
-
if (native_sdk_gtk_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), minSizeFloor(options.min_width), minSizeFloor(options.min_height), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
907
|
+
if (native_sdk_gtk_create_window(self.host, options.id, title.ptr, title.len, options.label.ptr, options.label.len, frame.x, frame.y, frame.width, frame.height, if (options.restore_state) 1 else 0, initialPlacementInt(options.initial_placement), restorePolicyInt(options.restore_policy), if (options.resizable) 1 else 0, titlebarStyleInt(options.titlebar), minSizeFloor(options.min_width), minSizeFloor(options.min_height), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
893
908
|
return .{
|
|
894
909
|
.id = options.id,
|
|
895
910
|
.label = options.label,
|
|
@@ -161,6 +161,7 @@ typedef enum {
|
|
|
161
161
|
NATIVE_SDK_APPKIT_WIDGET_ROLE_SLIDER = 18,
|
|
162
162
|
NATIVE_SDK_APPKIT_WIDGET_ROLE_PROGRESSBAR = 19,
|
|
163
163
|
NATIVE_SDK_APPKIT_WIDGET_ROLE_RADIO = 20,
|
|
164
|
+
NATIVE_SDK_APPKIT_WIDGET_ROLE_RADIOGROUP = 21,
|
|
164
165
|
} native_sdk_appkit_widget_role_t;
|
|
165
166
|
|
|
166
167
|
enum {
|
|
@@ -207,6 +208,7 @@ typedef enum {
|
|
|
207
208
|
|
|
208
209
|
typedef struct {
|
|
209
210
|
uint64_t id;
|
|
211
|
+
uint64_t parent_id;
|
|
210
212
|
int role;
|
|
211
213
|
const char *label;
|
|
212
214
|
size_t label_len;
|
|
@@ -378,8 +380,9 @@ typedef void (*native_sdk_appkit_bridge_callback_t)(void *context, uint64_t wind
|
|
|
378
380
|
// About panel, which also shows version and about_description when
|
|
379
381
|
// non-empty. has_web_content declares whether the app hosts a webview;
|
|
380
382
|
// web-only default menu items (Reload, Toggle Web Inspector, Undo/Redo)
|
|
381
|
-
// exist only when it is set.
|
|
382
|
-
|
|
383
|
+
// exist only when it is set. dock_visible selects Regular (nonzero) or
|
|
384
|
+
// Accessory (zero) before application configuration and window creation.
|
|
385
|
+
native_sdk_appkit_host_t *native_sdk_appkit_create(const char *app_name, size_t app_name_len, const char *display_name, size_t display_name_len, const char *version, size_t version_len, const char *about_description, size_t about_description_len, int has_web_content, int dock_visible, const char *window_title, size_t window_title_len, const char *bundle_id, size_t bundle_id_len, const char *icon_path, size_t icon_path_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
383
386
|
void native_sdk_appkit_destroy(native_sdk_appkit_host_t *host);
|
|
384
387
|
// Adopt pre-rendered straight-alpha RGBA8 pixels as the Dock icon (and
|
|
385
388
|
// the About panel copy). The pixels are copied before return, so the
|
|
@@ -418,7 +421,7 @@ void native_sdk_appkit_emit_window_event(native_sdk_appkit_host_t *host, uint64_
|
|
|
418
421
|
void native_sdk_appkit_set_security_policy(native_sdk_appkit_host_t *host, const char *allowed_origins, size_t allowed_origins_len, const char *external_urls, size_t external_urls_len, int external_action);
|
|
419
422
|
void native_sdk_appkit_set_menus(native_sdk_appkit_host_t *host, const char *const *menu_titles, const size_t *menu_title_lens, size_t menu_count, const uint32_t *item_menu_indices, const char *const *item_labels, const size_t *item_label_lens, const char *const *item_commands, const size_t *item_command_lens, const char *const *item_keys, const size_t *item_key_lens, const uint32_t *item_modifiers, const int *item_separators, const int *item_enabled, const int *item_checked, size_t item_count);
|
|
420
423
|
void native_sdk_appkit_set_shortcuts(native_sdk_appkit_host_t *host, const char *const *ids, const size_t *id_lens, const char *const *keys, const size_t *key_lens, const uint32_t *modifiers, size_t count);
|
|
421
|
-
int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
424
|
+
int native_sdk_appkit_create_window(native_sdk_appkit_host_t *host, uint64_t window_id, const char *window_title, size_t window_title_len, const char *window_label, size_t window_label_len, double x, double y, double width, double height, int restore_frame, int initial_placement, int restore_policy, int resizable, int titlebar_style, int show_policy, uint32_t window_flags);
|
|
422
425
|
// Content min-size floor for a created window (NSWindow contentMinSize):
|
|
423
426
|
// the user's resize stops at the floor. Values <= 0 leave that axis at
|
|
424
427
|
// AppKit's default minimum. Returns 0 when the window id is unknown.
|
|
@@ -643,7 +646,7 @@ int native_sdk_appkit_unregister_font(uint64_t font_id, uint64_t token);
|
|
|
643
646
|
* and -1 when the decoded pixels do not fit `pixels_len` (`out_width`/
|
|
644
647
|
* `out_height` still report the decoded dimensions). It retains no AppKit
|
|
645
648
|
* state, needs no host, and is main-thread independent. */
|
|
646
|
-
int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t *out_width, size_t *out_height);
|
|
649
|
+
int native_sdk_appkit_decode_image(const uint8_t *bytes, size_t bytes_len, uint8_t *pixels, size_t pixels_len, size_t max_pixels, size_t *out_width, size_t *out_height);
|
|
647
650
|
void native_sdk_appkit_clipboard_write(native_sdk_appkit_host_t *host, const char *text, size_t text_len);
|
|
648
651
|
size_t native_sdk_appkit_clipboard_read_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, char *buffer, size_t buffer_len);
|
|
649
652
|
int native_sdk_appkit_clipboard_write_data(native_sdk_appkit_host_t *host, const char *mime_type, size_t mime_type_len, const char *bytes, size_t bytes_len);
|