@native-sdk/cli 0.6.1 → 0.6.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.zig +8 -0
- package/native-sdk.d.ts +16 -0
- package/package.json +9 -9
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/text.ts +62 -21
- package/src/app_runner/root.zig +19 -0
- package/src/platform/linux/gtk_host.c +167 -8
- package/src/platform/linux/gtk_host.h +3 -2
- package/src/platform/linux/root.zig +198 -9
- package/src/platform/macos/appkit_host.h +4 -2
- package/src/platform/macos/appkit_host.m +137 -38
- package/src/platform/macos/cef_host.mm +46 -11
- package/src/platform/macos/root.zig +150 -6
- package/src/platform/null_platform.zig +32 -4
- package/src/platform/types.zig +31 -4
- package/src/platform/windows/root.zig +220 -10
- package/src/platform/windows/webview2_host.cpp +330 -31
- package/src/primitives/app_manifest/comptime_scene.zig +4 -0
- package/src/primitives/app_manifest/types.zig +16 -0
- package/src/primitives/canvas/equality.zig +3 -1
- package/src/primitives/canvas/events.zig +4 -0
- package/src/primitives/canvas/root.zig +11 -0
- package/src/primitives/canvas/text.zig +10 -0
- package/src/primitives/canvas/text_interaction.zig +164 -22
- package/src/primitives/canvas/text_layout.zig +107 -21
- package/src/primitives/canvas/text_tests.zig +86 -0
- package/src/primitives/canvas/ui.zig +21 -16
- package/src/primitives/canvas/ui_markup_reflect.zig +20 -3
- package/src/primitives/canvas/ui_markup_view_tests.zig +16 -0
- package/src/primitives/canvas/ui_tests.zig +6 -0
- package/src/primitives/canvas/widget_render.zig +21 -2
- package/src/primitives/canvas/widget_runtime.zig +1 -0
- package/src/primitives/canvas/widget_runtime_tests.zig +51 -0
- package/src/primitives/canvas/widget_text_input.zig +23 -11
- package/src/runtime/api.zig +9 -0
- package/src/runtime/bridge_payload.zig +9 -0
- package/src/runtime/bridge_responses.zig +2 -0
- package/src/runtime/builtin_bridge.zig +10 -0
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_limits.zig +7 -0
- package/src/runtime/canvas_widget_accessibility_tests.zig +27 -1
- package/src/runtime/canvas_widget_clipboard_tests.zig +16 -0
- package/src/runtime/canvas_widget_display.zig +15 -1
- package/src/runtime/canvas_widget_events.zig +43 -19
- package/src/runtime/canvas_widget_floating_tests.zig +3 -3
- package/src/runtime/canvas_widget_runtime.zig +67 -10
- package/src/runtime/canvas_widget_state.zig +1 -0
- package/src/runtime/canvas_widget_text_tests.zig +1878 -70
- package/src/runtime/effects.zig +5 -6
- package/src/runtime/flow.zig +45 -7
- package/src/runtime/gpu_surface_events.zig +46 -1
- package/src/runtime/runtime_event_tests.zig +9 -6
- package/src/runtime/shell_layout.zig +25 -11
- package/src/runtime/shell_layout_tests.zig +184 -0
- package/src/runtime/shell_view_tests.zig +9 -7
- package/src/runtime/state.zig +6 -0
- package/src/runtime/ui_app.zig +61 -14
- package/src/runtime/ui_app_window_tests.zig +107 -2
- package/src/runtime/view.zig +30 -0
- package/src/runtime/view_widget_text.zig +1048 -10
- package/src/runtime/view_widget_tree.zig +2 -0
- package/src/runtime/window_command_bridge_tests.zig +82 -6
- package/src/runtime/window_storage.zig +14 -3
- package/src/runtime/window_views.zig +12 -11
- package/src/tooling/manifest.zig +38 -2
- package/src/tooling/raw_manifest.zig +8 -0
- package/src/tooling/templates.zig +17 -0
|
@@ -13,6 +13,7 @@ pub const Error = error{
|
|
|
13
13
|
CreateFailed,
|
|
14
14
|
FocusFailed,
|
|
15
15
|
CloseFailed,
|
|
16
|
+
UnsupportedWindowTransparency,
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const AppKitHost = opaque {};
|
|
@@ -155,7 +156,7 @@ const shortcut_modifier_control: u32 = 1 << 2;
|
|
|
155
156
|
const shortcut_modifier_option: u32 = 1 << 3;
|
|
156
157
|
const shortcut_modifier_shift: u32 = 1 << 4;
|
|
157
158
|
|
|
158
|
-
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) ?*AppKitHost;
|
|
159
|
+
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;
|
|
159
160
|
extern fn native_sdk_appkit_destroy(host: *AppKitHost) void;
|
|
160
161
|
extern fn native_sdk_appkit_set_dock_icon_rgba(host: *AppKitHost, pixels: [*]const u8, width: usize, height: usize) void;
|
|
161
162
|
extern fn native_sdk_appkit_set_dock_icon_file(host: *AppKitHost, path: [*]const u8, path_len: usize) void;
|
|
@@ -173,7 +174,7 @@ extern fn native_sdk_appkit_set_security_policy(host: *AppKitHost, allowed_origi
|
|
|
173
174
|
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;
|
|
174
175
|
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;
|
|
175
176
|
extern fn native_sdk_appkit_request_frame(host: *AppKitHost) void;
|
|
176
|
-
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) c_int;
|
|
177
|
+
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;
|
|
177
178
|
extern fn native_sdk_appkit_set_window_content_min_size(host: *AppKitHost, window_id: u64, min_width: f64, min_height: f64) c_int;
|
|
178
179
|
extern fn native_sdk_appkit_focus_window(host: *AppKitHost, window_id: u64) c_int;
|
|
179
180
|
extern fn native_sdk_appkit_close_window(host: *AppKitHost, window_id: u64) c_int;
|
|
@@ -374,6 +375,8 @@ const widget_state_collapsed: u32 = 1 << 5;
|
|
|
374
375
|
const widget_state_required: u32 = 1 << 6;
|
|
375
376
|
const widget_state_read_only: u32 = 1 << 7;
|
|
376
377
|
const widget_state_invalid: u32 = 1 << 8;
|
|
378
|
+
const widget_state_can_undo: u32 = 1 << 9;
|
|
379
|
+
const widget_state_can_redo: u32 = 1 << 10;
|
|
377
380
|
const widget_action_focus: u32 = 1 << 0;
|
|
378
381
|
const widget_action_press: u32 = 1 << 1;
|
|
379
382
|
const widget_action_toggle: u32 = 1 << 2;
|
|
@@ -595,6 +598,7 @@ pub const MacPlatform = struct {
|
|
|
595
598
|
|
|
596
599
|
pub fn initWithOptions(size: geometry.SizeF, web_engine: platform_mod.WebEngine, app_info: platform_mod.AppInfo) Error!MacPlatform {
|
|
597
600
|
const window_options = app_info.resolvedMainWindow();
|
|
601
|
+
try refuseUnsupportedTransparentWindow(web_engine, window_options);
|
|
598
602
|
const window_title = window_options.resolvedTitle(app_info.app_name);
|
|
599
603
|
const frame = window_options.default_frame;
|
|
600
604
|
const display_name = app_info.resolvedDisplayName();
|
|
@@ -610,7 +614,7 @@ pub const MacPlatform = struct {
|
|
|
610
614
|
// the classic load byte-for-byte.
|
|
611
615
|
const dock_icon = planDockIcon(app_info.icon_path);
|
|
612
616
|
const icon_path = if (dock_icon == .host_file) app_info.icon_path else "";
|
|
613
|
-
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)) orelse return error.CreateFailed;
|
|
617
|
+
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;
|
|
614
618
|
switch (dock_icon) {
|
|
615
619
|
.host_file => {},
|
|
616
620
|
.masked_render => spawnDevDockIconRender(host, app_info.icon_path),
|
|
@@ -1220,6 +1224,19 @@ fn showModeInt(mode: platform_mod.WindowShowMode) c_int {
|
|
|
1220
1224
|
};
|
|
1221
1225
|
}
|
|
1222
1226
|
|
|
1227
|
+
fn windowFlags(options: platform_mod.WindowOptions) u32 {
|
|
1228
|
+
var flags: u32 = 0;
|
|
1229
|
+
if (options.transparent) flags |= 1 << 0;
|
|
1230
|
+
if (options.always_on_top) flags |= 1 << 1;
|
|
1231
|
+
if (options.click_through) flags |= 1 << 2;
|
|
1232
|
+
if (!options.activate_on_show) flags |= 1 << 3;
|
|
1233
|
+
return flags;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
fn refuseUnsupportedTransparentWindow(web_engine: platform_mod.WebEngine, options: platform_mod.WindowOptions) Error!void {
|
|
1237
|
+
if (web_engine == .chromium and options.transparent) return error.UnsupportedWindowTransparency;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1223
1240
|
fn closePolicyInt(policy: platform_mod.WindowClosePolicy) c_int {
|
|
1224
1241
|
return switch (policy) {
|
|
1225
1242
|
.quit => 0,
|
|
@@ -1249,9 +1266,10 @@ fn applyWindowContentMinSize(host: *AppKitHost, window_id: u64, min_width: f32,
|
|
|
1249
1266
|
|
|
1250
1267
|
fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyerror!platform_mod.WindowInfo {
|
|
1251
1268
|
const self: *MacPlatform = @ptrCast(@alignCast(context.?));
|
|
1269
|
+
try refuseUnsupportedTransparentWindow(self.web_engine, options);
|
|
1252
1270
|
const title = options.resolvedTitle(self.app_info.app_name);
|
|
1253
1271
|
const frame = options.default_frame;
|
|
1254
|
-
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)) == 0) return error.CreateFailed;
|
|
1272
|
+
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;
|
|
1255
1273
|
applyWindowContentMinSize(self.host, options.id, options.min_width, options.min_height);
|
|
1256
1274
|
applyWindowClosePolicy(self.host, options.id, options.close_policy);
|
|
1257
1275
|
return .{
|
|
@@ -1261,7 +1279,7 @@ fn createWindow(context: ?*anyopaque, options: platform_mod.WindowOptions) anyer
|
|
|
1261
1279
|
.frame = frame,
|
|
1262
1280
|
.scale_factor = 1,
|
|
1263
1281
|
.open = true,
|
|
1264
|
-
.focused =
|
|
1282
|
+
.focused = options.activate_on_show and options.show == .immediate,
|
|
1265
1283
|
};
|
|
1266
1284
|
}
|
|
1267
1285
|
|
|
@@ -1901,6 +1919,8 @@ fn widgetStateFlags(node: platform_mod.WidgetAccessibilityNode) u32 {
|
|
|
1901
1919
|
if (node.required) flags |= widget_state_required;
|
|
1902
1920
|
if (node.read_only) flags |= widget_state_read_only;
|
|
1903
1921
|
if (node.invalid) flags |= widget_state_invalid;
|
|
1922
|
+
if (node.can_undo) flags |= widget_state_can_undo;
|
|
1923
|
+
if (node.can_redo) flags |= widget_state_can_redo;
|
|
1904
1924
|
return flags;
|
|
1905
1925
|
}
|
|
1906
1926
|
|
|
@@ -2252,6 +2272,22 @@ test "macos chromium reports unsupported native surfaces" {
|
|
|
2252
2272
|
try std.testing.expect(!MacPlatform.supportsFeature(&chromium, .view_surface_adoption));
|
|
2253
2273
|
}
|
|
2254
2274
|
|
|
2275
|
+
test "macos chromium refuses transparent windows" {
|
|
2276
|
+
try refuseUnsupportedTransparentWindow(.system, .{ .transparent = true });
|
|
2277
|
+
try refuseUnsupportedTransparentWindow(.chromium, .{});
|
|
2278
|
+
try std.testing.expectError(
|
|
2279
|
+
error.UnsupportedWindowTransparency,
|
|
2280
|
+
refuseUnsupportedTransparentWindow(.chromium, .{ .transparent = true }),
|
|
2281
|
+
);
|
|
2282
|
+
|
|
2283
|
+
const host_source = @embedFile("cef_host.mm");
|
|
2284
|
+
try std.testing.expect(std.mem.count(
|
|
2285
|
+
u8,
|
|
2286
|
+
host_source,
|
|
2287
|
+
"if ((window_flags & (1u << 0)) != 0) return",
|
|
2288
|
+
) >= 2);
|
|
2289
|
+
}
|
|
2290
|
+
|
|
2255
2291
|
fn testPlatformWithEngine(web_engine: platform_mod.WebEngine) MacPlatform {
|
|
2256
2292
|
return .{
|
|
2257
2293
|
.host = undefined,
|
|
@@ -2423,6 +2459,112 @@ test "mac webview presses report the focused child label" {
|
|
|
2423
2459
|
try std.testing.expect(std.mem.indexOf(u8, host_source, ".view_label = label") != null);
|
|
2424
2460
|
}
|
|
2425
2461
|
|
|
2462
|
+
test "mac active implicit show activates before making the window key" {
|
|
2463
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2464
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source,
|
|
2465
|
+
\\ if ([self.passiveShowWindows containsObject:@(windowId)]) {
|
|
2466
|
+
\\ [window orderFront:nil];
|
|
2467
|
+
\\ } else {
|
|
2468
|
+
\\ [NSApp activate];
|
|
2469
|
+
\\ [window makeKeyAndOrderFront:nil];
|
|
2470
|
+
\\ }
|
|
2471
|
+
) != null);
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
test "mac explicit focus activates before making the window key" {
|
|
2475
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2476
|
+
try std.testing.expect(std.mem.indexOf(u8, host_source,
|
|
2477
|
+
\\- (void)focusWindowWithId:(uint64_t)windowId {
|
|
2478
|
+
\\ NSWindow *window = self.windows[@(windowId)];
|
|
2479
|
+
\\ if (!window) return;
|
|
2480
|
+
\\ // An explicit focus overrides a pending present-before-show defer:
|
|
2481
|
+
\\ // the runtime asked for the window NOW.
|
|
2482
|
+
\\ [self.deferredShowWindows removeObjectForKey:@(windowId)];
|
|
2483
|
+
\\ [NSApp activate];
|
|
2484
|
+
\\ [window makeKeyAndOrderFront:nil];
|
|
2485
|
+
) != null);
|
|
2486
|
+
}
|
|
2487
|
+
|
|
2488
|
+
test "mac transparent raw frames are premultiplied exactly once before Metal upload" {
|
|
2489
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2490
|
+
const helper_at = std.mem.indexOf(
|
|
2491
|
+
u8,
|
|
2492
|
+
host_source,
|
|
2493
|
+
"static void NativeSdkPremultiplyStraightRgba8",
|
|
2494
|
+
) orelse return error.TestExpectedEqual;
|
|
2495
|
+
const present_at = std.mem.indexOfPos(
|
|
2496
|
+
u8,
|
|
2497
|
+
host_source,
|
|
2498
|
+
helper_at,
|
|
2499
|
+
"- (BOOL)presentPixelsWithWidth:",
|
|
2500
|
+
) orelse return error.TestExpectedEqual;
|
|
2501
|
+
const present_tail = host_source[present_at..];
|
|
2502
|
+
|
|
2503
|
+
try std.testing.expect(helper_at < present_at);
|
|
2504
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2505
|
+
u8,
|
|
2506
|
+
present_tail,
|
|
2507
|
+
"if (self.window && !self.window.opaque && !sourceIsPremultiplied)",
|
|
2508
|
+
) != null);
|
|
2509
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2510
|
+
u8,
|
|
2511
|
+
present_tail,
|
|
2512
|
+
"NativeSdkPremultiplyStraightRgba8(",
|
|
2513
|
+
) != null);
|
|
2514
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2515
|
+
u8,
|
|
2516
|
+
present_tail,
|
|
2517
|
+
"sourceIsPremultiplied:YES rgba8:(const uint8_t *)pixels.bytes",
|
|
2518
|
+
) != null);
|
|
2519
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2520
|
+
u8,
|
|
2521
|
+
present_tail,
|
|
2522
|
+
"sourceIsPremultiplied:NO rgba8:rgba8",
|
|
2523
|
+
) != null);
|
|
2524
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2525
|
+
u8,
|
|
2526
|
+
present_tail,
|
|
2527
|
+
"const uint8_t *uploadBytes = presentBytes +",
|
|
2528
|
+
) != null);
|
|
2529
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2530
|
+
u8,
|
|
2531
|
+
present_tail,
|
|
2532
|
+
"memcpy(backingBytes, presentBytes, byteLength);",
|
|
2533
|
+
) != null);
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
test "mac transparent gpu surfaces clear missing canvas content to transparent" {
|
|
2537
|
+
const host_source = @embedFile("appkit_host.m");
|
|
2538
|
+
const render_at = std.mem.indexOf(
|
|
2539
|
+
u8,
|
|
2540
|
+
host_source,
|
|
2541
|
+
"- (void)renderFrame {",
|
|
2542
|
+
) orelse return error.TestExpectedEqual;
|
|
2543
|
+
const render_end = std.mem.indexOfPos(
|
|
2544
|
+
u8,
|
|
2545
|
+
host_source,
|
|
2546
|
+
render_at,
|
|
2547
|
+
"- (BOOL)acceptsFirstResponder",
|
|
2548
|
+
) orelse return error.TestExpectedEqual;
|
|
2549
|
+
const render_source = host_source[render_at..render_end];
|
|
2550
|
+
|
|
2551
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2552
|
+
u8,
|
|
2553
|
+
render_source,
|
|
2554
|
+
"const BOOL transparentWindow = window != nil && !window.opaque;",
|
|
2555
|
+
) != null);
|
|
2556
|
+
try std.testing.expect(std.mem.indexOf(u8, render_source,
|
|
2557
|
+
\\descriptor.colorAttachments[0].clearColor = transparentWindow
|
|
2558
|
+
\\ ? MTLClearColorMake(0.0, 0.0, 0.0, 0.0)
|
|
2559
|
+
\\ : MTLClearColorMake(red, green, blue, 1.0);
|
|
2560
|
+
) != null);
|
|
2561
|
+
try std.testing.expect(std.mem.indexOf(
|
|
2562
|
+
u8,
|
|
2563
|
+
render_source,
|
|
2564
|
+
"if (self.hasCanvasTexture && canvasTextureMatchesDrawable",
|
|
2565
|
+
) != null);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2426
2568
|
test "mac Chromium webview focus reports the focused child label" {
|
|
2427
2569
|
// CEF's focus handler is the engine-level ownership edge: it covers
|
|
2428
2570
|
// pointer, keyboard, and programmatic focus without predicting from
|
|
@@ -2513,13 +2655,15 @@ test "mac widget accessibility maps retained action flags" {
|
|
|
2513
2655
|
}
|
|
2514
2656
|
|
|
2515
2657
|
test "mac widget accessibility maps widget state flags" {
|
|
2516
|
-
const expanded = widgetStateFlags(.{ .enabled = true, .expanded = true, .required = true, .read_only = true, .invalid = true });
|
|
2658
|
+
const expanded = widgetStateFlags(.{ .enabled = true, .expanded = true, .required = true, .read_only = true, .invalid = true, .can_undo = true, .can_redo = true });
|
|
2517
2659
|
try std.testing.expect(expanded & widget_state_enabled != 0);
|
|
2518
2660
|
try std.testing.expect(expanded & widget_state_expanded != 0);
|
|
2519
2661
|
try std.testing.expect(expanded & widget_state_collapsed == 0);
|
|
2520
2662
|
try std.testing.expect(expanded & widget_state_required != 0);
|
|
2521
2663
|
try std.testing.expect(expanded & widget_state_read_only != 0);
|
|
2522
2664
|
try std.testing.expect(expanded & widget_state_invalid != 0);
|
|
2665
|
+
try std.testing.expect(expanded & widget_state_can_undo != 0);
|
|
2666
|
+
try std.testing.expect(expanded & widget_state_can_redo != 0);
|
|
2523
2667
|
|
|
2524
2668
|
const collapsed = widgetStateFlags(.{ .enabled = true, .expanded = false });
|
|
2525
2669
|
try std.testing.expect(collapsed & widget_state_enabled != 0);
|
|
@@ -328,6 +328,10 @@ pub const NullPlatform = struct {
|
|
|
328
328
|
/// like `windows` — same seam-regression purpose as
|
|
329
329
|
/// `window_resizable` (the startup create used to hardcode it).
|
|
330
330
|
window_titlebar: [max_windows]WindowTitlebarStyle = [_]WindowTitlebarStyle{.standard} ** max_windows,
|
|
331
|
+
window_transparent: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
332
|
+
window_always_on_top: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
333
|
+
window_click_through: [max_windows]bool = [_]bool{false} ** max_windows,
|
|
334
|
+
window_activate_on_show: [max_windows]bool = [_]bool{true} ** max_windows,
|
|
331
335
|
/// Minimize calls per window (`minimize_window_fn`), indexed like
|
|
332
336
|
/// `windows`: the observable seam for app-drawn minimize controls —
|
|
333
337
|
/// the null platform has no Dock to genie into, so the count IS the
|
|
@@ -937,7 +941,7 @@ pub const NullPlatform = struct {
|
|
|
937
941
|
.frame = window.default_frame,
|
|
938
942
|
.scale_factor = self.surface_value.scale_factor,
|
|
939
943
|
.open = true,
|
|
940
|
-
.focused = index == 0,
|
|
944
|
+
.focused = index == 0 and window.activate_on_show and window.show == .immediate,
|
|
941
945
|
} });
|
|
942
946
|
}
|
|
943
947
|
var frame: u32 = 0;
|
|
@@ -1037,6 +1041,10 @@ pub const NullPlatform = struct {
|
|
|
1037
1041
|
if (window.id == options.id) return error.DuplicateWindowId;
|
|
1038
1042
|
if (std.mem.eql(u8, window.label, options.label)) return error.DuplicateWindowLabel;
|
|
1039
1043
|
}
|
|
1044
|
+
const focused = options.activate_on_show and options.show == .immediate;
|
|
1045
|
+
if (focused) {
|
|
1046
|
+
for (self.windows[0..self.window_count]) |*window| window.focused = false;
|
|
1047
|
+
}
|
|
1040
1048
|
const info: WindowInfo = .{
|
|
1041
1049
|
.id = options.id,
|
|
1042
1050
|
.label = options.label,
|
|
@@ -1044,11 +1052,15 @@ pub const NullPlatform = struct {
|
|
|
1044
1052
|
.frame = options.default_frame,
|
|
1045
1053
|
.scale_factor = self.surface_value.scale_factor,
|
|
1046
1054
|
.open = true,
|
|
1047
|
-
.focused =
|
|
1055
|
+
.focused = focused,
|
|
1048
1056
|
};
|
|
1049
1057
|
self.windows[self.window_count] = info;
|
|
1050
1058
|
self.window_resizable[self.window_count] = options.resizable;
|
|
1051
1059
|
self.window_titlebar[self.window_count] = options.titlebar;
|
|
1060
|
+
self.window_transparent[self.window_count] = options.transparent;
|
|
1061
|
+
self.window_always_on_top[self.window_count] = options.always_on_top;
|
|
1062
|
+
self.window_click_through[self.window_count] = options.click_through;
|
|
1063
|
+
self.window_activate_on_show[self.window_count] = options.activate_on_show;
|
|
1052
1064
|
self.window_show[self.window_count] = options.show;
|
|
1053
1065
|
self.window_close_policy[self.window_count] = options.close_policy;
|
|
1054
1066
|
self.window_min_width[self.window_count] = options.min_width;
|
|
@@ -1081,6 +1093,11 @@ pub const NullPlatform = struct {
|
|
|
1081
1093
|
self.window_visible[index] = true;
|
|
1082
1094
|
self.show_op_seq += 1;
|
|
1083
1095
|
self.window_shown_seq[index] = self.show_op_seq;
|
|
1096
|
+
if (self.window_activate_on_show[index]) {
|
|
1097
|
+
for (self.windows[0..self.window_count], 0..) |*window, cursor| {
|
|
1098
|
+
window.focused = cursor == index;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1084
1101
|
}
|
|
1085
1102
|
}
|
|
1086
1103
|
|
|
@@ -1175,8 +1192,10 @@ pub const NullPlatform = struct {
|
|
|
1175
1192
|
// present-before-show alike.
|
|
1176
1193
|
self.windows[index].hidden = false;
|
|
1177
1194
|
self.window_occluded[index] = false;
|
|
1178
|
-
|
|
1179
|
-
|
|
1195
|
+
if (self.window_activate_on_show[index]) {
|
|
1196
|
+
for (self.windows[0..self.window_count], 0..) |*window, cursor| {
|
|
1197
|
+
window.focused = cursor == index;
|
|
1198
|
+
}
|
|
1180
1199
|
}
|
|
1181
1200
|
if (!self.window_visible[index]) {
|
|
1182
1201
|
self.window_visible[index] = true;
|
|
@@ -2591,6 +2610,15 @@ pub const NullPlatform = struct {
|
|
|
2591
2610
|
while (cursor + 1 < self.window_count) : (cursor += 1) {
|
|
2592
2611
|
self.windows[cursor] = self.windows[cursor + 1];
|
|
2593
2612
|
self.window_resizable[cursor] = self.window_resizable[cursor + 1];
|
|
2613
|
+
self.window_titlebar[cursor] = self.window_titlebar[cursor + 1];
|
|
2614
|
+
self.window_transparent[cursor] = self.window_transparent[cursor + 1];
|
|
2615
|
+
self.window_always_on_top[cursor] = self.window_always_on_top[cursor + 1];
|
|
2616
|
+
self.window_click_through[cursor] = self.window_click_through[cursor + 1];
|
|
2617
|
+
self.window_activate_on_show[cursor] = self.window_activate_on_show[cursor + 1];
|
|
2618
|
+
self.window_show[cursor] = self.window_show[cursor + 1];
|
|
2619
|
+
self.window_visible[cursor] = self.window_visible[cursor + 1];
|
|
2620
|
+
self.window_first_present_seq[cursor] = self.window_first_present_seq[cursor + 1];
|
|
2621
|
+
self.window_shown_seq[cursor] = self.window_shown_seq[cursor + 1];
|
|
2594
2622
|
self.window_min_width[cursor] = self.window_min_width[cursor + 1];
|
|
2595
2623
|
self.window_min_height[cursor] = self.window_min_height[cursor + 1];
|
|
2596
2624
|
self.window_minimize_count[cursor] = self.window_minimize_count[cursor + 1];
|
package/src/platform/types.zig
CHANGED
|
@@ -8,6 +8,7 @@ pub const default_gpu_first_frame_latency_budget_ns: u64 = 150_000_000;
|
|
|
8
8
|
|
|
9
9
|
pub const Error = error{
|
|
10
10
|
UnsupportedService,
|
|
11
|
+
UnsupportedWindowTransparency,
|
|
11
12
|
WindowNotFound,
|
|
12
13
|
WindowLimitReached,
|
|
13
14
|
DuplicateWindowId,
|
|
@@ -594,6 +595,22 @@ pub const WindowOptions = struct {
|
|
|
594
595
|
restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
|
|
595
596
|
titlebar: WindowTitlebarStyle = .standard,
|
|
596
597
|
show: WindowShowMode = .immediate,
|
|
598
|
+
/// Make the top-level window and its rendering surface alpha-capable.
|
|
599
|
+
/// The app must also render alpha (for canvas views, select a
|
|
600
|
+
/// non-opaque gpu alpha mode); otherwise opaque content still covers
|
|
601
|
+
/// the desktop normally. Backends that cannot provide an alpha-capable
|
|
602
|
+
/// render surface reject creation with `UnsupportedWindowTransparency`.
|
|
603
|
+
transparent: bool = false,
|
|
604
|
+
/// Keep the window above ordinary application windows using the
|
|
605
|
+
/// platform's floating/topmost window level.
|
|
606
|
+
always_on_top: bool = false,
|
|
607
|
+
/// Ignore pointer hit testing for the whole top-level window so
|
|
608
|
+
/// clicks, motion, and scrolling reach the window underneath.
|
|
609
|
+
click_through: bool = false,
|
|
610
|
+
/// Whether an implicit show (initial creation, first-present reveal,
|
|
611
|
+
/// or `showWindow`) activates the app and takes keyboard focus.
|
|
612
|
+
/// Explicit `focusWindow` remains an activation request either way.
|
|
613
|
+
activate_on_show: bool = true,
|
|
597
614
|
/// Content min-size floor the WINDOW enforces (macOS
|
|
598
615
|
/// `contentMinSize`): the user cannot resize below it, so declared
|
|
599
616
|
/// layout floors stop clamping/clipping panes instead of stopping
|
|
@@ -667,6 +684,10 @@ pub const WindowCreateOptions = struct {
|
|
|
667
684
|
restore_policy: WindowRestorePolicy = .clamp_to_visible_screen,
|
|
668
685
|
titlebar: WindowTitlebarStyle = .standard,
|
|
669
686
|
show: WindowShowMode = .immediate,
|
|
687
|
+
transparent: bool = false,
|
|
688
|
+
always_on_top: bool = false,
|
|
689
|
+
click_through: bool = false,
|
|
690
|
+
activate_on_show: bool = true,
|
|
670
691
|
/// Window-enforced content min-size floor (see
|
|
671
692
|
/// `WindowOptions.min_width`/`min_height`); 0 = no floor.
|
|
672
693
|
min_width: f32 = 0,
|
|
@@ -686,6 +707,10 @@ pub const WindowCreateOptions = struct {
|
|
|
686
707
|
.restore_policy = self.restore_policy,
|
|
687
708
|
.titlebar = self.titlebar,
|
|
688
709
|
.show = self.show,
|
|
710
|
+
.transparent = self.transparent,
|
|
711
|
+
.always_on_top = self.always_on_top,
|
|
712
|
+
.click_through = self.click_through,
|
|
713
|
+
.activate_on_show = self.activate_on_show,
|
|
689
714
|
.min_width = self.min_width,
|
|
690
715
|
.min_height = self.min_height,
|
|
691
716
|
.close_policy = self.close_policy,
|
|
@@ -853,7 +878,7 @@ pub const GpuSurfaceOptions = struct {
|
|
|
853
878
|
return (self.backend == .metal or self.backend == .software) and
|
|
854
879
|
self.pixel_format == .bgra8_unorm and
|
|
855
880
|
self.present_mode == .timer and
|
|
856
|
-
self.alpha_mode == .@"opaque" and
|
|
881
|
+
(self.alpha_mode == .@"opaque" or self.alpha_mode == .premultiplied) and
|
|
857
882
|
self.color_space == .srgb and
|
|
858
883
|
self.vsync;
|
|
859
884
|
}
|
|
@@ -2129,6 +2154,8 @@ pub const WidgetAccessibilityNode = struct {
|
|
|
2129
2154
|
required: bool = false,
|
|
2130
2155
|
read_only: bool = false,
|
|
2131
2156
|
invalid: bool = false,
|
|
2157
|
+
can_undo: bool = false,
|
|
2158
|
+
can_redo: bool = false,
|
|
2132
2159
|
focusable: bool = false,
|
|
2133
2160
|
actions: WidgetAccessibilityActions = .{},
|
|
2134
2161
|
};
|
|
@@ -2303,9 +2330,9 @@ pub const PlatformServices = struct {
|
|
|
2303
2330
|
/// controls — chromeless windows have no system button to click.
|
|
2304
2331
|
/// Platforms without the concept leave this null.
|
|
2305
2332
|
minimize_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
|
|
2306
|
-
/// The real OS show verb: unhide +
|
|
2307
|
-
///
|
|
2308
|
-
///
|
|
2333
|
+
/// The real OS show verb: unhide + order front. It activates by
|
|
2334
|
+
/// default; windows created with `activate_on_show = false` use the
|
|
2335
|
+
/// platform's passive variant. This is the counterpart to a
|
|
2309
2336
|
/// `close_policy = .hide` hide, and the tray "Open" consequence.
|
|
2310
2337
|
/// Platforms without the concept leave this null.
|
|
2311
2338
|
show_window_fn: ?*const fn (context: ?*anyopaque, window_id: WindowId) anyerror!void = null,
|