@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
|
@@ -4,9 +4,10 @@ const geometry = @import("geometry");
|
|
|
4
4
|
const platform_mod = @import("../root.zig");
|
|
5
5
|
const policy_values = @import("../policy_values.zig");
|
|
6
6
|
const security = @import("../../security/root.zig");
|
|
7
|
+
const canvas = @import("canvas");
|
|
7
8
|
// The packaging pipeline's one-image icon machinery: dev runs borrow its
|
|
8
9
|
// macOS mask/inset render so the Dock tile matches `native package`.
|
|
9
|
-
const app_icon =
|
|
10
|
+
const app_icon = canvas.app_icon;
|
|
10
11
|
|
|
11
12
|
pub const Error = error{
|
|
12
13
|
CallbackFailed,
|
|
@@ -153,13 +154,23 @@ const AppKitBridgeCallback = *const fn (context: ?*anyopaque, window_id: u64, we
|
|
|
153
154
|
/// anything else one dropped frame.
|
|
154
155
|
const AppKitVideoSinkPush = *const fn (context: ?*anyopaque, width: usize, height: usize, pixels: [*c]const u8, len: usize) callconv(.c) c_int;
|
|
155
156
|
|
|
157
|
+
extern fn native_sdk_test_imageio_thumbnail_dimensions(
|
|
158
|
+
bytes: [*]const u8,
|
|
159
|
+
bytes_len: usize,
|
|
160
|
+
source_width: usize,
|
|
161
|
+
source_height: usize,
|
|
162
|
+
max_pixels: usize,
|
|
163
|
+
out_width: *usize,
|
|
164
|
+
out_height: *usize,
|
|
165
|
+
) c_int;
|
|
166
|
+
|
|
156
167
|
const shortcut_modifier_primary: u32 = 1 << 0;
|
|
157
168
|
const shortcut_modifier_command: u32 = 1 << 1;
|
|
158
169
|
const shortcut_modifier_control: u32 = 1 << 2;
|
|
159
170
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
160
171
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
161
172
|
|
|
162
|
-
extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, display_name: [*]const u8, display_name_len: usize, version: [*]const u8, version_len: usize, about_description: [*]const u8, about_description_len: usize, has_web_content: c_int, 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, show_policy: c_int, window_flags: u32) ?*AppKitHost;
|
|
173
|
+
extern fn native_sdk_appkit_create(app_name: [*]const u8, app_name_len: usize, display_name: [*]const u8, display_name_len: usize, version: [*]const u8, version_len: usize, about_description: [*]const u8, about_description_len: usize, has_web_content: c_int, dock_visible: c_int, 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, show_policy: c_int, window_flags: u32) ?*AppKitHost;
|
|
163
174
|
extern fn native_sdk_appkit_destroy(host: *AppKitHost) void;
|
|
164
175
|
extern fn native_sdk_appkit_set_dock_icon_rgba(host: *AppKitHost, pixels: [*]const u8, width: usize, height: usize) void;
|
|
165
176
|
extern fn native_sdk_appkit_set_dock_icon_file(host: *AppKitHost, path: [*]const u8, path_len: usize) void;
|
|
@@ -177,7 +188,7 @@ extern fn native_sdk_appkit_set_security_policy(host: *AppKitHost, allowed_origi
|
|
|
177
188
|
extern fn native_sdk_appkit_set_menus(host: *AppKitHost, 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;
|
|
178
189
|
extern fn native_sdk_appkit_set_shortcuts(host: *AppKitHost, ids: [*]const [*]const u8, id_lens: [*]const usize, keys: [*]const [*]const u8, key_lens: [*]const usize, modifiers: [*]const u32, count: usize) void;
|
|
179
190
|
extern fn native_sdk_appkit_request_frame(host: *AppKitHost) void;
|
|
180
|
-
extern fn native_sdk_appkit_create_window(host: *AppKitHost, 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, show_policy: c_int, window_flags: u32) c_int;
|
|
191
|
+
extern fn native_sdk_appkit_create_window(host: *AppKitHost, 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, show_policy: c_int, window_flags: u32) c_int;
|
|
181
192
|
extern fn native_sdk_appkit_set_window_content_min_size(host: *AppKitHost, window_id: u64, min_width: f64, min_height: f64) c_int;
|
|
182
193
|
extern fn native_sdk_appkit_focus_window(host: *AppKitHost, window_id: u64) c_int;
|
|
183
194
|
extern fn native_sdk_appkit_close_window(host: *AppKitHost, window_id: u64) c_int;
|
|
@@ -244,7 +255,7 @@ extern fn native_sdk_appkit_measure_text_advances(font_id: u64, size: f64, text:
|
|
|
244
255
|
extern fn native_sdk_appkit_register_font(font_id: u64, bytes: [*]const u8, bytes_len: usize, out_token: *u64) c_int;
|
|
245
256
|
extern fn native_sdk_appkit_unregister_font(font_id: u64, token: u64) c_int;
|
|
246
257
|
extern fn native_sdk_appkit_register_bundled_fonts() void;
|
|
247
|
-
extern fn native_sdk_appkit_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, out_width: *usize, out_height: *usize) c_int;
|
|
258
|
+
extern fn native_sdk_appkit_decode_image(bytes: [*]const u8, bytes_len: usize, pixels: [*]u8, pixels_len: usize, max_pixels: usize, out_width: *usize, out_height: *usize) c_int;
|
|
248
259
|
extern fn native_sdk_appkit_clipboard_write(host: *AppKitHost, text: [*]const u8, text_len: usize) void;
|
|
249
260
|
extern fn native_sdk_appkit_clipboard_read_data(host: *AppKitHost, mime_type: [*]const u8, mime_type_len: usize, buffer: [*]u8, buffer_len: usize) usize;
|
|
250
261
|
extern fn native_sdk_appkit_clipboard_write_data(host: *AppKitHost, mime_type: [*]const u8, mime_type_len: usize, bytes: [*]const u8, bytes_len: usize) c_int;
|
|
@@ -337,6 +348,7 @@ const AppKitMessageDialogOpts = extern struct {
|
|
|
337
348
|
|
|
338
349
|
const AppKitWidgetAccessibilityNode = extern struct {
|
|
339
350
|
id: u64,
|
|
351
|
+
parent_id: u64,
|
|
340
352
|
role: c_int,
|
|
341
353
|
label: [*]const u8,
|
|
342
354
|
label_len: usize,
|
|
@@ -628,7 +640,7 @@ pub const MacPlatform = struct {
|
|
|
628
640
|
// the classic load byte-for-byte.
|
|
629
641
|
const dock_icon = planDockIcon(app_info.icon_path);
|
|
630
642
|
const icon_path = if (dock_icon == .host_file) app_info.icon_path else "";
|
|
631
|
-
const host = native_sdk_appkit_create(app_info.app_name.ptr, app_info.app_name.len, display_name.ptr, display_name.len, app_info.version.ptr, app_info.version.len, app_info.description.ptr, app_info.description.len, if (app_info.has_web_content) 1 else 0, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, icon_path.ptr, 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), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
643
|
+
const host = native_sdk_appkit_create(app_info.app_name.ptr, app_info.app_name.len, display_name.ptr, display_name.len, app_info.version.ptr, app_info.version.len, app_info.description.ptr, app_info.description.len, if (app_info.has_web_content) 1 else 0, if (app_info.dock_visible) 1 else 0, window_title.ptr, window_title.len, app_info.bundle_id.ptr, app_info.bundle_id.len, icon_path.ptr, 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), showModeInt(window_options.show), windowFlags(window_options)) orelse return error.CreateFailed;
|
|
632
644
|
switch (dock_icon) {
|
|
633
645
|
.host_file => {},
|
|
634
646
|
.masked_render => spawnDevDockIconRender(host, app_info.icon_path),
|
|
@@ -987,11 +999,7 @@ fn appkitCallback(context: ?*anyopaque, event: *const AppKitEvent) callconv(.c)
|
|
|
987
999
|
.wake => state.emit(.wake),
|
|
988
1000
|
.files_dropped => {
|
|
989
1001
|
var paths_buffer: [platform_mod.max_drop_paths][]const u8 = undefined;
|
|
990
|
-
|
|
991
|
-
state.emit(.{ .files_dropped = .{
|
|
992
|
-
.window_id = event.window_id,
|
|
993
|
-
.paths = paths,
|
|
994
|
-
} });
|
|
1002
|
+
state.emit(.{ .files_dropped = fileDropEventFromAppKitEvent(event, paths_buffer[0..]) });
|
|
995
1003
|
},
|
|
996
1004
|
.gpu_surface_frame => state.emit(.{ .gpu_surface_frame = .{
|
|
997
1005
|
.window_id = event.window_id,
|
|
@@ -1129,6 +1137,17 @@ fn gpuSurfaceInputEventFromAppKitEvent(event: *const AppKitEvent) platform_mod.G
|
|
|
1129
1137
|
};
|
|
1130
1138
|
}
|
|
1131
1139
|
|
|
1140
|
+
fn fileDropEventFromAppKitEvent(event: *const AppKitEvent, paths_buffer: [][]const u8) platform_mod.FileDropEvent {
|
|
1141
|
+
return .{
|
|
1142
|
+
.window_id = event.window_id,
|
|
1143
|
+
.view_label = appKitEventBytes(event.view_label, event.view_label_len),
|
|
1144
|
+
// AppKit's system host converts every accepted drop to the same
|
|
1145
|
+
// top-left-origin view space as gpu-surface input before emitting.
|
|
1146
|
+
.point = geometry.PointF.init(@floatCast(event.x), @floatCast(event.y)),
|
|
1147
|
+
.paths = platform_mod.splitDropPaths(appKitEventBytes(event.drop_paths, event.drop_paths_len), paths_buffer),
|
|
1148
|
+
};
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1132
1151
|
fn readClipboard(context: ?*anyopaque, buffer: []u8) anyerror![]const u8 {
|
|
1133
1152
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1134
1153
|
const len = native_sdk_appkit_clipboard_read(self.host, buffer.ptr, buffer.len);
|
|
@@ -1179,17 +1198,89 @@ fn measureTextAdvances(context: ?*anyopaque, font_id: u64, size: f32, text: []co
|
|
|
1179
1198
|
|
|
1180
1199
|
/// System image decoding (ImageIO raster codecs plus NSImage's SVG
|
|
1181
1200
|
/// rasterizer) into straight-alpha RGBA8.
|
|
1182
|
-
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!platform_mod.DecodedImage {
|
|
1201
|
+
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!platform_mod.DecodedImage {
|
|
1183
1202
|
_ = context;
|
|
1184
1203
|
var width: usize = 0;
|
|
1185
1204
|
var height: usize = 0;
|
|
1186
|
-
return switch (native_sdk_appkit_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, &width, &height)) {
|
|
1205
|
+
return switch (native_sdk_appkit_decode_image(bytes.ptr, bytes.len, buffer.ptr, buffer.len, max_pixels, &width, &height)) {
|
|
1187
1206
|
1 => .{ .width = width, .height = height, .rgba8 = buffer[0 .. width * height * 4] },
|
|
1188
1207
|
-1 => error.ImageTooLarge,
|
|
1189
1208
|
else => error.ImageDecodeFailed,
|
|
1190
1209
|
};
|
|
1191
1210
|
}
|
|
1192
1211
|
|
|
1212
|
+
test "mac image decoder keeps ImageIO thumbnail rounding inside the pixel cap" {
|
|
1213
|
+
// The Objective-C probe is compiled and linked only for macOS test
|
|
1214
|
+
// artifacts (build.zig's target-gated image_fit_test.m source). Keep
|
|
1215
|
+
// every other host from referencing its symbol at link time.
|
|
1216
|
+
if (comptime builtin.os.tag != .macos) return error.SkipZigTest;
|
|
1217
|
+
|
|
1218
|
+
// ImageIO derives the minor dimension from ThumbnailMaxPixelSize and
|
|
1219
|
+
// rounds it. 537x503 at the default 262,144-pixel target used to ask
|
|
1220
|
+
// for a 529px major side and return 529x496 = 262,384 pixels, which
|
|
1221
|
+
// the runtime correctly rejected as ImageTooLarge. The host must leave
|
|
1222
|
+
// enough headroom for that platform rounding before it asks ImageIO.
|
|
1223
|
+
const source_width: usize = 537;
|
|
1224
|
+
const source_height: usize = 503;
|
|
1225
|
+
const source_pixels = try std.testing.allocator.alloc(u8, source_width * source_height * 4);
|
|
1226
|
+
defer std.testing.allocator.free(source_pixels);
|
|
1227
|
+
var offset: usize = 0;
|
|
1228
|
+
while (offset < source_pixels.len) : (offset += 4) {
|
|
1229
|
+
source_pixels[offset..][0..4].* = .{ 23, 91, 177, 255 };
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1232
|
+
const encoded_len = try canvas.png.encodedRgba8ByteLen(source_width, source_height);
|
|
1233
|
+
const encoded = try std.testing.allocator.alloc(u8, encoded_len);
|
|
1234
|
+
defer std.testing.allocator.free(encoded);
|
|
1235
|
+
var writer = std.Io.Writer.fixed(encoded);
|
|
1236
|
+
try canvas.png.writeRgba8(&writer, source_width, source_height, source_pixels);
|
|
1237
|
+
|
|
1238
|
+
const max_pixels: usize = 512 * 512;
|
|
1239
|
+
var decoded_width: usize = 0;
|
|
1240
|
+
var decoded_height: usize = 0;
|
|
1241
|
+
try std.testing.expectEqual(@as(c_int, 1), native_sdk_test_imageio_thumbnail_dimensions(
|
|
1242
|
+
writer.buffered().ptr,
|
|
1243
|
+
writer.buffered().len,
|
|
1244
|
+
source_width,
|
|
1245
|
+
source_height,
|
|
1246
|
+
max_pixels,
|
|
1247
|
+
&decoded_width,
|
|
1248
|
+
&decoded_height,
|
|
1249
|
+
));
|
|
1250
|
+
try std.testing.expect(decoded_width > 0 and decoded_height > 0);
|
|
1251
|
+
try std.testing.expect(decoded_width * decoded_height <= max_pixels);
|
|
1252
|
+
|
|
1253
|
+
// A source panorama may exceed the decoded-axis ceiling. The host must
|
|
1254
|
+
// request a bounded thumbnail instead of rejecting the source metadata.
|
|
1255
|
+
const panorama_width = platform_mod.max_decoded_image_dimension + 1;
|
|
1256
|
+
const panorama_pixels = try std.testing.allocator.alloc(u8, panorama_width * 4);
|
|
1257
|
+
defer std.testing.allocator.free(panorama_pixels);
|
|
1258
|
+
offset = 0;
|
|
1259
|
+
while (offset < panorama_pixels.len) : (offset += 4) {
|
|
1260
|
+
panorama_pixels[offset..][0..4].* = .{ 47, 113, 191, 255 };
|
|
1261
|
+
}
|
|
1262
|
+
const panorama_encoded_len = try canvas.png.encodedRgba8ByteLen(panorama_width, 1);
|
|
1263
|
+
const panorama_encoded = try std.testing.allocator.alloc(u8, panorama_encoded_len);
|
|
1264
|
+
defer std.testing.allocator.free(panorama_encoded);
|
|
1265
|
+
var panorama_writer = std.Io.Writer.fixed(panorama_encoded);
|
|
1266
|
+
try canvas.png.writeRgba8(&panorama_writer, panorama_width, 1, panorama_pixels);
|
|
1267
|
+
|
|
1268
|
+
decoded_width = 0;
|
|
1269
|
+
decoded_height = 0;
|
|
1270
|
+
try std.testing.expectEqual(@as(c_int, 1), native_sdk_test_imageio_thumbnail_dimensions(
|
|
1271
|
+
panorama_writer.buffered().ptr,
|
|
1272
|
+
panorama_writer.buffered().len,
|
|
1273
|
+
panorama_width,
|
|
1274
|
+
1,
|
|
1275
|
+
max_pixels,
|
|
1276
|
+
&decoded_width,
|
|
1277
|
+
&decoded_height,
|
|
1278
|
+
));
|
|
1279
|
+
try std.testing.expect(decoded_width <= platform_mod.max_decoded_image_dimension);
|
|
1280
|
+
try std.testing.expect(decoded_height > 0);
|
|
1281
|
+
try std.testing.expect(decoded_width * decoded_height <= max_pixels);
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1193
1284
|
fn writeClipboard(context: ?*anyopaque, text: []const u8) anyerror!void {
|
|
1194
1285
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1195
1286
|
native_sdk_appkit_clipboard_write(self.host, text.ptr, text.len);
|
|
@@ -1263,6 +1354,21 @@ fn titlebarStyleInt(style: platform_mod.WindowTitlebarStyle) c_int {
|
|
|
1263
1354
|
};
|
|
1264
1355
|
}
|
|
1265
1356
|
|
|
1357
|
+
fn initialPlacementInt(placement: platform_mod.WindowInitialPlacement) c_int {
|
|
1358
|
+
return switch (placement) {
|
|
1359
|
+
.restored => 0,
|
|
1360
|
+
.explicit => 1,
|
|
1361
|
+
.default => 2,
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
fn restorePolicyInt(policy: platform_mod.WindowRestorePolicy) c_int {
|
|
1366
|
+
return switch (policy) {
|
|
1367
|
+
.clamp_to_visible_screen => 0,
|
|
1368
|
+
.center_on_primary => 1,
|
|
1369
|
+
};
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1266
1372
|
fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
1267
1373
|
return switch (mode) {
|
|
1268
1374
|
.immediate => 0,
|
|
@@ -1317,13 +1423,16 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
1317
1423
|
try refuseUnsupportedTransparentWindow(self.web_engine, options);
|
|
1318
1424
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
1319
1425
|
const frame = options.default_frame;
|
|
1320
|
-
if (native_sdk_appkit_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), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
1426
|
+
if (native_sdk_appkit_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), showModeInt(options.show), windowFlags(options)) == 0) return error.CreateFailed;
|
|
1321
1427
|
applyWindowContentMinSize(self.host, options.id, options.min_width, options.min_height);
|
|
1322
1428
|
applyWindowClosePolicy(self.host, options.id, options.close_policy);
|
|
1323
1429
|
return .{
|
|
1324
1430
|
.id = options.id,
|
|
1325
1431
|
.label = options.label,
|
|
1326
1432
|
.title = title,
|
|
1433
|
+
// Placement can alter the origin synchronously in AppKit; the host's
|
|
1434
|
+
// window_frame_changed event reports that actual frame immediately
|
|
1435
|
+
// after startup/create and replaces this requested-frame placeholder.
|
|
1327
1436
|
.frame = frame,
|
|
1328
1437
|
.scale_factor = 1,
|
|
1329
1438
|
.open = true,
|
|
@@ -1984,6 +2093,7 @@ fn updateWidgetAccessibility(context: ?*anyopaque, snapshot: platform_mod.Widget
|
|
|
1984
2093
|
for (snapshot.nodes, 0..) |node, index| {
|
|
1985
2094
|
nodes[index] = .{
|
|
1986
2095
|
.id = node.id,
|
|
2096
|
+
.parent_id = node.parent_id orelse 0,
|
|
1987
2097
|
.role = @intFromEnum(node.role),
|
|
1988
2098
|
.label = node.label.ptr,
|
|
1989
2099
|
.label_len = node.label.len,
|
|
@@ -2745,7 +2855,9 @@ test "mac unrestored secondary windows cascade within the active screen" {
|
|
|
2745
2855
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSWindow *referenceWindow = NSApp.keyWindow ?: self.window;") != null);
|
|
2746
2856
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMinX(referenceFrame) + 24.0") != null);
|
|
2747
2857
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxY(referenceFrame) - 24.0") != null);
|
|
2748
|
-
|
|
2858
|
+
// Only fresh/default windows under the default clamp policy cascade.
|
|
2859
|
+
// center_on_primary deliberately keeps the preceding center placement.
|
|
2860
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "if (initialPlacement == 2 && restorePolicy == 0 && !makeMain && referenceWindow)") != null);
|
|
2749
2861
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSRect visibleFrame = referenceScreen.visibleFrame;") != null);
|
|
2750
2862
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxX(visibleFrame) - NSWidth(cascadedFrame)") != null);
|
|
2751
2863
|
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSMaxY(visibleFrame) - NSHeight(cascadedFrame)") != null);
|
|
@@ -2753,6 +2865,29 @@ test "mac unrestored secondary windows cascade within the active screen" {
|
|
|
2753
2865
|
}
|
|
2754
2866
|
}
|
|
2755
2867
|
|
|
2868
|
+
test "both mac hosts distinguish restored explicit and default placement" {
|
|
2869
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2870
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "const BOOL restoredPlacement = initialPlacement == 0") != null);
|
|
2871
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "initialPlacement == 2 || (restoredPlacement && restorePolicy == 1)") != null);
|
|
2872
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkConstrainFrameToScreen(NSMakeRect(0, 0, width, height), primaryScreen)") != null);
|
|
2873
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkConstrainFrame(NSMakeRect(x, y, width, height))") != null);
|
|
2874
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "return [NSScreen screens].firstObject ?: [NSScreen mainScreen]") != null);
|
|
2875
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window frameRectForContentRect:restoredContentFrame]") != null);
|
|
2876
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window setFrame:restoredWindowFrame display:NO]") != null);
|
|
2877
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "[window setFrame:NativeSdkCenterFrameOnScreen(window.frame, primaryScreen) display:NO]") != null);
|
|
2878
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "initialPlacement == 2 && restorePolicy == 0 && !makeMain && referenceWindow") != null);
|
|
2879
|
+
}
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
test "both mac hosts preserve valid secondary-display frames" {
|
|
2883
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2884
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "static NSScreen *NativeSdkScreenForFrame(NSRect frame)") != null);
|
|
2885
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSArray<NSScreen *> *screens = [NSScreen screens]") != null);
|
|
2886
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NSIntersectionRect(frame, screen.visibleFrame)") != null);
|
|
2887
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "NativeSdkConstrainFrameToScreen(frame, NativeSdkScreenForFrame(frame))") != null);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
|
|
2756
2891
|
test "mac explicit focus activates before making the window key" {
|
|
2757
2892
|
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2758
2893
|
const focus_at = std.mem.indexOf(u8, host_source, "- (void)focusWindowWithId:(uint64_t)windowId {") orelse return error.TestExpectedEqual;
|
|
@@ -2776,6 +2911,23 @@ test "mac dock presence changes policy without activating the app" {
|
|
|
2776
2911
|
}
|
|
2777
2912
|
}
|
|
2778
2913
|
|
|
2914
|
+
test "both mac hosts apply launch dock presence before configuring the app" {
|
|
2915
|
+
for ([_][]const u8{ @embedFile("appkit_host.m"), @embedFile("cef_host.mm") }) |host_source| {
|
|
2916
|
+
const init_at = std.mem.indexOf(u8, host_source, "dockVisible:(BOOL)dockVisible") orelse return error.TestExpectedEqual;
|
|
2917
|
+
const init_tail = host_source[init_at..];
|
|
2918
|
+
const policy_at = std.mem.indexOf(u8, init_tail, "dockVisible ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory") orelse return error.TestExpectedEqual;
|
|
2919
|
+
const configure_at = std.mem.indexOf(u8, init_tail, "[self configureApplication]") orelse return error.TestExpectedEqual;
|
|
2920
|
+
const create_at = std.mem.indexOf(u8, init_tail, "[self createWindowWithId:1") orelse return error.TestExpectedEqual;
|
|
2921
|
+
try std.testing.expect(policy_at < configure_at);
|
|
2922
|
+
try std.testing.expect(policy_at < create_at);
|
|
2923
|
+
if (std.mem.indexOf(u8, init_tail, "ensureCefInitialized();")) |cef_init_at| {
|
|
2924
|
+
try std.testing.expect(policy_at < cef_init_at);
|
|
2925
|
+
}
|
|
2926
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "int has_web_content, int dock_visible") != null);
|
|
2927
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source, "dockVisible:(dock_visible != 0)") != null);
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
|
|
2779
2931
|
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
2780
2932
|
const host_source = @embedFile("appkit_host.m");
|
|
2781
2933
|
const helper_at = std.mem.indexOf(
|
|
@@ -3024,6 +3176,62 @@ test "mac gpu surface input preserves key and text" {
|
|
|
3024
3176
|
try std.testing.expect(input.modifiers.shift);
|
|
3025
3177
|
}
|
|
3026
3178
|
|
|
3179
|
+
test "mac file drop bridge preserves view label point and paths" {
|
|
3180
|
+
const label = "kanban-canvas";
|
|
3181
|
+
const paths = "/tmp/spec.txt\x00/tmp/design.pdf";
|
|
3182
|
+
var event = std.mem.zeroes(AppKitEvent);
|
|
3183
|
+
event.kind = .files_dropped;
|
|
3184
|
+
event.window_id = 7;
|
|
3185
|
+
event.view_label = label.ptr;
|
|
3186
|
+
event.view_label_len = label.len;
|
|
3187
|
+
event.x = 42.5;
|
|
3188
|
+
event.y = 91.25;
|
|
3189
|
+
event.drop_paths = paths.ptr;
|
|
3190
|
+
event.drop_paths_len = paths.len;
|
|
3191
|
+
|
|
3192
|
+
var paths_buffer: [platform_mod.max_drop_paths][]const u8 = undefined;
|
|
3193
|
+
const drop = fileDropEventFromAppKitEvent(&event, paths_buffer[0..]);
|
|
3194
|
+
try std.testing.expectEqual(@as(platform_mod.WindowId, 7), drop.window_id);
|
|
3195
|
+
try std.testing.expectEqualStrings("kanban-canvas", drop.view_label);
|
|
3196
|
+
try std.testing.expectEqualDeep(geometry.PointF.init(42.5, 91.25), drop.point.?);
|
|
3197
|
+
try std.testing.expectEqual(@as(usize, 2), drop.paths.len);
|
|
3198
|
+
try std.testing.expectEqualStrings("/tmp/spec.txt", drop.paths[0]);
|
|
3199
|
+
try std.testing.expectEqualStrings("/tmp/design.pdf", drop.paths[1]);
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
test "mac file drops and pointer input share the host y-down conversion" {
|
|
3203
|
+
const host_source = @embedFile("appkit_host.m");
|
|
3204
|
+
try std.testing.expectEqual(@as(usize, 5), std.mem.count(u8, host_source, "NativeSdkViewLocalYDownPoint("));
|
|
3205
|
+
try std.testing.expect(std.mem.indexOf(
|
|
3206
|
+
u8,
|
|
3207
|
+
host_source,
|
|
3208
|
+
"if (!view.isFlipped) point.y = view.bounds.size.height - point.y;",
|
|
3209
|
+
) != null);
|
|
3210
|
+
try std.testing.expect(std.mem.indexOf(
|
|
3211
|
+
u8,
|
|
3212
|
+
host_source,
|
|
3213
|
+
"const NSPoint yDownPoint = NativeSdkViewLocalYDownPoint(self, point);",
|
|
3214
|
+
) != null);
|
|
3215
|
+
try std.testing.expect(std.mem.indexOf(
|
|
3216
|
+
u8,
|
|
3217
|
+
host_source,
|
|
3218
|
+
"NativeSdkViewLocalYDownPoint(self, [self convertPoint:sender.draggingLocation fromView:nil])",
|
|
3219
|
+
) != null);
|
|
3220
|
+
|
|
3221
|
+
const label = "canvas";
|
|
3222
|
+
var event = std.mem.zeroes(AppKitEvent);
|
|
3223
|
+
event.view_label = label.ptr;
|
|
3224
|
+
event.view_label_len = label.len;
|
|
3225
|
+
event.x = 128.5;
|
|
3226
|
+
event.y = 73.25;
|
|
3227
|
+
|
|
3228
|
+
var paths_buffer: [platform_mod.max_drop_paths][]const u8 = undefined;
|
|
3229
|
+
const drop = fileDropEventFromAppKitEvent(&event, paths_buffer[0..]);
|
|
3230
|
+
const input = gpuSurfaceInputEventFromAppKitEvent(&event);
|
|
3231
|
+
try std.testing.expectEqual(input.x, drop.point.?.x);
|
|
3232
|
+
try std.testing.expectEqual(input.y, drop.point.?.y);
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3027
3235
|
test "mac gpu surface input preserves ime composition cursor" {
|
|
3028
3236
|
const label = "canvas";
|
|
3029
3237
|
const text = "compose";
|
|
@@ -76,6 +76,7 @@ const validateMenus = types.validateMenus;
|
|
|
76
76
|
const validateMenuItem = types.validateMenuItem;
|
|
77
77
|
const isValidShortcutKey = types.isValidShortcutKey;
|
|
78
78
|
const WindowRestorePolicy = types.WindowRestorePolicy;
|
|
79
|
+
const WindowInitialPlacement = types.WindowInitialPlacement;
|
|
79
80
|
const WindowOptions = types.WindowOptions;
|
|
80
81
|
const WindowState = types.WindowState;
|
|
81
82
|
const WindowInfo = types.WindowInfo;
|
|
@@ -377,6 +378,10 @@ pub const NullPlatform = struct {
|
|
|
377
378
|
/// like `windows` — same seam-regression purpose as
|
|
378
379
|
/// `window_resizable` (the startup create used to hardcode it).
|
|
379
380
|
window_titlebar: [max_windows]WindowTitlebarStyle = [_]WindowTitlebarStyle{.standard} ** max_windows,
|
|
381
|
+
/// Captured independently from `restore_state`: persistence opt-in does
|
|
382
|
+
/// not mean a frame was actually found and restored.
|
|
383
|
+
window_placement: [max_windows]WindowInitialPlacement = [_]WindowInitialPlacement{.default} ** max_windows,
|
|
384
|
+
window_restore_policy: [max_windows]WindowRestorePolicy = [_]WindowRestorePolicy{.clamp_to_visible_screen} ** max_windows,
|
|
380
385
|
window_transparent: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
381
386
|
window_always_on_top: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
382
387
|
window_click_through: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
@@ -802,7 +807,12 @@ pub const NullPlatform = struct {
|
|
|
802
807
|
}
|
|
803
808
|
|
|
804
809
|
pub fn initWithOptions(surface_value: Surface, web_engine: WebEngine, app_info: AppInfo) NullPlatform {
|
|
805
|
-
return .{
|
|
810
|
+
return .{
|
|
811
|
+
.surface_value = surface_value,
|
|
812
|
+
.web_engine = web_engine,
|
|
813
|
+
.app_info = app_info,
|
|
814
|
+
.dock_visible = app_info.dock_visible,
|
|
815
|
+
};
|
|
806
816
|
}
|
|
807
817
|
|
|
808
818
|
/// Heap-allocate the wrapper (process allocator) and initialize it
|
|
@@ -1152,6 +1162,8 @@ pub const NullPlatform = struct {
|
|
|
1152
1162
|
self.windows[self.window_count] = info;
|
|
1153
1163
|
self.window_resizable[self.window_count] = options.resizable;
|
|
1154
1164
|
self.window_titlebar[self.window_count] = options.titlebar;
|
|
1165
|
+
self.window_placement[self.window_count] = options.initial_placement;
|
|
1166
|
+
self.window_restore_policy[self.window_count] = options.restore_policy;
|
|
1155
1167
|
self.window_transparent[self.window_count] = options.transparent;
|
|
1156
1168
|
self.window_always_on_top[self.window_count] = options.always_on_top;
|
|
1157
1169
|
self.window_click_through[self.window_count] = options.click_through;
|
|
@@ -2415,11 +2427,11 @@ pub const NullPlatform = struct {
|
|
|
2415
2427
|
/// Deterministic decode seam for tests (see `image_decode`): parses
|
|
2416
2428
|
/// the strict PNG subset the canvas writer emits. Off by default so
|
|
2417
2429
|
/// the null platform models codec-less hosts.
|
|
2418
|
-
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8) anyerror!types.DecodedImage {
|
|
2430
|
+
fn decodeImage(context: ?*anyopaque, bytes: []const u8, buffer: []u8, max_pixels: usize) anyerror!types.DecodedImage {
|
|
2419
2431
|
const self: *NullPlatform = @ptrCast(@alignCast(context.?));
|
|
2420
2432
|
if (!self.image_decode) return error.UnsupportedService;
|
|
2421
2433
|
self.image_decode_count += 1;
|
|
2422
|
-
const decoded = canvas.png.
|
|
2434
|
+
const decoded = canvas.png.decodeRgba8Fitted(bytes, buffer, max_pixels, types.max_decoded_image_dimension) catch |err| return switch (err) {
|
|
2423
2435
|
error.PngPixelBufferTooSmall => error.ImageTooLarge,
|
|
2424
2436
|
else => error.ImageDecodeFailed,
|
|
2425
2437
|
};
|
|
@@ -2957,6 +2969,8 @@ pub const NullPlatform = struct {
|
|
|
2957
2969
|
self.windows[cursor] = self.windows[cursor + 1];
|
|
2958
2970
|
self.window_resizable[cursor] = self.window_resizable[cursor + 1];
|
|
2959
2971
|
self.window_titlebar[cursor] = self.window_titlebar[cursor + 1];
|
|
2972
|
+
self.window_placement[cursor] = self.window_placement[cursor + 1];
|
|
2973
|
+
self.window_restore_policy[cursor] = self.window_restore_policy[cursor + 1];
|
|
2960
2974
|
self.window_transparent[cursor] = self.window_transparent[cursor + 1];
|
|
2961
2975
|
self.window_always_on_top[cursor] = self.window_always_on_top[cursor + 1];
|
|
2962
2976
|
self.window_click_through[cursor] = self.window_click_through[cursor + 1];
|
|
@@ -187,6 +187,59 @@ test "null platform reports hidden startup state" {
|
|
|
187
187
|
try std.testing.expectEqual(true, recorder.startup_hidden.?);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
test "null platform captures fresh restored and explicit placement independently" {
|
|
191
|
+
var null_platform = NullPlatform.init(.{});
|
|
192
|
+
const services = null_platform.platform().services;
|
|
193
|
+
|
|
194
|
+
_ = try services.createWindow(.{
|
|
195
|
+
.id = 1,
|
|
196
|
+
.label = "fresh",
|
|
197
|
+
.restore_state = true,
|
|
198
|
+
.initial_placement = .default,
|
|
199
|
+
});
|
|
200
|
+
_ = try services.createWindow(.{
|
|
201
|
+
.id = 2,
|
|
202
|
+
.label = "restored",
|
|
203
|
+
.initial_placement = .restored,
|
|
204
|
+
});
|
|
205
|
+
_ = try services.createWindow(.{
|
|
206
|
+
.id = 3,
|
|
207
|
+
.label = "explicit",
|
|
208
|
+
.default_frame = geometry.RectF.init(80, 120, 640, 480),
|
|
209
|
+
.initial_placement = .explicit,
|
|
210
|
+
.restore_policy = .center_on_primary,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
try std.testing.expectEqual(types.WindowInitialPlacement.default, null_platform.window_placement[0]);
|
|
214
|
+
try std.testing.expectEqual(types.WindowInitialPlacement.restored, null_platform.window_placement[1]);
|
|
215
|
+
try std.testing.expectEqual(types.WindowInitialPlacement.explicit, null_platform.window_placement[2]);
|
|
216
|
+
try std.testing.expectEqual(types.WindowRestorePolicy.center_on_primary, null_platform.window_restore_policy[2]);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
test "window option conversion preserves legacy nonzero origins as explicit" {
|
|
220
|
+
const runtime_options: types.WindowCreateOptions = .{
|
|
221
|
+
.default_frame = geometry.RectF.init(32, 48, 640, 480),
|
|
222
|
+
};
|
|
223
|
+
try std.testing.expectEqual(types.WindowInitialPlacement.explicit, runtime_options.windowOptions(7, "runtime").initial_placement);
|
|
224
|
+
|
|
225
|
+
const app_info: types.AppInfo = .{
|
|
226
|
+
.main_window = .{ .default_frame = geometry.RectF.init(64, 96, 720, 480) },
|
|
227
|
+
};
|
|
228
|
+
try std.testing.expectEqual(types.WindowInitialPlacement.explicit, app_info.resolvedMainWindow().initial_placement);
|
|
229
|
+
try std.testing.expectEqual(types.WindowInitialPlacement.explicit, app_info.resolvedStartupWindow(0).initial_placement);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
test "null platform records accessory launch presence from app info" {
|
|
233
|
+
const null_platform = NullPlatform.initWithOptions(.{}, .system, .{
|
|
234
|
+
.app_name = "Menu Bar",
|
|
235
|
+
.dock_visible = false,
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
try std.testing.expect(!null_platform.app_info.dock_visible);
|
|
239
|
+
try std.testing.expect(!null_platform.dock_visible);
|
|
240
|
+
try std.testing.expectEqual(@as(u32, 0), null_platform.dock_presence_count);
|
|
241
|
+
}
|
|
242
|
+
|
|
190
243
|
test "null platform focus reveals a hidden window" {
|
|
191
244
|
var null_platform = NullPlatform.init(.{});
|
|
192
245
|
const services = null_platform.platform().services;
|
|
@@ -720,10 +773,11 @@ test "gpu surface image upload bounds are honest per id namespace" {
|
|
|
720
773
|
defer std.testing.allocator.free(buffer);
|
|
721
774
|
@memset(buffer, 128);
|
|
722
775
|
|
|
723
|
-
// Ordinary registered-image ids
|
|
724
|
-
//
|
|
725
|
-
// an engine bug and refuses loudly.
|
|
726
|
-
|
|
776
|
+
// Ordinary registered-image ids accept the registry's configurable
|
|
777
|
+
// ceiling: exactly 8 MiB (2048x1024 RGBA8) passes, one pixel past it
|
|
778
|
+
// is an engine bug and refuses loudly. Apps on the default 1 MiB tier
|
|
779
|
+
// still refuse earlier, at registration.
|
|
780
|
+
try services.uploadGpuSurfaceImage(.{ .id = 7, .width = 2048, .height = 1024, .rgba8 = buffer[0..types.max_gpu_surface_image_pixel_bytes] });
|
|
727
781
|
try std.testing.expectError(error.InvalidGpuSurfaceImage, services.uploadGpuSurfaceImage(.{
|
|
728
782
|
.id = 7,
|
|
729
783
|
.width = types.max_gpu_surface_image_pixel_bytes / 4 + 1,
|
package/src/platform/root.zig
CHANGED
|
@@ -66,6 +66,7 @@ pub const max_widget_accessibility_nodes = types.max_widget_accessibility_nodes;
|
|
|
66
66
|
pub const max_gpu_surface_packet_json_bytes = types.max_gpu_surface_packet_json_bytes;
|
|
67
67
|
pub const max_gpu_surface_packet_binary_bytes = types.max_gpu_surface_packet_binary_bytes;
|
|
68
68
|
pub const max_gpu_present_fallback_detail_bytes = types.max_gpu_present_fallback_detail_bytes;
|
|
69
|
+
pub const max_decoded_image_dimension = types.max_decoded_image_dimension;
|
|
69
70
|
pub const max_gpu_surface_image_pixel_bytes = types.max_gpu_surface_image_pixel_bytes;
|
|
70
71
|
pub const max_gpu_surface_media_image_pixel_bytes = types.max_gpu_surface_media_image_pixel_bytes;
|
|
71
72
|
pub const max_gpu_surface_font_bytes = types.max_gpu_surface_font_bytes;
|
|
@@ -80,6 +81,7 @@ pub const validateMenuItem = types.validateMenuItem;
|
|
|
80
81
|
pub const isValidShortcutKey = types.isValidShortcutKey;
|
|
81
82
|
pub const isValidShortcutBinding = types.isValidShortcutBinding;
|
|
82
83
|
pub const WindowRestorePolicy = types.WindowRestorePolicy;
|
|
84
|
+
pub const WindowInitialPlacement = types.WindowInitialPlacement;
|
|
83
85
|
pub const WindowTitlebarStyle = types.WindowTitlebarStyle;
|
|
84
86
|
pub const WindowChrome = types.WindowChrome;
|
|
85
87
|
pub const FormFactor = types.FormFactor;
|